react native app only in web not working, Ios and Android works fine

I can Run my App without Problems on Ios and Android. If i open it on web, nothing will show up and i get a lot of errors. I don’t understand why tho. The Error: AppEntry.bundle?plat…outerRoot=app:57797 Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Is there any possibility to get this working?

I tried basically everything. I tried to open it on Web with different ways but somehow it still gets errors. It has to work, if it works on Ios and Android, right?

Custom Sorting Issue – Empty values should always stay at Bottom

I am trying to sort my data table based on custom requirement where I need to push the null/empty values to bottom.
I have created data table where there are columns Age and Salary where I kept data empty in some rows. When ever user clicks on Age or Salary column null values should always stay at bottom for asc or desc sort. I have used method and override sort with
$.fn.dataTable.ext.oSort

I provided Link below for my Test Case with Data.
Js Fiddle

IOS camera does not work in pwa but works in browser

I have problems when using the camera (getUserMedia) on the iphone. When using it in the browser (safari) it works perfectly but as soon as I add the pwa to the homescreen it stops working.

My code setup:

<head>
    <link rel="manifest" href="manifest.json">
</head>
<body>
    <video id="video" width="200" height="200" autoplay playsinline muted crossorigin></video>
    <script>
        const video = document.getElementById('video');

        const events = [
          'play', 'waiting', 'loadstart', 'progress', 'suspend',
          'durationchange', 'loadedmetadata', 'loadeddata', 
          'canplay', 'playing', 'canplaythrough', 'timeupdate'
        ];

        events.forEach(e => {
          video.addEventListener(e, () => {
            console.log(`${e} event fired`);
          });
        });

        if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
            navigator.mediaDevices.getUserMedia({ video: true })
            .then(function(stream) {
                video.srcObject = stream;
                    video.onloadedmetadata = () => {
                        video.play();
                    };
                
            })
            .catch(function(error) {
                console.log("Something went wrong!", error);
            });
        }
    </script>
</body>

my manifest.json:

