OpenAI API key with “proj-” prefix not working when read from .env file

I’m working on a Next.js/React/TypeScript project that integrates with the OpenAI API. I’ve encountered an issue with the new Project-based API keys feature.
Previously, I successfully used this setup:

typescriptCopyconst openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, });

My .env file contained:

OPENAI_API_KEY=sk-xxxxx

However, with the new Project-based API keys (format: sk-proj-xxxxx), this setup no longer works. I’m receiving an invalid_api_key error.

I’ve noticed that process.env.OPENAI_API_KEY seems to strip the proj- part from the API key when reading it from the .env file.

Oddly enough, using the key as a plain string works fine:
const openai = new OpenAI({ apiKey: "sk-proj-xxxxx", });

I’ve scoured the OpenAI documentation and googled the hell out of it but haven’t found any solutions. The closest relevant information I found was in the OpenAI Authentication documentation.

Has anyone encountered this problem? Any insights or solutions would be greatly appreciated! 🙂

My route.ts:

import { auth } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";
import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: "process.env.OPENAI_API_KEY", //this seems to be the issue
});

const instructionMessage = {
  role: "system",
  content: `blah blah instructions`,
};

async function POST(req: Request) {
  try {
    const { userId } = auth();
    const body = await req.json();
    const { messages } = body;
    const lastMessage = messages[messages.length - 1];

    if (!userId) {
      return new NextResponse("Unauthorized", { status: 401 });
    }

    if (!openai.apiKey) {
      return new NextResponse("OpenAi Api Key not configured"), { status: 500 };
    }

    if (!messages || messages.length === 0) {
      return new NextResponse("Input Required", { status: 400 });
    }

    const response = await openai.chat.completions.create({
      model: "gpt-4o-mini",
      messages: [instructionMessage, lastMessage],
    });

    return NextResponse.json(response.choices[0].message);
  } catch (error) {
    console.log("[CODE_ERROR]", error);
    return new NextResponse("Internal error", { status: 500 });
  }
}

export { POST };

Returning Object Values in Javascript

Maybe I’m overthinking this. Will probably end up getting the answer if I just take a break from it for a second but I can’t get my head around it at the moment. Doing Javascript basics, and the problem question relates to amending objects in a function.

Will add the code below.
Sorry if I miss any details out – this is my first time seeking support on this community forum!

The question essentially presents you with object ‘Kitchen’ but with a few ‘issues’ that need sorting to make it read better. I’ve ‘passed’ 6 but failing the 7th requirement.

Requirements are:

  1. is a function – DONE
  2. should return a kitchen with the correct keys (hasFridge, favouriteAppliance, food, petName, totalShelves) – DONE
  3. should change each string to lower case in the object item – DONE
  4. should delete the hoover property, if present in the object – DONE
  5. should return the correct total number of shelves (5) – DONE
  6. should return the correct total number of shelves if only one shelf key is present

✕ AssertionError: expected 5 to equal 3

  1. should remove other shelf keys – DONE

The object:

let kitchen = {
  hasFridge: true, 
  favouriteAppliance: "KeTtlE",
  drinks: "lemoNAdE",
  food: "eGgS",
  shelvesInCupboards: 3,
  shelvesNotInCupboards: 2,
  petName: "RhuBarB",
  hoover: "DysOn" 
};

My code:

function sortTheKitchen(kitchen) {
    console.log(kitchen);
    delete kitchen.shelvesNotInCupboards
      const kitchenItems = {
        hasFridge: true,
        favouriteAppliance: 'kettle',
        food: 'eggs',
        petName: 'rhubarb',
        drinks: 'lemonade',
        shelvesInCupboards: 3
      };
      for (const key in kitchenItems) {
          for (const key1 in kitchen) {
            if (key === key1) {
              kitchen[key1] = kitchenItems[key]
            }
            if (key1 === 'hoover') {
              delete kitchen[key1]
            }
          }
      }
    delete kitchen.shelvesInCupboards
    kitchen.totalShelves = 5 
    return kitchen;
}

