<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: San</title>
    <description>The latest articles on Forem by San (@imsan).</description>
    <link>https://forem.com/imsan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1007627%2F9269257a-b617-44c8-a592-f6d78f806ad8.png</url>
      <title>Forem: San</title>
      <link>https://forem.com/imsan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/imsan"/>
    <language>en</language>
    <item>
      <title>Run the script in the background using npm forever cmd</title>
      <dc:creator>San</dc:creator>
      <pubDate>Fri, 22 Dec 2023 11:24:42 +0000</pubDate>
      <link>https://forem.com/imsan/run-the-script-in-the-background-using-npm-forever-cmd-14di</link>
      <guid>https://forem.com/imsan/run-the-script-in-the-background-using-npm-forever-cmd-14di</guid>
      <description>&lt;h2&gt;
  
  
  Installing forever
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -g forever
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running a script with forever
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;forever start app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  After you start the script, you can list all the running processes.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;forever list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdlsxest7zn084n9xcsu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdlsxest7zn084n9xcsu.png" alt="forever" width="730" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Some other useful forever commands:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;forever start: starts a script as a daemon
forever stop: stops the daemon script by Id|Uid|Pid|Index|Script
forever stopall: stops all running scripts
forever restart: restarts the daemon script
forever restartall: restarts all running forever scripts
forever cleanlogs: deletes all historical forever log files
forever config: lists all forever user configurations
forever set : defines a forever config value for an unique key
forever clear : clears the specified forever config by its key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Run your customize script
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Navigate your file:eg /var/www/frontend &lt;/li&gt;
&lt;li&gt;Where package.json is available
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;forever start -c "npm run dev" ./

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Utility CMD for linux</title>
      <dc:creator>San</dc:creator>
      <pubDate>Fri, 15 Dec 2023 10:30:04 +0000</pubDate>
      <link>https://forem.com/imsan/utility-cmd-for-linux-5dpg</link>
      <guid>https://forem.com/imsan/utility-cmd-for-linux-5dpg</guid>
      <description>&lt;h2&gt;
  
  
  Display a list of ports in use:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo lsof -nP -iTCP -sTCP:LISTEN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Check a specific port number with this syntax:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo lsof -nP -i:[port-number]
For example, to check if port 5054 is in use, type:
sudo lsof -nP -i:5054
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Check Ports via netstat Command
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo netstat -tunpl

-t - Queries the command for TCP ports.
-u - Queries for UDP ports.
-n - Avoids DNS lookup and shows only IP addresses to speed up the process.
-p - Displays the process ID and the name of the program using the port.
-l - Outputs listening ports.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Give Permission
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root@ip-192-168-4-59:/var/www# chmod -R 777 www

root@ip-192-168-4-59:/var/www# chown -R 777 www


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  For example, to copy a folder named source_folder to a destination directory named destination_folder, you can use the following command:
&lt;/h2&gt;

&lt;p&gt;cp -r source_folder /path/to/destination_folder/&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp -r source_folder /path/to/destination_folder/
cp -r ./var/www/pharmacy_/v18/pharmacy /var/www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify the Copied Folder
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls /path/to/destination_folder/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to give permission to any folder/file Linux ubuntu</title>
      <dc:creator>San</dc:creator>
      <pubDate>Thu, 14 Dec 2023 17:16:45 +0000</pubDate>
      <link>https://forem.com/imsan/how-to-give-permission-to-any-folderfile-linux-ubuntu-19gf</link>
      <guid>https://forem.com/imsan/how-to-give-permission-to-any-folderfile-linux-ubuntu-19gf</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Go to a terminal and type:

sudo mkdir /var/myfolder
sudo chmod a+rwx /var/myfolder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explain:&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Where *&lt;/em&gt; **myfolder **is the name of the directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;a means "all" (users) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;means "add the following rights" &lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;and rwx means &lt;strong&gt;read&lt;/strong&gt;, &lt;strong&gt;write **and **execute&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create Directory with mkdir:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
sudo mkdir /var/DirectoryName
To give all permissions to a folder give chmod -R 777:

sudo chmod -R 777 /var/DirectoryName

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
    </item>
    <item>
      <title>You can upload any zip file to your server using any FTP or SFTP and need to install unzip.</title>
      <dc:creator>San</dc:creator>
      <pubDate>Thu, 14 Dec 2023 09:28:34 +0000</pubDate>
      <link>https://forem.com/imsan/you-can-upload-any-zip-file-to-your-server-using-any-ftp-or-sftpand-need-to-install-unzip-26l2</link>
      <guid>https://forem.com/imsan/you-can-upload-any-zip-file-to-your-server-using-any-ftp-or-sftpand-need-to-install-unzip-26l2</guid>
      <description>&lt;p&gt;You can upload any zip file to your server using any FTP or SFTP&lt;br&gt;
and need to install unzip.&lt;/p&gt;

&lt;p&gt;You need to install the unzip package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install unzip

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may request an admin password and need to grant the Ubuntu package manager, called apt, to occupy additional disk space with programs. Enter the password and answer 'yes' when needed. After all the packets have been installed, type in a terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;unzip archive.zip 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to extract the zip file to another folder, you will need to use the &lt;strong&gt;-d&lt;/strong&gt; key followed by the directory path. Type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;unzip file.zip -d destination_folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;unzip mysite.zip -d /var/www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will extract the contents of the archive mysite.zip to the folder /var/&lt;a href="http://www"&gt;www&lt;/a&gt;. The directory path can be full or relative.&lt;/p&gt;

&lt;p&gt;Here:&lt;br&gt;
After coming to the directory where your zip file is uploaded path.&lt;br&gt;
In: &lt;strong&gt;/var/www/project "Folder"&lt;/strong&gt; code.zip is present &lt;br&gt;
Then run cmd:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**/var/www/project#**:- unzip code.zip -d /var/www/project                                                                                           
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Make zip file
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;npm install zip -g
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zip -r newtest.zip /var/www/forntend/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>devops</category>
      <category>cloudcomputing</category>
    </item>
    <item>
      <title>router next js</title>
      <dc:creator>San</dc:creator>
      <pubDate>Thu, 14 Dec 2023 09:25:27 +0000</pubDate>
      <link>https://forem.com/imsan/router-next-js-1eja</link>
      <guid>https://forem.com/imsan/router-next-js-1eja</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ArrowUpRight } from "lucide-react";
import React from "react";