{ "name": "Test-App", "display": "standalone",...

If I remove "display:": "standalone" (or fullscreen, does not matter), the video stream works again…

I’ve tried to see what events are being fired by the video element and if the pwa is open only the loadstart, progress and suspend (in that order) events are fired. If it is opend in the browser every expected event is fired. There are no errors, nothing…

Async function stops in middle

Why this code stops in middle?

async function main () {
    await new Promise(() => {
        console.log('Hello world')
    })
    console.log('debug1')
    await new Promise(r => setTimeout(r, 1000));
    console.log('finish')
}

main()

This code only print “Hello world”, but not “debug1” or “finish”, why?

graphql api fetching issue in next js getting ( Error: React functionality ‘useContext’ is not available in this environment. )

I have created a next js 14.2.3 app & I have graphql api end point(** which I replaced with localhost for stackOverflow )and I am using “@apollo/client”: “^3.10.3”,
“graphql”: “^16.8.1”, for fetching data. I have created a product page path “pages/products”.

import { useQuery, gql } from '@apollo/client';
import { initializeApollo } from '../lib/apollo-client';

const PRODUCTS_QUERY = gql`
  query Products {
   products(first: 10, channel: "default-channel") {
    edges {
     node {
      id
      name
    }
  }
}
}`;

function Products() {
 const apolloClient = initializeApollo();
 const { data, loading, error } = useQuery(PRODUCTS_QUERY, {
  client: apolloClient,
 });

 if (loading) return <p>Loading...</p>;
 if (error) return <p>Error: {error.message}</p>;

 return (
   <div>
    <h1>Products</h1>
    <ul>
      {data && data.products.edges.map(({ node }) => (
       <li key={node.id}>{node.name}</li>
    ))}
  </ul>
</div>
 );}

  export default Products;

I have created a apollo-client,js file

code –
import { useMemo } from ‘react’;
import { ApolloClient, HttpLink, InMemoryCache } from ‘@apollo/client’;

let apolloClient;

function createApolloClient() {
 return new ApolloClient({
  ssrMode: typeof window === 'undefined',
  link: new HttpLink({
  uri: 'http://localhost:8000/graphql/',
}),
cache: new InMemoryCache(),
});}

export function initializeApollo(initialState = null) {
const _apolloClient = apolloClient ?? createApolloClient();

// If your page has Next.js data fetching methods that use Apollo Client, the initial 
state
// gets hydrated here
if (initialState) {
  _apolloClient.cache.restore(initialState);
}
// For SSG and SSR always create a new Apollo Client
if (typeof window === 'undefined') return _apolloClient;
// Create the Apollo Client once in the client
if (!apolloClient) apolloClient = _apolloClient;

return _apolloClient;
}

export function useApollo(initialState) {
const store = useMemo(() => initializeApollo(initialState), [initialState]);
return store;
}

so when I am routing http://localhost:3000/pages/products

getting error – enter image description here

One button with two actions on HTML

I made a button in HTML and when I clicked it the first action worked but the second one didn’t. I want the same button to replace the text with new text after the second click.

<body>
        <button onclick=dosomething(); onclick=dosomething2() style="background-color:
        aquamarine;color:purple;
        font-size:40px;border-radius:100px;">Click Me!</button>

        <p style="color:red;font-size:80px;" id="test"></p>
        <script>
            function dosomething(){
                document.getElementById("test").innerHTML = "Why did you do what it said >:("
            }
        </script>
        <script>
            function dosomething2(){
                document.getElementById("test").innerHTML = "Stop it >:("
            }
        </script>
</body>

RoadMap FrontEnd 2024, Necesito ayuda

Me darían un consejo bien actualizado de un RoadMap para frontEnd 2024?

Mi idea es hacer lo siguiente (tambien coloco herramientas importantes):

  • HTML
  • Css
  • Frameworks como Boostrap/Saas
  • Git
  • JavaSript
  • Logica de Programación
  • TypeScript
  • React/Angular (aca supongo que depende de cada uno)

Que opinan? la realidad que todo esto de forma autodidacta… Ya sea leyendo libros, o buscando buenos canales de youtube donde ofrecen estos cursos bien completos y gratis. Tengo pensado hacerlo en largo plazo, aprendiendo cada uno a la perfección. Mi meta es poder conseguir un trabajo como desarrollador mas adelante.

Espero sus consejos, saludos.

on firefox and firefox developer i cant see the elements of a class on the console

when i use console.log(class) or use a string template the elements i put for each object of the class it says undefined

 mokepones.forEach((mokepon) => {
        MokeponChoice = `
        <input type="radio" name="mascota" id=${mokepon.nombre} />
        <label class="tarjetas-mokepon" for=${mokepon.nombre}>
            <p>${mokepon.nombre}</p>
            <img src=${mokepon.foto} alt="${mokepon.nombre}">
        </label>
        `
        contenedorTarjetas.innerHTML += MokeponChoice
        console.log(mokepon.nombre)
    })

is there a plugin or something that can let me see these elements in firefox developer?

i tried downloading firefox developer to see if i could see it

Datalist behavior in browser that does not support it?

I am developing some HTML for a program which uses Chromium Embedded Framework (CEF), specifically CefSharp.

The exact functionality I want is already perfectly handled with use of datalist elements: an input where the user can free-type and enter any value, but as they type suggestions from a list of expected values can easily be selected to autofill. It also handles finding similar entries i.e, if you type “red” you are suggested “red onion”, and if you type “onion” you are also suggested “red onion”

However, it appears that datalist is not supported.

I am wondering if it would be possible to emulate the behavior of a datalist linked input using JavaScript? The select tag isn’t appropriate for this case because free-typing new values will be just as common as selecting a pre-existing value.

How can I show and hide Like/Unlike buttons using Javascript in my Web app?

I’m doing online course CS50W by Harvard and building a web app similar to twitter.
When user sees a post I need to show the user Like or Unlike button depending on user liked it or not. There’s also a counter showing how many users liked the post so far. I am able to update the counter if the user liked or unliked the post, but I’m having problem with the code showing or hiding the buttons.

Here’s my code:

models.py

class Post(models.Model):
    """ Model representing a post. """
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    content = models.TextField()
    timestamp = models.DateTimeField(auto_now_add=True)
    no_of_likes = models.IntegerField(default=0)

    def __str__(self):
        return f"Post {self.id} by {self.user.username} on {self.timestamp}"
    
class Like(models.Model):
    """ Model representing a like. """
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    post = models.ForeignKey(Post, on_delete=models.CASCADE)
    timestamp = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.user} likes {self.post}"