Am I overlooking the solution to “Module ‘fs’ has been externalized for browser compatibility”?

Just so you get an understanding of the situation, I am trying to build a web game library that runs on my computer. It is pretty much a rip off of the Nintendo Wii and 3DS. I’m using Vite as the server I use to access the webpages, and WS so I can run multiplayer games and services. The next thing I want to do is file manipulation so I can create save files for whatever game, but I have been having issues with file manipulation.

I have a test run file that is suppose to change the text of “hello.txt” from “Hello there” to “Good Bye”. I am using Node/fs to edit files, and when I import fs after I run index.js, I get this error:
Uncaught Error: Module "fs" has been externalized for browser compatibility. Cannot access "fs.fs" in client code.

I looked all over the internet to find the solution to this problem, and I have found it, but I still get this error.

For clarification, the answer was to install vite-plugin-node-polyfills and type this into vite.config.ts:

import { nodePolyfills } from 'vite-plugin-node-polyfills'

export default defineConfig({
  plugins: [
    nodePolyfills(),
  ],
})

Is there more to this solution that I am missing, or am I doing it all wrong? Also what does, “Cannot access ‘fs.fs’ in client code,” mean? Is this something I’m completely overlooking?

If you need anymore information, I’ll be here.

Add click event function to folium markers with Python

I have made an html file that consists of a folium map with several markers on the right half of the screen. On the left half of the screen I have an html container consisting of several items, where each item is a description and several images.

Each item corresponds to a location of a marker, e.g. One marker is located on Bangkok and in the html container I have a corresponding story and images. I want to add a click event to each marker, such that when you click on a marker, the left side automatically scrolls down to the text/images corresponding to said marker (see image below).

Example layout

I have found a similar issue in this thread below, but I have no clue how to adjust the function onClick(e) to suit my needs.
Show path in folium map by clicking or hovering marker

Thanks in advance!

console.log showing different values in object and in property of the same object

I have a NextJS project with Typescript, and this code is from a cart state manager with zustand, on. I have a map function that change two properties, but one of them acting weird.
The ‘name’ property is changing correctly, but the itemPrice property only change when I try accessing the property directly trough the object, when I access the entire object the value is not the same…

Result
Code for the function

Here is the code for the store.ts file :

import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import { round2 } from '@/lib/utils';
import {
  EscompteCaisse,
  EscompteCaisseSchema,
  OrderPassItem,
  OrderPublicItem,
  Product,
  ShippingAddress,
} from '@/schemas/caisse-schemas';

type Cart = {
  items: OrderPublicItem[];
  itemsPrice: number;
  taxPrice: number;
  escompte: number;
  escomptePrice: number;
  totalPrice: number;
  fullPrice: number;

  paymentMethod: string;
  shippingAddress: ShippingAddress;
};
const initialState: Cart = {
  items: [],
  itemsPrice: 0,
  taxPrice: 0,
  escompte: 0,
  fullPrice: 0,
  escomptePrice: 0,
  totalPrice: 0,
  paymentMethod: 'PayPal',
  shippingAddress: {
    fullName: '',
    address: '',
    city: '',
    postalCode: '',
    country: '',
  },
};

export const cartStore = create<Cart>()(
  persist(() => initialState, {
    name: 'cartStore',
  })
);