import { getOrderByIdAPI } from "@/utils";
import MyOrderCard from "./components/MyOrderCard";

export default async function MyOrderPage() {
  const uid = "6525c166fb721037a5de1164";
  const { data } = await getOrderByIdAPI(uid);
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="py-14 px-4 md:px-6 2xl:px-20 2xl:container 2xl:mx-auto"&amp;gt;
        {data?.map((myOrder: any) =&amp;gt; (
          &amp;lt;MyOrderCard key={myOrder?._id} myOrder={myOrder} /&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";
import { ArrowUpRight } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import React from "react";

export interface MyOrdersPropsI {
  _id: string;
  uid: string;
  pid: string;
  qty: number;
  status: string;
  orderDate: string;
  shiftedDate: string;
  deliveredDate: string;
  paymentType: string;
  paymentStatus: boolean;
  address: string;
  name: string;
  mobile: string;
  __v: number;
  createdAt: Date;
  updatedAt: Date;
}

type MyOrdersPropsT = {
  myOrder: MyOrdersPropsI;
};

const MyOrderCard = ({ myOrder }: MyOrdersPropsT) =&amp;gt; {
  // console.log("myOrders=&amp;gt;", myOrder);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;Link href="/user/orders"&amp;gt;
        &amp;lt;div className="flex max-w-2xl flex-col mb-2  items-center rounded-md border md:flex-row"&amp;gt;
          {/* &amp;lt;div className="h-full w-full md:h-[200px] md:w-[300px]"&amp;gt;
          &amp;lt;Image
            width={100}
            height={100}
            src="https://images.unsplash.com/photo-1522199755839-a2bacb67c546?ixlib=rb-4.0.3&amp;amp;ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTF8fGJsb2d8ZW58MHx8MHx8&amp;amp;auto=format&amp;amp;fit=crop&amp;amp;w=800&amp;amp;q=60"
            alt="Laptop"
            className="h-full w-full rounded-md object-cover"
          /&amp;gt;
        &amp;lt;/div&amp;gt; */}
          &amp;lt;div&amp;gt;
            &amp;lt;div className="p-4"&amp;gt;
              &amp;lt;h1 className="inline-flex items-center text-lg font-semibold"&amp;gt;
                Order id: {myOrder?.orderDate}{" "}
                &amp;lt;ArrowUpRight color="blue" className="ml-2 h-4 w-4" /&amp;gt;
              &amp;lt;/h1&amp;gt;
              &amp;lt;p className="mt-3 text-sm text-gray-600"&amp;gt;
                Order date: {myOrder.orderDate}
              &amp;lt;/p&amp;gt;
              &amp;lt;div className="mt-4"&amp;gt;
                &amp;lt;span className="mb-2 mr-2 inline-block rounded-full bg-gray-100 px-3 py-1 text-[12px] font-semibold text-gray-900"&amp;gt;
                  Payment Type: {myOrder.paymentType}
                &amp;lt;/span&amp;gt;
                &amp;lt;span className="mb-2 mr-2 inline-block rounded-full bg-green-100 px-3 py-1 text-[12px] font-semibold text-gray-900"&amp;gt;
                  Payment Status: {myOrder.paymentStatus &amp;amp;&amp;amp; "Success"}
                &amp;lt;/span&amp;gt;
              &amp;lt;/div&amp;gt;
              &amp;lt;div className="mt-3 flex items-center space-x-2"&amp;gt;
                {/* &amp;lt;img
                className="inline-block h-8 w-8 rounded-full"
                src="https://overreacted.io/static/profile-pic-c715447ce38098828758e525a1128b87.jpg"
                alt="Dan_Abromov"
              /&amp;gt; */}
                &amp;lt;span className="flex flex-col"&amp;gt;
                  &amp;lt;span className="text-[12px] font-medium text-gray-900"&amp;gt;
                    Order Status
                  &amp;lt;/span&amp;gt;
                  &amp;lt;span className="bg-green-200 rounded-full p-[4px] text-center text-[10px] font-extrabold text-gray-800"&amp;gt;
                    {myOrder?.status}
                  &amp;lt;/span&amp;gt;
                &amp;lt;/span&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/Link&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default MyOrderCard;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
    </item>
    <item>
      <title>How to pass data in server-side component to client-side</title>
      <dc:creator>San</dc:creator>
      <pubDate>Tue, 07 Nov 2023 17:40:02 +0000</pubDate>
      <link>https://forem.com/imsan/how-to-pass-data-in-server-side-component-to-client-side-4pjh</link>
      <guid>https://forem.com/imsan/how-to-pass-data-in-server-side-component-to-client-side-4pjh</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";
import React from "react";
import DeliveryInfoCard from "./delivery-info";

const MyOrders = ({ myorder }: any) =&amp;gt; {
  console.log("component=&amp;gt;", myorder);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="py-14 px-4 md:px-6 2xl:px-20 2xl:container 2xl:mx-auto"&amp;gt;
        &amp;lt;div className="flex justify-start item-start space-y-2 flex-col"&amp;gt;
          &amp;lt;h1 className="text-3xl dark:text-white lg:text-4xl font-semibold leading-7 lg:leading-9 text-gray-800"&amp;gt;
            Order #13432
          &amp;lt;/h1&amp;gt;
          &amp;lt;p className="text-base dark:text-gray-300 font-medium leading-6 text-gray-600"&amp;gt;
            21st Mart 2021 at 10:34 PM
          &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div className="mt-10 flex flex-col xl:flex-row jusitfy-center items-stretch w-full xl:space-x-8 space-y-4 md:space-y-6 xl:space-y-0"&amp;gt;
          &amp;lt;div className="flex flex-col justify-start items-start w-full space-y-4 md:space-y-6 xl:space-y-8"&amp;gt;
            &amp;lt;div className="flex flex-col justify-start items-start dark:bg-gray-800 bg-gray-50 px-4 py-4 md:py-6 md:p-6 xl:p-8 w-full"&amp;gt;
              &amp;lt;p className="text-lg md:text-xl dark:text-white font-semibold leading-6 xl:leading-5 text-gray-800"&amp;gt;
                My Orders
              &amp;lt;/p&amp;gt;
              &amp;lt;div className="mt-4 md:mt-6 flex flex-col md:flex-row justify-start items-start md:items-center md:space-x-6 xl:space-x-8 w-full"&amp;gt;
                &amp;lt;div className="pb-4 md:pb-8 w-full md:w-40"&amp;gt;
                  &amp;lt;img
                    className="w-full hidden md:block"
                    src="/images/sanv.jpg"
                    alt="dress"
                  /&amp;gt;
                  &amp;lt;img
                    className="w-full md:hidden"
                    src="/images/sanv.jpg"
                    alt="dress"
                  /&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div className="border-b border-gray-200 md:flex-row flex-col flex justify-between items-start w-full pb-8 space-y-4 md:space-y-0"&amp;gt;
                  &amp;lt;div className="w-full flex flex-col justify-start items-start space-y-8"&amp;gt;
                    &amp;lt;h3 className="text-xl dark:text-white xl:text-2xl font-semibold leading-6 text-gray-800"&amp;gt;
                      Premium Quaility Dress
                    &amp;lt;/h3&amp;gt;
                    &amp;lt;div className="flex justify-start items-start flex-col space-y-2"&amp;gt;
                      &amp;lt;p className="text-sm dark:text-white leading-none text-gray-800"&amp;gt;
                        &amp;lt;span className="dark:text-gray-400 text-gray-300"&amp;gt;
                          Style:{" "}
                        &amp;lt;/span&amp;gt;{" "}
                        Italic Minimal Design
                      &amp;lt;/p&amp;gt;
                      &amp;lt;p className="text-sm dark:text-white leading-none text-gray-800"&amp;gt;
                        &amp;lt;span className="dark:text-gray-400 text-gray-300"&amp;gt;
                          Size:{" "}
                        &amp;lt;/span&amp;gt;{" "}
                        Small
                      &amp;lt;/p&amp;gt;
                      &amp;lt;p className="text-sm dark:text-white leading-none text-gray-800"&amp;gt;
                        &amp;lt;span className="dark:text-gray-400 text-gray-300"&amp;gt;
                          Color:{" "}
                        &amp;lt;/span&amp;gt;{" "}
                        Light Blue
                      &amp;lt;/p&amp;gt;
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/div&amp;gt;
                  &amp;lt;div className="flex justify-between space-x-8 items-start w-full"&amp;gt;
                    &amp;lt;p className="text-base dark:text-white xl:text-lg leading-6"&amp;gt;
                      $36.00{" "}
                      &amp;lt;span className="text-red-300 line-through"&amp;gt; $45.00&amp;lt;/span&amp;gt;
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="text-base dark:text-white xl:text-lg leading-6 text-gray-800"&amp;gt;
                      01
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="text-base dark:text-white xl:text-lg font-semibold leading-6 text-gray-800"&amp;gt;
                      $36.00
                    &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
              &amp;lt;div className="mt-6 md:mt-0 flex justify-start flex-col md:flex-row items-start md:items-center space-y-4 md:space-x-6 xl:space-x-8 w-full"&amp;gt;
                &amp;lt;div className="w-full md:w-40"&amp;gt;
                  &amp;lt;img
                    className="w-full hidden md:block"
                    src="/images/1.jpg"
                    width={100}
                    height={100}
                    alt="dress"
                  /&amp;gt;
                  &amp;lt;img
                    className="w-full md:hidden"
                    src="/images/1.jpg"
                    alt="dress"
                  /&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div className="flex justify-between items-start w-full flex-col md:flex-row space-y-4 md:space-y-0"&amp;gt;
                  &amp;lt;div className="w-full flex flex-col justify-start items-start space-y-8"&amp;gt;
                    &amp;lt;h3 className="text-xl dark:text-white xl:text-2xl font-semibold leading-6 text-gray-800"&amp;gt;
                      High Quaility Italic Dress
                    &amp;lt;/h3&amp;gt;
                    &amp;lt;div className="flex justify-start items-start flex-col space-y-2"&amp;gt;
                      &amp;lt;p className="text-sm dark:text-white leading-none text-gray-800"&amp;gt;
                        &amp;lt;span className="dark:text-gray-400 text-gray-300"&amp;gt;
                          Style:{" "}
                        &amp;lt;/span&amp;gt;{" "}
                        Italic Minimal Design
                      &amp;lt;/p&amp;gt;
                      &amp;lt;p className="text-sm dark:text-white leading-none text-gray-800"&amp;gt;
                        &amp;lt;span className="dark:text-gray-400 text-gray-300"&amp;gt;
                          Size:{" "}
                        &amp;lt;/span&amp;gt;{" "}
                        Small
                      &amp;lt;/p&amp;gt;
                      &amp;lt;p className="text-sm dark:text-white leading-none text-gray-800"&amp;gt;
                        &amp;lt;span className="dark:text-gray-400 text-gray-300"&amp;gt;
                          Color:{" "}
                        &amp;lt;/span&amp;gt;{" "}
                        Light Blue
                      &amp;lt;/p&amp;gt;
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/div&amp;gt;
                  &amp;lt;div className="flex justify-between space-x-8 items-start w-full"&amp;gt;
                    &amp;lt;p className="text-base dark:text-white xl:text-lg leading-6"&amp;gt;
                      $20.00{" "}
                      &amp;lt;span className="text-red-300 line-through"&amp;gt; $30.00&amp;lt;/span&amp;gt;
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="text-base dark:text-white xl:text-lg leading-6 text-gray-800"&amp;gt;
                      01
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="text-base dark:text-white xl:text-lg font-semibold leading-6 text-gray-800"&amp;gt;
                      $20.00
                    &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div className="flex justify-center flex-col md:flex-row flex-col items-stretch w-full space-y-4 md:space-y-0 md:space-x-6 xl:space-x-8"&amp;gt;
              &amp;lt;div className="flex flex-col px-4 py-6 md:p-6 xl:p-8 w-full bg-gray-50 dark:bg-gray-800 space-y-6"&amp;gt;
                &amp;lt;h3 className="text-xl dark:text-white font-semibold leading-5 text-gray-800"&amp;gt;
                  Summary
                &amp;lt;/h3&amp;gt;
                &amp;lt;div className="flex justify-center items-center w-full space-y-4 flex-col border-gray-200 border-b pb-4"&amp;gt;
                  &amp;lt;div className="flex justify-between w-full"&amp;gt;
                    &amp;lt;p className="text-base dark:text-white leading-4 text-gray-800"&amp;gt;
                      Subtotal
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="text-base dark:text-gray-300 leading-4 text-gray-600"&amp;gt;
                      $56.00
                    &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                  &amp;lt;div className="flex justify-between items-center w-full"&amp;gt;
                    &amp;lt;p className="text-base dark:text-white leading-4 text-gray-800"&amp;gt;
                      Discount{" "}
                      &amp;lt;span className="bg-gray-200 p-1 text-xs font-medium dark:bg-white dark:text-gray-800 leading-3 text-gray-800"&amp;gt;
                        STUDENT
                      &amp;lt;/span&amp;gt;
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="text-base dark:text-gray-300 leading-4 text-gray-600"&amp;gt;
                      -$28.00 (50%)
                    &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                  &amp;lt;div className="flex justify-between items-center w-full"&amp;gt;
                    &amp;lt;p className="text-base dark:text-white leading-4 text-gray-800"&amp;gt;
                      Shipping
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="text-base dark:text-gray-300 leading-4 text-gray-600"&amp;gt;
                      $8.00
                    &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div className="flex justify-between items-center w-full"&amp;gt;
                  &amp;lt;p className="text-base dark:text-white font-semibold leading-4 text-gray-800"&amp;gt;
                    Total
                  &amp;lt;/p&amp;gt;
                  &amp;lt;p className="text-base dark:text-gray-300 font-semibold leading-4 text-gray-600"&amp;gt;
                    $36.00
                  &amp;lt;/p&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
              {/* &amp;lt;div className="flex flex-col justify-center px-4 py-6 md:p-6 xl:p-8 w-full bg-gray-50 dark:bg-gray-800 space-y-6"&amp;gt;
                &amp;lt;h3 className="text-xl dark:text-white font-semibold leading-5 text-gray-800"&amp;gt;
                  Shipping
                &amp;lt;/h3&amp;gt;
                &amp;lt;div className="flex justify-between items-start w-full"&amp;gt;
                  &amp;lt;div className="flex justify-center items-center space-x-4"&amp;gt;
                    &amp;lt;div className="w-8 h-8"&amp;gt;
                      &amp;lt;img
                        className="w-full h-full"
                        alt="logo"
                        src="https://i.ibb.co/L8KSdNQ/image-3.png"
                      /&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div className="flex flex-col justify-start items-center"&amp;gt;
                      &amp;lt;p className="text-lg leading-6 dark:text-white font-semibold text-gray-800"&amp;gt;
                        DPD Delivery
                        &amp;lt;br /&amp;gt;
                        &amp;lt;span className="font-normal"&amp;gt;
                          Delivery with 24 Hours
                        &amp;lt;/span&amp;gt;
                      &amp;lt;/p&amp;gt;
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/div&amp;gt;
                  &amp;lt;p className="text-lg font-semibold leading-6 dark:text-white text-gray-800"&amp;gt;
                    $8.00
                  &amp;lt;/p&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div className="w-full flex justify-center items-center"&amp;gt;
                  &amp;lt;button className="hover:bg-black dark:bg-white dark:text-gray-800 dark:hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-800 py-5 w-96 md:w-full bg-gray-800 text-base font-medium leading-4 text-white"&amp;gt;
                    View Carrier Details
                  &amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt; */}
            &amp;lt;/div&amp;gt;
            &amp;lt;DeliveryInfoCard /&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="bg-gray-50 dark:bg-gray-800 w-full xl:w-96 flex justify-between items-center md:items-start px-4 py-6 md:p-6 xl:p-8 flex-col"&amp;gt;
            &amp;lt;h3 className="text-xl dark:text-white font-semibold leading-5 text-gray-800"&amp;gt;
              Shipping Details
            &amp;lt;/h3&amp;gt;
            &amp;lt;div className="flex flex-col md:flex-row xl:flex-col justify-start items-stretch h-full w-full md:space-x-6 lg:space-x-8 xl:space-x-0"&amp;gt;
              &amp;lt;div className="flex flex-col justify-start items-start flex-shrink-0"&amp;gt;
                &amp;lt;div className="flex justify-center w-full md:justify-start items-center space-x-4 py-8 border-b border-gray-200"&amp;gt;
                  {/* &amp;lt;img
                    src="https://i.ibb.co/5TSg7f6/Rectangle-18.png"
                    alt="avatar"
                  /&amp;gt; */}
                  &amp;lt;div className="flex justify-start items-start flex-col space-y-2"&amp;gt;
                    &amp;lt;p className="text-base dark:text-white font-semibold leading-4 text-left text-gray-800"&amp;gt;
                      David Kent
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="text-sm dark:text-gray-300 leading-5 text-gray-600"&amp;gt;
                      10 Previous Orders
                    &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div className="flex justify-center text-gray-800 dark:text-white md:justify-start items-center space-x-4 py-4 border-b border-gray-200 w-full"&amp;gt;
                  &amp;lt;svg
                    width={24}
                    height={24}
                    viewBox="0 0 24 24"
                    fill="none"
                    xmlns="http://www.w3.org/2000/svg"
                  &amp;gt;
                    &amp;lt;path
                      d="M19 5H5C3.89543 5 3 5.89543 3 7V17C3 18.1046 3.89543 19 5 19H19C20.1046 19 21 18.1046 21 17V7C21 5.89543 20.1046 5 19 5Z"
                      stroke="currentColor"
                      strokeLinecap="round"
                      strokeLinejoin="round"
                    /&amp;gt;
                    &amp;lt;path
                      d="M3 7L12 13L21 7"
                      stroke="currentColor"
                      strokeLinecap="round"
                      strokeLinejoin="round"
                    /&amp;gt;
                  &amp;lt;/svg&amp;gt;
                  &amp;lt;p className="cursor-pointer text-sm leading-5 "&amp;gt;
                    david89@gmail.com
                  &amp;lt;/p&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
              &amp;lt;div className="flex justify-between xl:h-full items-stretch w-full flex-col mt-6 md:mt-0"&amp;gt;
                &amp;lt;div className="flex justify-center md:justify-start xl:flex-col flex-col md:space-x-6 lg:space-x-8 xl:space-x-0 space-y-4 xl:space-y-12 md:space-y-0 md:flex-row items-center md:items-start"&amp;gt;
                  &amp;lt;div className="flex justify-center md:justify-start items-center md:items-start flex-col space-y-4 xl:mt-8"&amp;gt;
                    &amp;lt;p className="text-base dark:text-white font-semibold leading-4 text-center md:text-left text-gray-800"&amp;gt;
                      Shipping Address
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="w-48 lg:w-full dark:text-gray-300 xl:w-48 text-center md:text-left text-sm leading-5 text-gray-600"&amp;gt;
                      180 North King Street, Northhampton MA 1060
                    &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                  &amp;lt;div className="flex justify-center md:justify-start items-center md:items-start flex-col space-y-4"&amp;gt;
                    &amp;lt;p className="text-base dark:text-white font-semibold leading-4 text-center md:text-left text-gray-800"&amp;gt;
                      Billing Address
                    &amp;lt;/p&amp;gt;
                    &amp;lt;p className="w-48 lg:w-full dark:text-gray-300 xl:w-48 text-center md:text-left text-sm leading-5 text-gray-600"&amp;gt;
                      180 North King Street, Northhampton MA 1060
                    &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
                {/* &amp;lt;div className="flex w-full justify-center items-center md:justify-start md:items-start"&amp;gt;
                  &amp;lt;button className="mt-6 md:mt-0 dark:border-white dark:hover:bg-gray-900 dark:bg-transparent dark:text-white py-5 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-800 border border-gray-800 font-medium w-96 2xl:w-full text-base font-medium leading-4 text-gray-800"&amp;gt;
                    Edit Details
                  &amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt; */}
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default MyOrders;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dinfo
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";

const DeliveryInfoCard = () =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;ol className="flex items-center w-full"&amp;gt;
        &amp;lt;li className="flex w-full items-center text-blue-600 dark:text-blue-500 after:content-[''] after:w-full after:h-1 after:border-b after:border-blue-100 after:border-4 after:inline-block dark:after:border-blue-800"&amp;gt;
          &amp;lt;span className="flex items-center justify-center w-10 h-10 bg-blue-100 rounded-full lg:h-12 lg:w-12 dark:bg-blue-800 shrink-0"&amp;gt;
            &amp;lt;svg
              className="w-3.5 h-3.5 text-blue-600 lg:w-4 lg:h-4 dark:text-blue-300"
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              fill="none"
              viewBox="0 0 16 12"
            &amp;gt;
              &amp;lt;path
                stroke="currentColor"
                strokeLinecap="round"
                strokeLinejoin="round"
                strokeWidth={2}
                d="M1 5.917 5.724 10.5 15 1.5"
              /&amp;gt;
            &amp;lt;/svg&amp;gt;
          &amp;lt;/span&amp;gt;
        &amp;lt;/li&amp;gt;
        &amp;lt;li className="flex w-full items-center after:content-[''] after:w-full after:h-1 after:border-b after:border-gray-100 after:border-4 after:inline-block dark:after:border-gray-700"&amp;gt;
          &amp;lt;span className="flex items-center justify-center w-10 h-10 bg-gray-100 rounded-full lg:h-12 lg:w-12 dark:bg-gray-700 shrink-0"&amp;gt;
            &amp;lt;svg
              className="w-4 h-4 text-gray-500 lg:w-5 lg:h-5 dark:text-gray-100"
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              fill="currentColor"
              viewBox="0 0 20 16"
            &amp;gt;
              &amp;lt;path d="M18 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2ZM6.5 3a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM3.014 13.021l.157-.625A3.427 3.427 0 0 1 6.5 9.571a3.426 3.426 0 0 1 3.322 2.805l.159.622-6.967.023ZM16 12h-3a1 1 0 0 1 0-2h3a1 1 0 0 1 0 2Zm0-3h-3a1 1 0 1 1 0-2h3a1 1 0 1 1 0 2Zm0-3h-3a1 1 0 1 1 0-2h3a1 1 0 1 1 0 2Z" /&amp;gt;
            &amp;lt;/svg&amp;gt;
          &amp;lt;/span&amp;gt;
        &amp;lt;/li&amp;gt;
        &amp;lt;li className="flex items-center w-full"&amp;gt;
          &amp;lt;span className="flex items-center justify-center w-10 h-10 bg-gray-100 rounded-full lg:h-12 lg:w-12 dark:bg-gray-700 shrink-0"&amp;gt;
            &amp;lt;svg
              className="w-4 h-4 text-gray-500 lg:w-5 lg:h-5 dark:text-gray-100"
              aria-hidden="true"
              xmlns="http://www.w3.org/2000/svg"
              fill="currentColor"
              viewBox="0 0 18 20"
            &amp;gt;
              &amp;lt;path d="M16 1h-3.278A1.992 1.992 0 0 0 11 0H7a1.993 1.993 0 0 0-1.722 1H2a2 2 0 0 0-2 2v15a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2ZM7 2h4v3H7V2Zm5.7 8.289-3.975 3.857a1 1 0 0 1-1.393 0L5.3 12.182a1.002 1.002 0 1 1 1.4-1.436l1.328 1.289 3.28-3.181a1 1 0 1 1 1.392 1.435Z" /&amp;gt;
            &amp;lt;/svg&amp;gt;
          &amp;lt;/span&amp;gt;
        &amp;lt;/li&amp;gt;
      &amp;lt;/ol&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default DeliveryInfoCard;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Server component
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import MyOrders from "@/components/myorder";
import { getOrderByIdAPI } from "@/utils";

export default async function MyOrdersPage() {
  const uid = "6525c166fb721037a5de1164";
  const { data } = await getOrderByIdAPI(uid);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;MyOrders myorder={data} /&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  API Call
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function getOrderByIdAPI(uid: string) {
  try {
    const res = await axios.get(`${apiUrl}/order/${uid}`);
    const data = await res.data;
    console.log('api data=&amp;gt;', data);
    return data

  } catch (err) {
    console.log('err=&amp;gt;', err);

  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>URL Params value change on select using next js 13</title>
      <dc:creator>San</dc:creator>
      <pubDate>Mon, 06 Nov 2023 18:36:59 +0000</pubDate>
      <link>https://forem.com/imsan/url-params-value-change-on-select-using-next-js-13-h22</link>
      <guid>https://forem.com/imsan/url-params-value-change-on-select-using-next-js-13-h22</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";
import { searchFilterProductAPI } from "@/utils";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import React, { useEffect, useState } from "react";

// const checkList = ["Apple", "Banana", "Tea", "Coffee"];
const checkList = ["All", "Michael Kors", "Tommy Hilfiger", "Emporio Armani"];

interface MyFilterProps {
  brands: any;
}

const MyFilter = ({ brands }: MyFilterProps) =&amp;gt; {
  const searchParams = useSearchParams();
  const pathname = usePathname();
  const router = useRouter();
  const [checkedItems, setCheckedItems] = useState&amp;lt;any&amp;gt;([]);
  const [catsItems, setCatsItems] = useState&amp;lt;any&amp;gt;([]);
  const [selectedPrice, setSelectedPrice] = useState("");
  const [searchTerm, setSearchTerm] = useState&amp;lt;any&amp;gt;("watch");

  function handleBrandChage(e: any) {
    const { value, checked } = e.target;
    let isSelected = checked;
    if (isSelected) {
      setCheckedItems([...checkedItems, value]);
    } else {
      setCheckedItems((preItems: any) =&amp;gt; {
        return preItems?.filter((val: any) =&amp;gt; {
          return val !== value;
        });
      });
    }
  }

  function handleCatsChage(e: any) {
    const { value, checked } = e.target;
    const selectedVal = value;
    let isSelected = checked;
    if (isSelected) {
      setCatsItems([...catsItems, selectedVal]);
    } else {
      setCatsItems((preItems: any) =&amp;gt; {
        return preItems?.filter((val: any) =&amp;gt; {
          return val !== selectedVal;
        });
      });
    }
  }

  // handle price select
  const handlePriceSelect = (e: any) =&amp;gt; {
    const { value } = e.target;
    setSelectedPrice(value);
  };

  const params = new URLSearchParams(searchParams);
  // const searchTerm = "watch";
  useEffect(() =&amp;gt; {
    if (searchTerm) {
      params.set("q", searchTerm);
    } else {
      params.delete("q");
    }
    if (!checkedItems || !catsItems) {
      params.set("", "");
      return;
    }
    if (checkedItems) {
      params.set("brand", checkedItems);
      router.push(`${pathname}?${params}`);
    } else {
      params.delete("brand", "");
    }
  }, [checkedItems]);

  console.log("checkedItems=&amp;gt;", { checkedItems, catsItems });

  useEffect(() =&amp;gt; {
    if (catsItems) {
      params.set("category", catsItems);
      router.push(`${pathname}?${params}`);
    } else {
      params.delete("category", "");
    }
    if (selectedPrice) {
      params.set("price", selectedPrice);
      router.push(`${pathname}?${params}`);
    } else {
      params.delete("price", "");
    }
  }, [catsItems, selectedPrice]);

  // useEffect(() =&amp;gt; {
  //   if (selectedPrice) {
  //     params.set("price", selectedPrice);
  //     router.push(`${pathname}?${params}`);
  //   } else {
  //     params.delete("price", "");
  //   }
  // }, [selectedPrice]);

  // API call for search and filter
  const category = catsItems.toString();
  const brand = checkedItems.toString();
  useEffect(() =&amp;gt; {
    const q: any = "watch";
    const searchFilterProduct = async () =&amp;gt; {
      await searchFilterProductAPI(searchTerm, category, brand, selectedPrice);
    };
    if (searchTerm) {
      searchFilterProduct();
    }
  }, [searchTerm, checkedItems, catsItems, selectedPrice]);

  const clearAllFilter = async () =&amp;gt; {
    // setSearchTerm("");
    setSelectedPrice("");
    setCheckedItems("");
    setCatsItems("");
    await searchFilterProductAPI(searchTerm, category, brand, selectedPrice);
    router.push(`${pathname}?q=${searchTerm}`);
    router.refresh();
  };

  // console.log("selectedPrice==&amp;gt;", selectedPrice);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;button onClick={clearAllFilter}&amp;gt;Clear Filter&amp;lt;/button&amp;gt;
      &amp;lt;h1&amp;gt;Brand Filter&amp;lt;/h1&amp;gt;
      {checkList &amp;amp;&amp;amp;
        checkList?.map((b: any, i: number) =&amp;gt; (
          &amp;lt;&amp;gt;
            &amp;lt;input
              key={b}
              type="checkbox"
              checked={checkedItems?.includes(b)}
              value={b}
              onChange={handleBrandChage}
              name="brand-checkbox"
            /&amp;gt;
            &amp;lt;label&amp;gt; {b}&amp;lt;/label&amp;gt;
            &amp;lt;br /&amp;gt;
          &amp;lt;/&amp;gt;
        ))}
      &amp;lt;div className="result"&amp;gt;
        Above checkbox is {checkedItems &amp;amp;&amp;amp; checkedItems.join(", ")}.
      &amp;lt;/div&amp;gt;

      &amp;lt;h1&amp;gt;category Filter&amp;lt;/h1&amp;gt;
      {brands &amp;amp;&amp;amp;
        brands?.map((b: any) =&amp;gt; (
          &amp;lt;&amp;gt;
            &amp;lt;input
              key={b.id}
              type="checkbox"
              checked={catsItems?.includes(b.brand)}
              value={b.brand}
              onChange={handleCatsChage}
              name="brand-checkbox"
            /&amp;gt;
            &amp;lt;label&amp;gt; {b.brand}&amp;lt;/label&amp;gt;
            &amp;lt;br /&amp;gt;
          &amp;lt;/&amp;gt;
        ))}
      &amp;lt;div className="result"&amp;gt;
        Above checkbox is {catsItems &amp;amp;&amp;amp; catsItems.join(", ")}.
      &amp;lt;/div&amp;gt;

      {/* Price set */}
      &amp;lt;label
        htmlFor="price"
        className="block mb-2 text-sm font-medium text-gray-900 dark:text-white"
      &amp;gt;
        Select price range
      &amp;lt;/label&amp;gt;
      &amp;lt;select
        defaultValue="nan"
        className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
        onChange={handlePriceSelect}
      &amp;gt;
        &amp;lt;option defaultValue={selectedPrice}&amp;gt;
          {selectedPrice === "" &amp;amp;&amp;amp; "Choose a country"}
        &amp;lt;/option&amp;gt;
        &amp;lt;option value="500"&amp;gt;Above 500&amp;lt;/option&amp;gt;
        &amp;lt;option value="2000"&amp;gt;Above 2000&amp;lt;/option&amp;gt;
        &amp;lt;option value="5000"&amp;gt;Above 5000&amp;lt;/option&amp;gt;
        &amp;lt;option value="10000"&amp;gt;Above 10000&amp;lt;/option&amp;gt;
        &amp;lt;option value="20000"&amp;gt;Above 20000&amp;lt;/option&amp;gt;
        &amp;lt;option value="30000"&amp;gt;Above 30000&amp;lt;/option&amp;gt;
        &amp;lt;option value="40000"&amp;gt;Above 40000&amp;lt;/option&amp;gt;
        &amp;lt;option value="50000"&amp;gt;Above 50000&amp;lt;/option&amp;gt;
      &amp;lt;/select&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default MyFilter;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. server-side search and filter
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function searchFilterProductAPI(q: string, category: string, brand: string, price: string) {
  console.log('searchFilterProductAPI', { q, category, brand, price });
  // http://103.174.102.250:3000/api/filter?q=watch&amp;amp;category=Women's Watch&amp;amp;brand=Tommy Hilfiger&amp;amp;price
  try {
    const res = await axios.get(`${apiUrl}/filter?q=${q}&amp;amp;category=${category}&amp;amp;brand=${brand}&amp;amp;price=${price}`);
    const data = await res.data
    console.log('result api=?', data);
    return data;

  } catch (err) {
    console.log('err occured==&amp;gt;', err);
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to use useSearchParams hooks in next js 13</title>
      <dc:creator>San</dc:creator>
      <pubDate>Fri, 03 Nov 2023 18:29:28 +0000</pubDate>
      <link>https://forem.com/imsan/how-to-use-usesearchparams-hooks-in-next-js-13-f7f</link>
      <guid>https://forem.com/imsan/how-to-use-usesearchparams-hooks-in-next-js-13-f7f</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import React, { useEffect, useState } from "react";

const checkList = ["Apple", "Banana", "Tea", "Coffee"];

interface MyFilterProps {
  brands: any;
}
const MyFilter = ({ brands }: MyFilterProps) =&amp;gt; {
  const searchParams = useSearchParams();
  const pathname = usePathname();
  const router = useRouter();
  const [checkedItems, setCheckedItems] = useState&amp;lt;any&amp;gt;([]);
  const [catsItems, setCatsItems] = useState&amp;lt;any&amp;gt;([]);

  function handleBrandChage(e: any) {
    const { value, checked } = e.target;
    let isSelected = checked;
    if (isSelected) {
      setCheckedItems([...checkedItems, value]);
    } else {
      setCheckedItems((preItems: any) =&amp;gt; {
        return preItems?.filter((val: any) =&amp;gt; {
          return val !== value;
        });
      });
    }
  }

  function handleCatsChage(e: any) {
    const { value, checked } = e.target;
    const val = parseInt(value);

    let isSelected = checked;
    if (isSelected) {
      setCatsItems([...catsItems, val]);
    } else {
      setCatsItems((preItems: any) =&amp;gt; {
        return preItems?.filter((val: any) =&amp;gt; {
          return val !== val;
        });
      });
    }
  }

  const params = new URLSearchParams(searchParams);
  useEffect(() =&amp;gt; {
    if (!checkedItems || !catsItems) {
      params.set("", "");
      return;
    }
    if (checkedItems) {
      params.set("brand", checkedItems);
      router.push(`${pathname}?${params}`);
    } else {
      params.delete("brand", "");
    }
  }, [checkedItems]);

  console.log("checkedItems=&amp;gt;", { checkedItems, catsItems });

  useEffect(() =&amp;gt; {
    if (catsItems) {
      params.set("cats", catsItems);
      router.push(`${pathname}?${params}`);
    } else {
      params.delete("cats", "");
    }
  }, [catsItems]);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;h1&amp;gt;Brand Filter&amp;lt;/h1&amp;gt;
      {checkList &amp;amp;&amp;amp;
        checkList?.map((b: any, i: number) =&amp;gt; (
          &amp;lt;&amp;gt;
            &amp;lt;input
              key={b}
              type="checkbox"
              checked={checkedItems?.includes(b)}
              value={b}
              onChange={handleBrandChage}
              name="brand-checkbox"
            /&amp;gt;
            &amp;lt;label&amp;gt;{b}&amp;lt;/label&amp;gt;
            &amp;lt;br /&amp;gt;
          &amp;lt;/&amp;gt;
        ))}
      &amp;lt;div className="result"&amp;gt;
        Above checkbox is {checkedItems &amp;amp;&amp;amp; checkedItems.join(", ")}.
      &amp;lt;/div&amp;gt;

      &amp;lt;h1&amp;gt;Cats Filter&amp;lt;/h1&amp;gt;
      {brands &amp;amp;&amp;amp;
        brands?.map((b: any) =&amp;gt; (
          &amp;lt;&amp;gt;
            &amp;lt;input
              key={b.id}
              type="checkbox"
              checked={catsItems?.includes(b.id)}
              value={b.id}
              onChange={handleCatsChage}
              name="brand-checkbox"
            /&amp;gt;
            &amp;lt;label&amp;gt;:::::{b.brand}&amp;lt;/label&amp;gt;
            &amp;lt;br /&amp;gt;
          &amp;lt;/&amp;gt;
        ))}
      &amp;lt;div className="result"&amp;gt;
        Above checkbox is {catsItems &amp;amp;&amp;amp; catsItems.join(", ")}.
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default MyFilter;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>nextjs</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>You can convert the string field to int and then compare. If the db value is in sting</title>
      <dc:creator>San</dc:creator>
      <pubDate>Thu, 02 Nov 2023 21:45:40 +0000</pubDate>
      <link>https://forem.com/imsan/you-can-convert-the-string-field-to-int-and-then-compare-if-the-db-value-is-in-sting-59ec</link>
      <guid>https://forem.com/imsan/you-can-convert-the-string-field-to-int-and-then-compare-if-the-db-value-is-in-sting-59ec</guid>
      <description>&lt;p&gt;You can convert the string field to int and then compare.&lt;/p&gt;

&lt;p&gt;If aggregation add a match stage&lt;/p&gt;

&lt;p&gt;{"$match" : {"$expr" : {"$gt" : [{"$toInt" :"$diskSizeGb"} , 200]}}}&lt;br&gt;
If find&lt;/p&gt;

&lt;p&gt;find({"$expr" : {"$gt" : [{"$toInt" :"$diskSizeGb"} , 200]}})&lt;br&gt;
*$expr allows us to use aggregate operators to query&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Zoom image on hover</title>
      <dc:creator>San</dc:creator>
      <pubDate>Wed, 01 Nov 2023 12:00:43 +0000</pubDate>
      <link>https://forem.com/imsan/zoom-image-on-hover-i9d</link>
      <guid>https://forem.com/imsan/zoom-image-on-hover-i9d</guid>
      <description>&lt;p&gt;&lt;a href="https://codesandbox.io/s/wizardly-grass-2cv76m?file=/src/MyReactImageMagnify.js"&gt;https://codesandbox.io/s/wizardly-grass-2cv76m?file=/src/MyReactImageMagnify.js&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ArrowUpRight } from "lucide-react";
import React from "react";

import { getOrderByIdAPI } from "@/utils";
import MyOrderCard from "./components/MyOrderCard";

export default async function MyOrderPage() {
  const uid = "6525c166fb721037a5de1164";
  const { data } = await getOrderByIdAPI(uid);
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="py-14 px-4 md:px-6 2xl:px-20 2xl:container 2xl:mx-auto"&amp;gt;
        {data?.map((myOrder: any) =&amp;gt; (
          &amp;lt;MyOrderCard key={myOrder?._id} myOrder={myOrder} /&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";
import { ArrowUpRight } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import React from "react";

export interface MyOrdersPropsI {
  _id: string;
  uid: string;
  pid: string;
  qty: number;
  status: string;
  orderDate: string;
  shiftedDate: string;
  deliveredDate: string;
  paymentType: string;
  paymentStatus: boolean;
  address: string;
  name: string;
  mobile: string;
  __v: number;
  createdAt: Date;
  updatedAt: Date;
}

type MyOrdersPropsT = {
  myOrder: MyOrdersPropsI;
};

const MyOrderCard = ({ myOrder }: MyOrdersPropsT) =&amp;gt; {
  // console.log("myOrders=&amp;gt;", myOrder);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;Link href="/user/orders"&amp;gt;
        &amp;lt;div className="flex max-w-2xl flex-col mb-2  items-center rounded-md border md:flex-row"&amp;gt;
          {/* &amp;lt;div className="h-full w-full md:h-[200px] md:w-[300px]"&amp;gt;
          &amp;lt;Image
            width={100}
            height={100}
            src="https://images.unsplash.com/photo-1522199755839-a2bacb67c546?ixlib=rb-4.0.3&amp;amp;ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTF8fGJsb2d8ZW58MHx8MHx8&amp;amp;auto=format&amp;amp;fit=crop&amp;amp;w=800&amp;amp;q=60"
            alt="Laptop"
            className="h-full w-full rounded-md object-cover"
          /&amp;gt;
        &amp;lt;/div&amp;gt; */}
          &amp;lt;div&amp;gt;
            &amp;lt;div className="p-4"&amp;gt;
              &amp;lt;h1 className="inline-flex items-center text-lg font-semibold"&amp;gt;
                Order id: {myOrder?.orderDate}{" "}
                &amp;lt;ArrowUpRight color="blue" className="ml-2 h-4 w-4" /&amp;gt;
              &amp;lt;/h1&amp;gt;
              &amp;lt;p className="mt-3 text-sm text-gray-600"&amp;gt;
                Order date: {myOrder.orderDate}
              &amp;lt;/p&amp;gt;
              &amp;lt;div className="mt-4"&amp;gt;
                &amp;lt;span className="mb-2 mr-2 inline-block rounded-full bg-gray-100 px-3 py-1 text-[12px] font-semibold text-gray-900"&amp;gt;
                  Payment Type: {myOrder.paymentType}
                &amp;lt;/span&amp;gt;
                &amp;lt;span className="mb-2 mr-2 inline-block rounded-full bg-green-100 px-3 py-1 text-[12px] font-semibold text-gray-900"&amp;gt;
                  Payment Status: {myOrder.paymentStatus &amp;amp;&amp;amp; "Success"}
                &amp;lt;/span&amp;gt;
              &amp;lt;/div&amp;gt;
              &amp;lt;div className="mt-3 flex items-center space-x-2"&amp;gt;
                {/* &amp;lt;img
                className="inline-block h-8 w-8 rounded-full"
                src="https://overreacted.io/static/profile-pic-c715447ce38098828758e525a1128b87.jpg"
                alt="Dan_Abromov"
              /&amp;gt; */}
                &amp;lt;span className="flex flex-col"&amp;gt;
                  &amp;lt;span className="text-[12px] font-medium text-gray-900"&amp;gt;
                    Order Status
                  &amp;lt;/span&amp;gt;
                  &amp;lt;span className="bg-green-200 rounded-full p-[4px] text-center text-[10px] font-extrabold text-gray-800"&amp;gt;
                    {myOrder?.status}
                  &amp;lt;/span&amp;gt;
                &amp;lt;/span&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/Link&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default MyOrderCard;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>JavaScript</title>
      <dc:creator>San</dc:creator>
      <pubDate>Fri, 27 Oct 2023 19:19:45 +0000</pubDate>
      <link>https://forem.com/imsan/javascript-33ij</link>
      <guid>https://forem.com/imsan/javascript-33ij</guid>
      <description>&lt;h2&gt;
  
  
  1. Join
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ["Banana", "Orange", "Apple", "Mango"];
let text = fruits.join();


join() returns an array as a string

Output: 
Banana,Orange,Apple,Mango
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const productPrice = 30
const gstRate = 5

const GST = 30 - [30 * 100 / (100 + 5)]
// GST = Supply Value - [Supply Value x {100/(100+GST%)}]

const vv = 30 - (30 * 100 / 105)

let gstPrice = vv
let gstIncludedPrice = productPrice - gstPrice
let finalPriceIncludedGST = productPrice - gstIncludedPrice
const finalProductPriceIncludedGST = gstIncludedPrice + gstPrice


console.log("GST Price=", gstPrice);
console.log("GST Included Price=", gstIncludedPrice);
console.log("Net Price Included GST=", finalProductPriceIncludedGST);

const finalVal = `GST charged of ${gstRate}% Product Price ${productPrice} = ${GST} `

console.log(finalVal);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Remove qouma and put space in string js</title>
      <dc:creator>San</dc:creator>
      <pubDate>Fri, 27 Oct 2023 08:32:33 +0000</pubDate>
      <link>https://forem.com/imsan/remove-qouma-and-put-space-in-string-js-dnm</link>
      <guid>https://forem.com/imsan/remove-qouma-and-put-space-in-string-js-dnm</guid>
      <description>&lt;h2&gt;
  
  
  Remove qouma and put space in string js
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const str = 'apple,ball,cat';

const withoutCommas = str.replaceAll(',', ' ');
console.log(withoutCommas); // 👉️ 'apple ball cat'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