urls.py

path("", views.index, name="index"),
path("like/<int:post_id>", views.like, name="like"),
path("unlike/<int:post_id>", views.unlike, name="unlike"),

views.py

def index(request):
    """ Home page. """
    posts = Post.objects.all().order_by('-timestamp')
    paginator = Paginator(posts, 5)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)
    likes = Like.objects.all()  
    
    # Make a list of liked posts.
    liked_posts = []
    try:
        for like in likes:
            if like.user.id == request.user.id:
                liked_posts.append(like.post.id)
    except:
        liked_posts = []

    return render(request, "network/index.html", {
        "posts": posts,
        "page_obj": page_obj,
        "likes": likes,
        "liked_posts": liked_posts,             
    })

@login_required
def like(request, post_id):
   
    post = Post.objects.get(pk=post_id)
    user = User.objects.get(pk=request.user.id)
    like = Like.objects.create(user=user, post=post)
    like.save()

    # Update no of likes.
    post.no_of_likes = Like.objects.filter(post=post).count()
    post.save()
    return JsonResponse({"message": "successfully liked", "no_of_likes": post.no_of_likes})

@login_required   
def unlike(request, post_id):
    
    post = Post.objects.get(pk=post_id)
    user = User.objects.get(pk=request.user.id)
    like = Like.objects.filter(user=user, post=post)
    like.delete()

    # Update no of likes.
    post.no_of_likes = Like.objects.filter(post=post).count()
    post.save()
    return JsonResponse({"message": "successfully unliked", "no_of_likes": post.no_of_likes})

index.html with Javascript

{% if post.id not in liked_posts %}
    <button type="button" class="btn btn-primary" id="like{{ post.id }}" onclick="like('{{ post.id         }}')">Like</button>
{% else %}
    <button type="button" class="btn btn-primary" id="unlike{{ post.id }}"onclick="unlike('{{ post.id }}')">Unlike</button>
{% endif %}

function like(id) {
        fetch(`/like/${id}`, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "X-CSRFToken": "{{ csrf_token }}",
            },
        })
        .then(response => response.json())
        .then(data => {
            document.querySelector(".no-of-likes").innerHTML = data.no_of_likes + " likes";
        })
        .then(() => {
            document.getElementById("unlike" + id).style.display = "block";
            document.getElementById("like" + id).style.display = "none";
        });
    }

function unlike(id) {
        fetch(`/unlike/${id}`, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "X-CSRFToken": "{{ csrf_token }}",
            },
        })
        .then(response => response.json())
        .then(data => {
            document.querySelector(".no-of-likes").innerHTML = data.no_of_likes + " likes";
        })
        .then(() => {
            document.getElementById("unlike" + id).style.display = "none";
            document.getElementById("like" + id).style.display = "block";
        });
    }   

I can update the counter without refreshing the page, but it’s not the same with buttons.
This is what happening:

–> When I click Like button counter updates. I have to refresh the page to change button to Unlike. As per the specification this needs to be done asynchronously (assuming with the help of Javascript!) without reloading the page.

–> And it’s same with Unlike button too. When I click it counter updates but I have to reload the page to change the button to Like.

I want to change the buttons without reloading the page. Tried placing code blocks at different places, tried using ‘if else’ conditions but I’m still stuck here. Any help is appreciated!
Sorry for the messy Javascript code, newbie here.

PHP Dynamic row insert and update values in to database