export default function usePersonnelCartService() {
  const {
    items,
    itemsPrice,
    taxPrice,
    escompte,
    escomptePrice,
    totalPrice,
    fullPrice,
    paymentMethod,
    shippingAddress,
  } = cartStore();
  return {
    items,
    itemsPrice,
    taxPrice,
    escompte,
    escomptePrice,
    totalPrice,
    fullPrice,
    paymentMethod,
    shippingAddress,
    increase: (item: OrderPassItem) => {
      console.log(items);
      const exist = items.find((x) => x.slug === item.slug);

  if (!exist?.format.find((v) => v.name === item.format.name)) {
    exist?.format.push({
      id: item.format.id,
      name: item.format.name,
      price: item.format.price,
      qty: item.format.qty,
    });
  }

  const updatedItems = exist
    ? items.filter((x) =>
        x.slug === item.slug
          ? x.format.filter((fo) =>
              fo.name === item.format.name
                ? ((fo.qty = fo.qty + 1),
                  (exist.itemPrice = exist.itemPrice + fo.price))
                : x
            )
          : x
      )
    : [
        ...items,
        {
          ...item,
          itemPrice: item.itemPrice || 0 + item.format.price,
          format: [
            {
              id: item.format.id,
              name: item.format.name,
              price: item.format.price,
              qty: 1,
            },
          ],
        },
      ];

  const updatedCartItems = updatedItems.map((item) => ({
    ...item,
    itemPrice: item.itemPrice - item.itemPrice * escompte,
  }));
  console.log(updatedCartItems, 'increase');

  const { itemsPrice, taxPrice, totalPrice, fullPrice } = calcPrice(
    updatedCartItems,
    escompte
  );
  cartStore.setState({
    items: updatedCartItems,
    itemsPrice,
    taxPrice,
    totalPrice,
    fullPrice,
  });
},
set: (item: OrderPassItem) => {
  const exist = items.find((x) => x.slug === item.slug);

  if (!exist?.format.find((v) => v.name === item.format.name)) {
    exist?.format.push({
      id: item.format.id,
      name: item.format.name,
      price: item.format.price,
      qty: item.format.qty,
    });
  }

  const updatedItems = exist
    ? items.filter((x) =>
        x.slug === item.slug
          ? x.format.filter((fo) =>
              fo.name === item.format.name
                ? ((fo.qty = fo.qty + item.format.qty),
                  (exist.itemPrice =
                    exist.itemPrice + fo.price * item.format.qty))
                : x
            )
          : x
      )
    : [
        ...items,
        {
          ...item,
          itemPrice:
            item.itemPrice + item.format.price * item.format.qty ||
            0 + item.format.price * item.format.qty,
          format: [
            {
              id: item.format.id,
              name: item.format.name,
              price: item.format.price,
              qty: item.format.qty,
            },
          ],
        },
      ];

  const updatedCartItems = updatedItems.map((item) => ({
    ...item,
    itemPrice: item.itemPrice - item.itemPrice * escompte,
  }));

  const { itemsPrice, taxPrice, totalPrice, fullPrice } = calcPrice(
    updatedCartItems,
    escompte
  );
  cartStore.setState({
    items: updatedCartItems,
    itemsPrice,
    taxPrice,
    totalPrice,
    fullPrice,
  });
},

decrease: (item: OrderPassItem) => {
  const exist = items.find((x) => x.slug === item.slug);
  if (!exist) return;

  const updatedItems =
    item.format.qty <= 1
      ? items.filter((x: OrderPublicItem) => x.slug !== item.slug)
      : items.filter((x) =>
          x.slug === item.slug
            ? x.format.filter((fo) =>
                fo.name === item.format.name && fo.qty !== 0
                  ? ((fo.qty = fo.qty - 1),
                    (exist.itemPrice = exist.itemPrice - fo.price))
                  : x
              )
            : x
        );

  const updatedCartItems = updatedItems.map((item) => ({
    ...item,
    itemPrice: item.itemPrice - item.itemPrice * escompte,
  }));

  const { itemsPrice, taxPrice, totalPrice, fullPrice } = calcPrice(
    updatedCartItems,
    escompte
  );
  cartStore.setState({
    items: updatedCartItems,
    itemsPrice,
    taxPrice,
    totalPrice,
    fullPrice,
  });
},

addEscompte: (esc: EscompteCaisse | undefined) => {
  const escompte = esc?.montant || 0;

  console.log('before', items, items[0].itemPrice, items[0].name);

  const updatedCartItems = items.map((item) => ({
    ...item,
    itemPrice: 10,
    name: 'name',
  }));

  console.log(
    'updated',
    updatedCartItems,
    updatedCartItems.map((item) => item.itemPrice),
    updatedCartItems[0].name,
    updatedCartItems[0].itemPrice
  );

  const { itemsPrice, taxPrice, totalPrice, fullPrice } = calcPrice(
    updatedCartItems,
    escompte
  );
  cartStore.setState({
    items: updatedCartItems,
    itemsPrice,
    taxPrice,
    totalPrice,
    fullPrice,
    escompte,
  });
},

resetEscompte: () => {
  const updatedCartItems = items;

  updatedCartItems.map(
    (item) =>
      (item.itemPrice = item.format.reduce(
        (acc, f) => acc + f.qty * f.price,
        0
      ))
  );

  console.log(updatedCartItems, 'resetEscompte');

  const { itemsPrice, taxPrice, totalPrice, fullPrice } = calcPrice(
    updatedCartItems,
    escompte
  );
  cartStore.setState({
    items: updatedCartItems,
    itemsPrice,
    taxPrice,
    totalPrice,
    fullPrice,
    escompte: 1,
  });
},
// addEscompte: (escompte: EscompteCaisse | undefined) => {
//   const { itemsPrice, taxPrice, totalPrice } = calcPrice(
//     items,
//     escompte?.montant || 0
//   );
//   cartStore.setState({
//     items,
//     itemsPrice,
//     escompte: escompte?.montant,
//     taxPrice,
//     totalPrice,
//   });
// },

saveShippingAddrress: (shippingAddress: ShippingAddress) => {
  cartStore.setState({
    shippingAddress,
  });
},
savePaymentMethod: (paymentMethod: string) => {
  cartStore.setState({
    paymentMethod,
  });
},
clear: () => {
  cartStore.setState({
    items: [],
    itemsPrice: 0,
    escomptePrice: 0,
    escompte: 0,
    totalPrice: 0,
    taxPrice: 0,
    fullPrice: 0,
  });
},
init: () => cartStore.setState(initialState),
  };
}