Hello friend I am developing a web application and I have created a dynamic in which when I click add more button it adds more rows into the form and then click submit it passes all values to the database through a for loop iteration

But currently, I have been struck at one point where when a user wants to make some changes in the form I have no idea how to do the update and insert the query into DB

for example, if the user already submitted the dynamic form to db and later the user wants to make some changes in the already inserted dynamic form and add a few new rows to the same form I don’t have any idea how to do that I need some help from my fellow stack overflow community

so below is the full code which is quite long, feel free to check and help me to go through this

Material_request.php page

<?php
if ($requestNo) {

    $query = "SELECT * FROM material_requests WHERE request_no = '$requestNo'";
    $result = mysqli_query($con, $query);


    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {

            $select_item = "SELECT * FROM itemregistration WHERE id = ?";
            $stmt = mysqli_prepare($con, $select_item);
            mysqli_stmt_bind_param($stmt, "s", $row['item_name']);
            mysqli_stmt_execute($stmt);
            $result_itemName = mysqli_stmt_get_result($stmt);

            $row_itemName = mysqli_fetch_assoc($result_itemName);

            if ($row_itemName) {
                // Sanitize data before displaying
                $name = htmlspecialchars($row_itemName['name']);
                // Similarly, sanitize other fields if needed

                ?>
                <div class="form-group addmoreFormGroup" style="margin-top: 30px;">
                    <div class="col-lg-1" style="text-align: center;"
                         hidden="hidden">
                        <div class="col-lg-12">
                            <p class="para" style="margin-top: 30px" id="number">
                                1. </p>
                        </div>
                    </div>
                    <div class="col-lg-3">
                        <label style="margin-left: 16px" class="control-label">Item
                            Name: </label>
                        <div class="col-lg-12">
                            <input type="text" id="itemName" name="itemName"
                                   class="form-control"
                                   onkeyup="autocompleteName();"
                                   value="<?php echo $name ?> ">
                            <input name="id1" id="id1" type="hidden">
                        </div>
                    </div>
                    <!--                                        <div class="col-lg-4">-->
                    <!--                                            <label style="margin-left: 16px" class="control-label">Item Code:</label>-->
                    <!--                                            <div class="col-lg-12">-->
                    <!--                                                <input name="itemCode[]" style="width: 100%; height: 40%"-->
                    <!--                                                       class="form-control" readonly/>-->
                    <!--                                            </div>-->
                    <!--                                        </div>-->
                    <div class="col-lg-2" style="margin-bottom: 30px">
                        <label style="margin-left: 16px" class="control-label">Requested
                            Qty:
                            <span style="color: #CA0609;">*</span>
                        </label>
                        <div class="col-lg-12">
                            <input name="reqQty[]" style="width: 100%; height: 40%"
                                   class="form-control"
                                   value="<?php echo $row['request_qty'] ?>"
                                   required>
                        </div>
                    </div>
                    <div class="col-lg-2" style="margin-bottom: 30px">
                        <label style="margin-left: 16px" class="control-label">Unit
                            of
                            Measure:
                            <span style="color: #CA0609;">*</span>
                        </label>
                        <div class="col-lg-12">
                            <input name="Uom[]" style="width: 100%; height: 40%"
                                   class="form-control"
                                   value="<?php echo $row['unit_of_measure'] ?>"
                                   required>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <label for="Sremark" class="control-label col-lg-12">Special
                            Remark
                            <span style="color: #CA0609;">*</span>
                        </label>
                        <div class="col-lg-12">
                            <textarea class="form-control" name="Sremark[]"
                                      id="Sremark"
                                      required><?php echo htmlspecialchars($row['special_remark']); ?></textarea>
                        </div>
                    </div>
                </div>
                <?php
            }
        }

        ?>

        <div class="form-group col-lg-12">
            <div class="col-lg-3">
                <button type="button" class="btn btn-success add-more-insert"
                        style="font-weight: bold; margin-bottom: 20px;">Add
                    More
                </button>
            </div>
        </div>

        <?php
    } else {
        ?>

        <div class="form-group addmoreFormGroup" style="margin-top: 30px;">
            <div class="col-lg-1" style="text-align: center;" hidden="hidden">
                <div class="col-lg-12">
                    <p class="para" style="margin-top: 30px" id="number">1. </p>
                </div>
            </div>
            <div class="col-lg-3">
                <label style="margin-left: 16px" class="control-label">Item
                    Name:
                    <span style="color: #CA0609;">*</span>
                </label>
                <div class="col-lg-3">
                    <label style="margin-left: 16px" class="control-label">Item
                        Name: </label>
                    <div class="col-lg-12">
                        <input type="text" id="itemName" name="itemName"
                               class="form-control" onkeyup="autocompleteName();">
                        <input name="id1" id="id1" type="hidden">
                    </div>
                </div>
            </div>
            <!--                                        <div class="col-lg-4">-->
            <!--                                            <label style="margin-left: 16px" class="control-label">Item Code:</label>-->
            <!--                                            <div class="col-lg-12">-->
            <!--                                                <input name="itemCode[]" style="width: 100%; height: 40%"-->
            <!--                                                       class="form-control" readonly/>-->
            <!--                                            </div>-->
            <!--                                        </div>-->
            <div class="col-lg-2" style="margin-bottom: 30px">
                <label style="margin-left: 16px" class="control-label">Requested
                    Qty:
                    <span style="color: #CA0609;">*</span>
                </label>
                <div class="col-lg-12">
                    <input name="reqQty[]" style="width: 100%; height: 40%"
                           class="form-control" required/>
                </div>
            </div>
            <div class="col-lg-2" style="margin-bottom: 30px">
                <label style="margin-left: 16px" class="control-label">Unit of
                    Measure:
                    <span style="color: #CA0609;">*</span>
                </label>
                <div class="col-lg-12">
                    <input name="Uom[]" style="width: 100%; height: 40%"
                           class="form-control" required/>
                </div>
            </div>
            <div class="col-lg-4">
                <label for="Sremark" class="control-label col-lg-12">Special
                    Remark
                    <span style="color: #CA0609;">*</span>
                </label>
                <div class="col-lg-12">
                <textarea class="form-control" name="Sremark[]"
                          id="Sremark[]" required></textarea>
                </div>
            </div>
        </div>

        <div class="form-group col-lg-12">
            <div class="col-lg-3">
                <button type="button" class="btn btn-success add-more-insert"
                        style="font-weight: bold; margin-bottom: 20px;">Add
                    More
                </button>
            </div>
        </div>

        <?php
    }
} else {
    ?>

    <div class="form-group addmoreFormGroup" style="margin-top: 30px;">
        <div class="col-lg-1" style="text-align: center;" hidden="hidden">
            <div class="col-lg-12">
                <p class="para" style="margin-top: 30px" id="number">1. </p>
            </div>
        </div>
        <div class="col-lg-3">
            <label style="margin-left: 16px" class="control-label">Item
                Name: </label>
            <div class="col-lg-12">
                <input type="text" id="itemName" name="itemName"
                       class="form-control" onkeyup="autocompleteName();">
                <input  name="id1" id="id1" type="text" hidden="hidden">
            </div>
        </div>
        <!--                                        <div class="col-lg-4">-->
        <!--                                            <label style="margin-left: 16px" class="control-label">Item Code:</label>-->
        <!--                                            <div class="col-lg-12">-->
        <!--                                                <input name="itemCode[]" style="width: 100%; height: 40%"-->
        <!--                                                       class="form-control" readonly/>-->
        <!--                                            </div>-->
        <!--                                        </div>-->
        <div class="col-lg-2" style="margin-bottom: 30px">
            <label style="margin-left: 16px" class="control-label">Requested
                Qty:
                <span style="color: #CA0609;">*</span>
            </label>
            <div class="col-lg-12">
                <input name="reqQty[]" style="width: 100%; height: 40%"
                       class="form-control" required/>
            </div>
        </div>
        <div class="col-lg-2" style="margin-bottom: 30px">
            <label style="margin-left: 16px" class="control-label">Unit of
                Measure:
                <span style="color: #CA0609;">*</span>
            </label>
            <div class="col-lg-12">
                <input name="Uom[]" style="width: 100%; height: 40%"
                       class="form-control" required/>
            </div>
        </div>
        <div class="col-lg-4">
            <label for="Sremark" class="control-label col-lg-12">Special
                Remark
                <span style="color: #CA0609;">*</span>
            </label>
            <div class="col-lg-12">
                <textarea class="form-control" name="Sremark[]"
                          id="Sremark[]" required></textarea>
            </div>
        </div>
    </div>

    <div class="form-group col-lg-12">
        <div class="col-lg-3">
            <button type="button" class="btn btn-success add-more-insert" value="1" onclick="addMore"
                    style="font-weight: bold; margin-bottom: 20px;">Add
                More
            </button>
        </div>
    </div>

    <?php
}
?>

Javascript part of the dynamic form

function autocompleteName() {
  $("#itemName").autocomplete({
    source: "fetch_items.php",
    minLength: 1,
    select: function(event, ui) {
      $('#id1').val(ui.item.id);
      return false;
    }
  });
}

$(document).ready(function() {
  $('.tempSave').click(function() {
    // Create a FormData object to send files
    var formData = new FormData($('#purchaseorderForm')[0]);
    formData.append('tempSave', 1); // Add a flag to indicate temporary save

    // Send AJAX request
    $.ajax({
      type: 'POST',
      url: 'submit_materialRequestTemp.php',
      data: formData,
      processData: false, // Prevent jQuery from automatically processing data
      contentType: false, // Prevent jQuery from setting contentType
      success: function(response) {
        // Handle success response
        alert('Data temporarily saved successfully!');
        console.log(response); // Log the response for debugging
      },
      error: function(xhr, status, error) {
        // Handle error
        alert('Error occurred while saving data.');
        console.error(xhr.responseText); // Log the error response for debugging
      }
    });
  });
});


function selectCode(selectElement) {
  var selectedItemId = $(selectElement).val();
  var itemCodeInput = $(selectElement).closest('.addmoreFormGroup').find('input[name="itemCode[]"]');

  // Make an AJAX call to fetch the item code based on the selected item ID
  $.ajax({
    url: 'get_item_code.php',
    type: 'POST',
    data: {
      item_id: selectedItemId
    },
    success: function(response) {
      // Log the response to the console for debugging
      console.log(response);
      // Set the item code input value within the same row
      itemCodeInput.val(response);
    },
    error: function(xhr, status, error) {
      // Log any errors to the console
      console.error(xhr.responseText);
      // Optionally, display an error message to the user
      alert('Error fetching item code');
    }
  });
}