// const calcPriceBackup = (items: OrderPublicItem[]) => {
//   const itemsPrice = round2(
//       items.reduce((acc, item) => acc + item.price * item.qty, 0)
//     ),
//     escomptePrice = round2(itemsPrice > 100 ? 0 : 100),
//     taxPrice = round2(Number(0.15 * itemsPrice)),
//     totalPrice = round2(itemsPrice + escomptePrice + taxPrice);
//   return { itemsPrice, escomptePrice, taxPrice, totalPrice };
// };
const calcPrice = (items: OrderPublicItem[], escompte: number) => {
  const itemsPrice = round2(
      items.reduce((acc, item) => acc + item.itemPrice, 0)
    ),
    escomptePrice = round2(escompte * itemsPrice),
    taxPrice = round2(Number(0 * itemsPrice)),
    fullPrice = round2(
      items.reduce(
        (acc, item) =>
          acc +
          (item.itemPrice = item.format.reduce(
            (acc, f) => acc + f.qty * f.price,
            0
          )),
        0
      )
    ),
    totalPrice = itemsPrice;

  return { itemsPrice, escomptePrice, taxPrice, totalPrice, fullPrice };
};

Let me know if more code is necessary, but I cannot understand how console.log can output to different value for the same object in the same call ???

I’m expecting the itemPrice to change with the map function. For the ‘name’ property all is working correctly, but for the itemPrice property, the console.log is showing contradictory values… I tried on both Chrome and Firefox on two different computer.

And the final value that is set to the state is the one in the object, so the wrong one.

Websocket in nodejs does not work after page refresh

Hey I am getting into Node.js with express and I tried to use Websockets for Client-Server communication. The communication works fine until the client refreshs the page for some reason. The then newly created Websocket connection does not get all messages from the server.
HTML part (I know that the messages are sent twice to the client, I was just trying both of them)

// Create WebSocket connection.
const socket = new WebSocket("ws://localhost:8080");