var count = 2; // Initial row count

// Add more when only inserting
$('.add-more-insert').click(function() {
  // Check if the static row and all existing dynamic rows are filled
  if (isStaticRowFilled() && areDynamicRowsFilled()) {
    var newFormGroup = createFormGroup(count);
    $('.addmoreFormGroup:last').after(newFormGroup);
    count++;
  } else {
    alert('Fill the static row and existing dynamic rows before adding a new row.');
  }
});

function isStaticRowFilled() {
  // Check if the static row is filled
  var itemName = $('#itemName').val();
  var reqQty = $('input[name="reqQty[]"]').val();
  var Uom = $('input[name="Uom[]"]').val();
  var Sremark = $('textarea[name="Sremark[]"]').val();

  return itemName !== '' && reqQty !== '' && Uom !== '' && Sremark !== '';
}

function areDynamicRowsFilled() {
  var areFilled = true;

  // Check each existing dynamic row
  $('.addmoreFormGroup').each(function() {
    var itemName = $(this).find('#itemName').val();
    var reqQty = $(this).find('input[name="reqQty[]"]').val();
    var Uom = $(this).find('input[name="Uom[]"]').val();
    var Sremark = $(this).find('textarea[name="Sremark[]"]').val();

    // If any dynamic row is not filled, set areFilled to false
    if (itemName === '' || reqQty === '' || Uom === '' || Sremark === '') {
      areFilled = false;
      return false; // exit the loop
    }
  });

  return areFilled;
}