// Listen for messages
socket.addEventListener("message", (event) => {
  console.log("Message from server ", event.data);
  document.getElementById("data_field_id").textContent = event.data;
});

socket.onmessage = function (event) {
  console.log("Message from server ", event.data);
   document.getElementById("data_field_id").textContent = event.data;
};

// Log WebSocket close event
socket.addEventListener("close", (event) => {
  console.log("WebSocket is closed now.");
});

// Log WebSocket error event
socket.addEventListener("error", (event) => {
  console.error("WebSocket error observed:", event);
});

The javascript nodejs code looks like this:

app.listen(3000, () => {
    console.log("It Works!");
});

app.get('/', (req, res) => {
    res.sendFile('index.html', {
        root: './'
    });
})

wss.on('connection', (ws) => {
    

    console.log("Client connected");
    ws.send(" Server ready...");

    setTimeout(function () {
        ws.send("AWAITED") // will be executed after the specified time
    }, 5000);

    function sendUpdate(status) {
        ws.send(status);
    }
    
    ws.on('close', () => {
        console.log('Client disconnected');
    });



    app.get('/download', async (req, res) => {
        firstStepInDownload();
        sendUpate("FIRST STEP DONE");
    }
    firstStepInDownload{
       // This method sends status updates while processing
       ws.send("RUNNING FIRST STEP")
       }

The thing is now that when going onto localhost it works fine. Client gets all messages “Server ready…”, “AWAITED”, “RUNNING FIRST STEP” and “FIRST STEP DONE”. But when I refresh the page, only the “Server ready…” message and the “AWAITED” message are sent for some reason. The other two are not sent to the client when triggering the processing. Can someone tell why? I already tried putting the functions outside the wss. block and just forwarding the ws entity to the functions but that did not work neither. Can someone help? If you want to try it yourself I can share the github link.

Is It Possible to Override Behavior of ons-button-back But Keep Default Animation?

I’m working on a small single page application in Onsen UI. It presents multiple screens that collect form data, all of which gets submitted to a mySql database on the backend on the last page template. As users are free to move back and forth through previously loaded templates, I’ve overridden the behavior of the Onsen back button to bring a previously visited page to the top of the navigation stack, rather than pop it off the stack. This is working, but I’d like to maintain the default animation of the back button. What is currently happening is I’m getting the same animation effect that occurs by default when a regular Onsen button is clicked. Is it possible to maintain the default back button animation behavior (e.g., slide out vs. slide in)?

If not, I’m wondering if it would be possible to define my own class that inherits most of the behavior from ons-back-button, but overrides just the stack navigation behavior (bring a page to the top of the stack rather than popping it)? I haven’t really worked with the new ES6 classes yet, so thought I’d ask here before trying that approach.

Here’s the current code I’m using for the back button:

document.querySelector('ons-back-button').onClick = function() {
   previous('page1.html');       
};

function previous(page){
    const prevNav = document.querySelector('#navigator');
    prevNav.bringPageTop(page);
}
      

And here’s the navigator element HTML:

<ons-splitter>
    <ons-splitter-side id="menu" side="left" width="220px" collapse swipeable>
        <ons-page>
            <ons-list>
                <ons-list-item onclick="fn.load('page1.html')" tappable>Vehicle Information</ons-list-item>
                <ons-list-item onclick="fn.load('page2.html')" tappable>Exterior Damage</ons-list-item>
                <ons-list-item onclick="fn.load('page3.html')" tappable>Glovebox Check</ons-list-item>
                <ons-list-item onclick="fn.load('page4.html')" tappable>Interior Check</ons-list-item>
                <ons-list-item onclick="fn.load('page5.html')" tappable>Road Test</ons-list-item>
                <ons-list-item onclick="fn.load('page6.html')" tappable>Lights Check</ons-list-item>
                <ons-list-item onclick="fn.load('page7.html')" tappable>Fluid Inspection</ons-list-item>
                <ons-list-item onclick="fn.load('page8.html')" tappable>Tire Inspection</ons-list-item>
                <ons-list-item onclick="fn.load('signature.html')" tappable>Signature</ons-list-item>
            </ons-list>
        </ons-page>
    </ons-splitter-side>
    <ons-splitter-content id="content">
        <ons-navigator animation="slide" animation-options="{ duration: 0.3 }" id="navigator" page="page1.html">        
        </ons-navigator>
    </ons-splitter-content>
</ons-splitter>

useParams Returns Undefined values

I’m using react-router-dom 5.2.0

App.jsx

`<Route path="/shop">
<ProductListPage />
</Route>
<Route path="/shop/:page">
<ProductListPage />
</Route>
<Route path="/shop/:gender/:category?">
<ProductListPage />
</Route>
<Route path="/shop/:filter">
<ProductListPage />
</Route>`

ProductListPage.jsx

`import { useParams } from "react-router-dom";

export default function ProductListPage() {
let { page } = useParams();
let { gender, category } = useParams();
let { filter } = useParams();

console.log(page + " " + gender + " " + filter + " " + category);

return (
<div className="bg-light-gray-1">
  <ProductCategories />
  <ProductList />
  <ClientList />
</div>
);
}`

Can’t get page or gender or anything, just undefined.

I have one page for listing all products.
Second one is for pagination
Third one is for categorization
And fourth one is for filtering

But variables where i get from links is not working. For example;
"/shop/women/tshirt" "/shop/man/shoe" "/shop/1

I’ve tried to get values like this but keep getting undefined values.

`import { useParams } from "react-router-dom";

export default function ProductListPage() {
let { page } = useParams();
let { gender, category } = useParams();
let { filter } = useParams();

console.log(page + " " + gender + " " + filter + " " + category);

How to apply data- attribute to rows from array of column headers

I have created a table in Angular using the column and row arrays at the bottom of this post. I have been trying to add a data-cell attribute to each row programmatically, which I have successfully done — I just can’t populate the attribute with data.

The desktop view is fine. On mobile devices, I am moving to a stacked version of the table (see image way at the bottom below the data) and I want to leverage the data-cell attribute to place the column headers above the appropriate cell data. If you look at the image, I want each column header to appear where the colons are currently appearing.

So far, I have the written this code. I just need a little help to get to the finish line, please and thank you.

const tds = Array.from(document.querySelectorAll('td'));

// Add data-cell attribute programatically
tds.forEach(td => {

  this.columns.forEach((col) => {
    console.log('HEADER: ', col.header);
    return col.header;
  })

  this.rows.forEach(row => {
    console.log('ROW: ', row)
    return row;
  })

  //td.setAttribute('data-cell', row.header)
})

=================================================================================

let columns: TableColumn[] = [
  {
    header: "Beverages",
    key: "name",
    sortable: true,
    cell: (item: any) => {
      return item.name;
    }
  },
  {
    header: "Cost",
    key: "cost",
    sortable: true,
    cell: (item: any) => {
      return item.cost;
    },
  },
  {
    header: "Text",
    key: "text",
    sortable: true,
    cell: (item: any) => {
      return item.text ? "Yes" : "No";
    },
  },
  {
    header: "Date",
    key: "date",
    sortable: true,
    cell: (item: any) => {
      return item.date;
    },
  },
  {
    header: "Unsortable",
    key: "unsortable",
    sortable: false,
    cell: (item: any) => {
      return item.unsortable;
    },
  }
]

let rows: any[] = [
  {
    id: 1,
    name: "Water",
    cost: 100,
    text: true,
    date: "05021967",
    unsortable: "12 Fountain Street, Andover, MA"
  },
  {
    id: 2,
    name: "Soda",
    cost: 250,
    text: false,
    date: "12121963",
    unsortable: "23 Oakland Avenue, Louisville, KY"
  },
  {
    id: 3,
    name: "Coffee/Tea",
    cost: 50,
    text: true,
    date: "03111964",
    unsortable: "4 Maple Road, Stone Mountain, GA"
  }
]

stacked version of my table for mobile devices

Error: Unable to resolve module missing-asset-registry-path with React Native app

I am trying to build a react native project and it is giving me an asset path error. I checked and double checked everything and I can not figure out why I am getting this issue.

here is the error:

info Dev server ready

i - run on iOS
a - run on Android
d - open Dev Menu
r - reload app

info Opening app on iOS...
info A dev server is already running for this project on port 8081.
info Found Xcode workspace "Grubber.xcworkspace"
info Found booted iPhone 15 Pro Max
info Building (using "xcodebuild -workspace Grubber.xcworkspace -configuration Debug -scheme Grubber -destination id=0C686315-2040-48D2-8D24-97C5F4422F75")
success Successfully built the app
info Installing "/Users/omarjandali/Library/Developer/Xcode/DerivedData/Grubber-fmzgeggnhellaudxvdkwklgxliav/Build/Products/Debug-iphonesimulator/Grubber.app on iPhone 15 Pro Max"
info Launching "app.grubber.grubber"
success Successfully launched the app on the simulator
 BUNDLE  ./index.js 

error: Error: Unable to resolve module missing-asset-registry-path from /Users/omarjandali/GrubberLLC/Grubber/src/Assets/Verified-icon.png: missing-asset-registry-path could not be found within the project or in these directories:
  node_modules
> 1 | �PNG
  2 | 
  3 | 
  4 | IHDR��>a�tEXtSoftwareAdobe ImageReadyq�e<�IDATx���U�0G���{H7�    &H�� �4� aؠ��l��+2$&;��?����cHBpt�e9�� �c�}�?��Gvqf�I�{[�_�� _�W��v�ti�LF    ��]�4�����t�W#��n   
                                                        �uK`��[|����_���%0��-��n    
                                                                                        �uK`��[���]
                                                                                                   =�eyV/��l�yqe�Z%'��~`��=���Ζk+�s�X�#��i�켋 ����7t�o^��HK�pu_
                                          ���zɩ���x�/[�o���"}�o>��v��5e';�>�&�g�瓚�BW��[��=2��0��@@� A@� A�w9���uݷ�(]mi5*�_��{geˏ�m8�w[�^R�����ʞn���,��� �p�%I0�?�7`�2�:�4B>�?�kY^���{�_�������(�u��
                                                                                   ���KL��?���/����ٺ;0��
    at ModuleResolver.resolveDependency (/Users/omarjandali/GrubberLLC/Grubber/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:138:15)
    at DependencyGraph.resolveDependency (/Users/omarjandali/GrubberLLC/Grubber/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
    at /Users/omarjandali/GrubberLLC/Grubber/node_modules/metro/src/lib/transformHelpers.js:156:21
    at resolveDependencies (/Users/omarjandali/GrubberLLC/Grubber/node_modules/metro/src/DeltaBundler/buildSubgraph.js:42:25)
    at visit (/Users/omarjandali/GrubberLLC/Grubber/node_modules/metro/src/DeltaBundler/buildSubgraph.js:83:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 12)
    at async visit (/Users/omarjandali/GrubberLLC/Grubber/node_modules/metro/src/DeltaBundler/buildSubgraph.js:92:5)
    at async Promise.all (index 3)
    at async visit (/Users/omarjandali/GrubberLLC/Grubber/node_modules/metro/src/DeltaBundler/buildSubgraph.js:92:5)

Here is my metro.config.js file:

const { getDefaultConfig } = require('metro-config');

module.exports = (async () => {
  const {
    resolver: { assetExts, sourceExts },
  } = await getDefaultConfig();

  return {
    transformer: {
      getTransformOptions: async () => ({
        transform: {
          experimentalImportSupport: false,
          inlineRequires: false,
        },
      }),
    },
    resolver: {
      assetExts: [...assetExts, 'png', 'jpg', 'jpeg'],
      sourceExts: [...sourceExts, 'jsx', 'js', 'ts', 'tsx'],
    },
  };
})();

I am importing the images here:

const Verified = require('../../Assets/Verified-icon.png');

The path to the images is correct and the file name is correct. It is just not accepting the image for some reason.

WordPress – On click of image carousel with lightbox, taking to image url and then showing lightbox

I have a wordpress website where I am using elementor Image Carousel in Blocksy theme. Here are the option I have selected for the images

  1. Link – Media File
  2. Lightbox – Yes

When I click on the image, first I am navigated to media url – /wp-content/uploads/image
and when I go back, I see the lightbox (default one with elementor) opened with the image in full screen.

Here, on click of a image, I want to just open the lightbox without navigating to /wp-content/uploads/image path. How can I achieve this?

I tried running the below jQuery and also similar php code using WP Code Light Plugin. also tried few chatgpt answers which didn’t work.

    // Ensure the script runs after the DOM is fully loaded
    $('.carousel a').on('click', function(e) {
        e.preventDefault(); // Prevent the default link behavior

        // Get the href attribute of the clicked link
        var href = $(this).attr('href');

        // Ensure the lightbox plugin is available and has a method to open images
        if (typeof $.featherlight === 'function') {
            $.featherlight(href); // Open the lightbox (replace with the correct method if using another plugin)
        } else {
            console.error('Featherlight plugin is not loaded or available.');
        }
    });
});

Please share share a solution for this? I am ok to use any free Carousel unless it supports Image view in full screen on click. Thanks!

Date.intlFormat hindi date does not show date in hindi which is 15 days and leter change the part of day

using Intl.dateTimeFormat() for indian month name and date

const fullHindi = {
    weekday: 'long',
    dayPeriod: 'long',
    year: 'numeric',
    month: 'short',
    day: 'numeric',
    dayPeriod: "narrow",
    hour: '2-digit',
    minute: '2-digit',
    second: 'numeric',
    calendar: 'indian',
    timeZone: 'Asia/Kolkata',
    numberingSystem: 'deva',
    formatMatcher: 'basic',
    hourCycle: 'h24',
};
const samay = new Intl.DateTimeFormat("hi", fullHindi);
const today = new Date();
const hindi = samay.format(today);
console.log({hindi}); // शक मंगलवार, २२ श्रावण १९४६, २३:४४:०८

but its not correct though its Shuka/Saptami शुक्ल सप्तमी i.e. in india date are till 15 and then it changes to diffrent paksha ( either Shukla/Krishna ) see more details here

so my ask is is there any format option configuration is there which change this; just like h12 and h24 format

React Form Not Submitting on onSubmit, But Works with onClick

I am trying to submit a login form in my React application. I have attached the loginUser function to the form’s onSubmit event. However, when I press the login button, nothing happens, and no errors are shown in the console.

Interestingly, if I move the loginUser function to the button’s onClick event, it works as expected. I want the form to be submitted via the form’s onSubmit event, not the button’s onClick event. What could be causing this issue?

const toggleButton = () => {
    console.log("Clicking toggle button");
    setIsLogin((prev) => !prev);
};

const loginUser = (e) => {
    console.log("I am Login Now...!");
    e.preventDefault();
};

<form
    style={{
        width: "100%",
        marginTop: "10px",
        marginBottom: "10px",
    }}
    onSubmit={loginUser}
>
    <TextField
        required
        fullWidth
        label="UsernameOrEmail"
        margin="normal"
        variant="outlined"
    />
    <PasswordInput />

    <Button
        fullWidth
        variant="contained"
        color="info"
        type="submit"
        sx={{
            marginTop: "10px",
            marginBottom: "10px",
            fontSize: "1.2rem",
            textTransform: "capitalize",
            fontWeight: "600",
            letterSpacing: "0.05rem",
            padding: "0.5rem 1rem",
        }}
    >
        Login
    </Button>

    <Typography
        textAlign={"center"}
        margin={"1rem"}
        fontWeight={"600"}
    >
        OR
    </Typography>

    <Button color="primary" fullWidth onClick={toggleButton}>
        Register Instead
    </Button>
</form>