$('form').submit(function() {
  // Check if the static row and all existing dynamic rows are filled
  if (isStaticRowFilled() && areDynamicRowsFilled()) {
    // The form is filled, proceed with submission
    return true;
  } else {
    alert('Fill all rows before submitting the form.');
    return false; // Prevent form submission
  }
});

// Remove form group
$(document).on('click', '.remove-form-group', function() {
  var formGroup = $(this).closest('.addmoreFormGroup');
  formGroup.remove();
  count--;

  // Update the remaining row numbers
  updateRowNumbers();
});

function createFormGroup(number) {
  var formGroup = `
        <div class="form-group col-lg-12 addmoreFormGroup">
            <div class="col-lg-1" style="text-align: center;" hidden = "hidden">
                <div class="col-lg-12">
                    <p class="para" style="margin-top: 30px" id="number">${number}. </p>
                </div>
            </div>
           <div class="col-lg-3">

                                            <div class="col-lg-12">
                                                <input type="text" id="itemName" name="itemName"
                                                       class="form-control" onkeyup="autocompleteName();">
                                                <input  name="id1" id="id1" type="text" hidden="hidden">
                                            </div>
                                        </div>

            <div class="col-lg-2" style="margin-bottom: 30px">

                <div class="col-lg-12">
                    <input name="reqQty[]" style="width: 100%; height: 40%" class="form-control"/>
                </div>
            </div>

            <div class="col-lg-2" style="margin-bottom: 30px">

                <div class="col-lg-12">
                    <input name="Uom[]" style="width: 100%; height: 40%" class="form-control"/>
                </div>
            </div>

            <div class="col-lg-3">

                <div class="col-lg-12">
                    <textarea class="form-control" name="Sremark[]" id="Sremark[]"></textarea>
                </div>
            </div>

            <div class="col-lg-2">
                <button style="margin-top: 35px; margin-left: 18px" class="remove-form-group btn btn-danger">Remove</button>
            </div>
        </div>
    </div>`;

  return formGroup;
}

function updateRowNumbers() {
  $('.addmoreFormGroup').each(function(index) {
    $(this).find('#number').text(index + 1 + '.');
  });
}

// Update button click event
$('#tUpdate').click(function(e) {
  e.preventDefault(); // Prevent default form submission

  // Serialize form data
  var formData = $('#purchaseorderForm').serialize();

  // Append the count of added rows to the form data
  formData += '&addedRows=' + (count - 2); // Subtract 2 to exclude the initial row and the first dynamic row

  // Send form data asynchronously
  $.post('updateMaterialRequest.php', formData)
    .done(function(response) {
      // Handle success
      console.log(response); // Log the response
      // You can handle success message or redirect here if needed
    })
    .fail(function(xhr, status, error) {
      // Handle failure
      console.error(xhr.responseText); // Log error response
      // You can handle failure message here
    });
});

please help me to find a way to update the values

Errors in Importing assets folder with static url in React parcel project

I am trying to serverside render a react page using Django. The server-side rendering is working fine for normal react components. The project is using parcel to auto-build javaScript files so that Django could render them. This is the command I am using to compile react to Js.
"scripts": { "watch": "parcel watch src/index.tsx --public-url /assets/" }

I am new to the parcel, So sorry for the poor framing of the problem and/or any wrong terminology.

The problem comes whenever I try to import an assets component in my assets folder into my react components. The import statement in my react code is working fine but I am getting an error in the import statements of the assets folder telling the file path for import is wrong. Here is the below screenshot of the issue.

enter image description here

@parcel/core: Failed to resolve 'assets/theme/base/typography' from './src/assets/theme/index.js'

  C:profitionalBRAVOServerassetssrcassetsthemeindex.js:23:24
    22 | import breakpoints from "assets/theme/base/breakpoints";
  > 23 | import typography from "assets/theme/base/typography";
  >    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    24 | import boxShadows from "assets/theme/base/boxShadows";
    25 | import borders from "assets/theme/base/borders";

Done in 689.72s.

C:profitionalBRAVOServerassets>yarn parcel watch src/index.tsx
yarn run v1.22.19
$ C:profitionalBRAVOServerassetsnode_modules.binparcel watch src/index.tsx
× Build failed.

@parcel/core: Failed to resolve 'assets/theme/base/breakpoints' from './src/assets/theme/index.js'

  C:profitionalBRAVOServerassetssrcassetsthemeindex.js:22:25
    21 | import colors from "assets/theme/base/colors";
  > 22 | import breakpoints from "assets/theme/base/breakpoints";
  >    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    23 | import typography from "assets/theme/base/typography";
    24 | import boxShadows from "assets/theme/base/boxShadows";

The issue with this is that I am not able to figure out how to adjust the assets files properly in the react parcel project configurations so that I don’t need to change any of the assets paths.

The is my file paths in the project where:

Server is the Django project root folder

  • assets (Has all react code for SSR)
    • src
      • assets(the folder I am trying to import)
        • theme
          -index(file that is causing the error)

enter image description here
enter image description here

The error is not caused by just one asset import, it’s going to be caused by all the import statements in the src/assets folder. I already tried to change all the file paths in the assets folder that are causing the issue but it’s too cumbersome. What can I do to solve this issue in this React parcel project?

,parcelrc file

{
  "extends": ["@parcel/config-default"],
  "resolvers": ["@parcel/resolver-glob", "..."]
}

jsconfig.json file

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "*": ["public/src/*"]
    }
  }
}

Thank you for taking the time to help me with this issue. If you need any additional information please ask in the comments section.

I am expecting to solve this import statment issues by changing the assets folder path in config files so that I don’t have to change all the import statment paths in src/assets folder.

Fastify implement authentication plugin

i can’t call authentication, when try to check auth
es

fastify.get<{ Querystring: IQuerystring; Reply: IReplyCurrent }>(
  '/at/api',
  {
    onRequest: [fastify.authentication()],
  },

---

// plugins/route.ts
export async function authRoute(fastify: FastifyInstance, option: object, done: () => void) {
  // #region addone to fastify
  fastify.register(import('@fastify/jwt'), {
    secret: 'secret-key',
  });

// index.ts
fastify.register(authRoute, { prefix: '/auth' });

fastifyPlugin(async function (fastify, opts, done) {
  fastify.decorate('authentication', async (request, reply) => {
    try {
      await request.jwtVerify();
    } catch (error) {
      reply.code(401).send({ error: 'Unauthorized' });
    }
  });
  done();
});

I won check if client it’s call api ase authenticate and if autenticate is expired i won use refresh token for create another

Not able to connect my SQL server with my Express JS API in windows authentication mode

I have created a sample API that connects to my Microsoft SQL Server. I have used the following code to do so:

var express = require("express");
var app = express();

app.get("/", function (req, res) {
  var sql = require("mssql/msnodesqlv8");
  var config = {
    driver: "msnodesqlv8",
    connectionString:
      "Driver={SQL Server Client 16.0};Server=.\LAPTOP-***;Database=Test;Trusted_Connection=yes;",
  };
  const pool = new sql.ConnectionPool(config)
    .connect()
    .then((pool) => {
      return pool.request().query("Select * From dbo.Test123");
    })
    .then((result) => {
      let rows = result.recordset;
      res.status(200).json(rows);
      sql.close();
    })
    .catch((err) => {
      res.status(500).send({ message: `${err}` });
      sql.close();
    });
});

var server = app.listen(5000, function () {
  console.log("Server is running..");
});

and I have been getting the following output in my localhost:5000:

{
  "message": "ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
}

I have tried the following above code and been trying to get the result of query in my console.