Skip to content

Commit eb67f7b

Browse files
Fixed : UI related chagnes
1 parent 0253b5a commit eb67f7b

23 files changed

Lines changed: 133 additions & 129 deletions

File tree

app/(public)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default async function RootLayout({
1010
return (
1111
<main>
1212
<Navbar />
13-
<div className="mx-auto min-h-[calc(100vh-450px)] w-full max-w-screen-2xl px-[15px] xss:px-7.5">
13+
<div className="mx-auto min-h-[calc(100vh-580px)] w-full max-w-screen-2xl px-[15px] xss:px-7.5">
1414
{children}
1515
</div>
1616
<Footer />

app/(public)/search/page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getFilterAttributes, getProducts } from "@/lib/bagisto";
99
import MobileFilter from "@/components/layout/search/filter/modile-filter";
1010
import { isArray } from "@/lib/type-guards";
1111
import Pagination from "@/components/elements/pagination";
12+
import CategoryDetail from "@/components/layout/search/category-detail.tsx";
1213
const ProductGridItems = dynamic(
1314
() => import("@/components/layout/product-grid-items"),
1415
{
@@ -62,6 +63,12 @@ export default async function SearchPage({
6263

6364
return (
6465
<>
66+
<CategoryDetail
67+
categoryItem={{
68+
description: `<h1>All Top Products</h1> <p>${searchValue ? searchValue : ""}</p>`,
69+
}}
70+
/>
71+
6572
<div className="my-10 hidden gap-4 md:flex md:items-baseline md:justify-between">
6673
<Suspense fallback={<FilterListSkeleton />}>
6774
<FilterList filterAttributes={filterAttributes} />

app/api/cart-detail/route.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
import { bagistoFetch } from "@/lib/bagisto";
22
import { getCartQuery } from "@/lib/bagisto/queries/cart";
33
import { BagistoCartOperation } from "@/lib/bagisto/types";
4-
import { TAGS } from "@/lib/constants";
4+
import { BAGISTO_SESSION, TAGS } from "@/lib/constants";
55
import { isObject } from "@/lib/type-guards";
6+
import { generateCookieValue } from "@/lib/utils";
7+
import { cookies } from "next/headers";
68

79
export async function GET() {
810
try {
11+
const store = await cookies();
12+
let cartId = store.get(BAGISTO_SESSION)?.value;
13+
if (!cartId) {
14+
// Generate new session ID
15+
cartId = generateCookieValue(40);
16+
// Set cookie
17+
store.set({
18+
name: BAGISTO_SESSION,
19+
value: cartId,
20+
secure: false,
21+
});
22+
return Response.json({ cartDetail: null }, { status: 200 });
23+
}
24+
925
const response = await bagistoFetch<BagistoCartOperation>({
1026
query: getCartQuery,
1127
tags: [TAGS.cart],
1228
cache: "no-store",
1329
});
14-
1530
const res = response.body.data;
16-
1731
// Old carts becomes `null` when you checkout.
1832
if (!isObject(res?.cartDetail)) {
1933
return Response.json({ cartDetail: null }, { status: 200 });

changelog.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# Change Log
22

3+
## [2.2.0] - 2025-09-09
4+
5+
### Added
6+
7+
- Added `BAGISTO_SESSION` key.
8+
- Added `NEXTAUTH_URL` key.
9+
- Added `NEXTAUTH_SECRET` key.
10+
- Added `REVALIDATION_DURATION` key.
11+
- Added `IMAGE_DOMAIN` key.
12+
- Added the new the query field.
13+
- Added the Authentication pages (Sign Up, Sign In and Forget Password).
14+
- Added Customer Checkout.
15+
- Added more banner on the home page.
16+
- Added the pagination and Product Attributes.
17+
18+
19+
### Removed
20+
21+
- Removed `BAGISTO_PROTOCOL` key.
22+
- Removed `BAGISTO_STOREFRONT_ACCESS_TOKEN` key.
23+
- Removed `BAGISTO_REVALIDATION_SECRET` key.
24+
25+
### Changed
26+
27+
- Updated the latest changes of the UI.
28+
- Manged the state with Redux.
29+
30+
### Fixed
31+
32+
- Resolved the UI issues.
33+
- Improved performance.
34+
- Made compatible with the latest Bagisto APIs (version 2.3.0).
35+
336
## [2.1.0] - 2025-02-24
437

538
### Added

components/cart/edit-item-quantity-button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ function SubmitButton({
2525
type === "plus" ? "Increase item quantity" : "Reduce item quantity"
2626
}
2727
className={clsx(
28-
"ease flex h-full min-w-[36px] max-w-[36px] flex-none items-center justify-center rounded-full px-2 transition-all duration-200 hover:border-neutral-800 hover:opacity-80",
28+
"ease flex h-full cursor-pointer min-w-[36px] max-w-[36px] flex-none items-center justify-center rounded-full px-2 transition-all duration-200 hover:border-neutral-800 hover:opacity-80",
2929
{
3030
"cursor-wait": pending,
3131
"ml-auto": type === "minus",
32-
},
32+
}
3333
)}
3434
type="button"
3535
onClick={() => handleUpdateCart(type)}

components/cart/open-cart.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@ export default function OpenCart({
99
quantity?: number | string;
1010
}) {
1111
return (
12-
<div className="relative flex h-9 w-9 items-center justify-center rounded-md border border-solid border-neutral-200 text-black transition-colors dark:border-neutral-700 dark:text-white md:h-9 md:w-9 lg:h-11 lg:w-11">
13-
<ShoppingCartIcon
14-
className={clsx(
15-
"h-4 transition-all ease-in-out hover:scale-110 ",
16-
className
17-
)}
18-
/>
12+
<div className="relative flex h-9 w-9 items-center justify-center rounded-md border border-solid border-neutral-200 text-black dark:border-neutral-700 dark:text-white md:h-9 md:w-9 lg:h-11 lg:w-11">
13+
<ShoppingCartIcon className={clsx("h-4.5 ", className)} />
1914

2015
{quantity ? (
2116
<div className="absolute right-0 top-0 -mr-2 -mt-2 h-4 w-4 rounded bg-blue-600 text-[11px] font-medium text-white">

components/checkout/cart/cart-item-accordian.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ShoppingCartIcon from "@/components/icons/shopping-cart";
33
import Price from "@/components/price";
44
// import { Disclosure, Transition } from "@headlessui/react";
55

6-
import type { Cart } from "@/lib/bagisto/types";
6+
import type { BagistoCart, Cart } from "@/lib/bagisto/types";
77
import { DEFAULT_OPTION } from "@/lib/constants";
88
import { isObject } from "@/lib/type-guards";
99
import { createUrl } from "@/lib/utils";
@@ -19,7 +19,7 @@ type MerchandiseSearchParams = {
1919
export default function CartItemAccordion({
2020
cartItem,
2121
}: {
22-
cartItem: Cart | undefined;
22+
cartItem: BagistoCart;
2323
}) {
2424
return (
2525
<div className="mobile-heading mx-auto block w-full dark:bg-transparent lg:hidden">

components/checkout/cart/cart.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@ import Prose from "@/components/prose";
1010
import { DEFAULT_OPTION } from "@/lib/constants";
1111
import { isObject } from "@/lib/type-guards";
1212
import { createUrl } from "@/lib/utils";
13+
import { useEffect } from "react";
14+
import { useRouter } from "next/navigation";
15+
import { BagistoCart } from "@/lib/bagisto/types";
1316
type MerchandiseSearchParams = {
1417
[key: string]: string;
1518
};
16-
export default function Cart({ cart }: { cart: any }) {
19+
export default function Cart({ cart }: { cart: BagistoCart }) {
20+
const router = useRouter();
21+
22+
useEffect(() => {
23+
if (!isObject(cart)) {
24+
router.replace("/");
25+
}
26+
}, []);
1727
return (
1828
<>
1929
<CartItemAccordion cartItem={cart} />

components/checkout/information/checkout.tsx

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { CartSkeleton } from "../product-cart-skeleton";
44
import Stepper from "../stepper";
55
import { useCartDetail } from "@/components/hooks/use-cart-detail";
66
import { useAppSelector } from "@/store/hooks";
7-
import { CountryArrayDataType } from "@/lib/bagisto/types";
7+
import { BagistoCart, CountryArrayDataType } from "@/lib/bagisto/types";
88
import CheckoutSkeleton from "../place-holder";
9+
import { useEffect } from "react";
10+
import { isObject } from "@/lib/type-guards";
11+
import { useRouter } from "next/navigation";
912
interface CheckOutProps {
1013
countries: CountryArrayDataType[];
1114
step: string;
@@ -15,22 +18,7 @@ const CheckOut = ({ countries, step }: CheckOutProps) => {
1518
const { isLoading } = useCartDetail();
1619
const cartDetail = useAppSelector((state) => state.cartDetail);
1720

18-
if (isLoading) {
19-
return (
20-
<section className="flex flex-col-reverse items-start justify-between lg:flex-row lg:justify-between">
21-
<div className="w-full px-0 py-2 sm:px-4 sm:py-4 lg:w-1/2 xl:px-16">
22-
<CheckoutSkeleton />
23-
</div>
24-
25-
<div className="h-full w-full justify-self-start border-0 border-l border-none border-black/[10%] dark:border-neutral-700 lg:w-1/2 lg:border-solid">
26-
<CartSkeleton className="w-full" />
27-
</div>
28-
</section>
29-
);
30-
}
31-
3221
const cartItems = cartDetail?.cart;
33-
3422
const billingAddress = cartItems?.billingAddress;
3523
const shippingAddress = cartItems?.shippingAddress;
3624
const userEmail = cartItems?.customerEmail;
@@ -43,22 +31,30 @@ const CheckOut = ({ countries, step }: CheckOutProps) => {
4331
<>
4432
<section className="flex flex-col-reverse items-start justify-between lg:flex-row lg:justify-between">
4533
<div className="w-full px-0 py-2 sm:px-4 sm:py-4 lg:w-1/2 xl:px-16">
46-
<Stepper
47-
billingAddress={billingAddress}
48-
countries={countries}
49-
currentStep={step}
50-
isGuest={isGuest}
51-
selectedPayment={selectedPayment}
52-
selectedShippingRate={selectedShippingRate}
53-
shippingAddress={shippingAddress}
54-
userEmail={userEmail}
55-
/>
34+
{isLoading ? (
35+
<CheckoutSkeleton />
36+
) : (
37+
<Stepper
38+
billingAddress={billingAddress}
39+
countries={countries}
40+
currentStep={step}
41+
isGuest={isGuest}
42+
selectedPayment={selectedPayment}
43+
selectedShippingRate={selectedShippingRate}
44+
shippingAddress={shippingAddress}
45+
userEmail={userEmail}
46+
/>
47+
)}
5648
</div>
5749

5850
<div className="h-full w-full justify-self-start border-0 border-l border-none border-black/[10%] dark:border-neutral-700 lg:w-1/2 lg:border-solid">
59-
<div className="max-h-auto w-full flex-initial flex-shrink-0 flex-grow-0 lg:sticky lg:top-0">
60-
<Cart cart={cartItems} />
61-
</div>
51+
{isLoading ? (
52+
<CartSkeleton className="w-full" />
53+
) : (
54+
<div className="max-h-auto w-full flex-initial flex-shrink-0 flex-grow-0 lg:sticky lg:top-0">
55+
<Cart cart={cartItems as BagistoCart} />
56+
</div>
57+
)}
6258
</div>
6359
</section>
6460
</>

components/customer/modal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ export default function CredentialModal() {
160160
placement="bottom-end"
161161
>
162162
<PopoverTrigger>
163-
<button aria-label="Open cart" className="cursor-pointer">
163+
<button
164+
aria-label="Open cart"
165+
className="cursor-pointer bg-transparent"
166+
>
164167
<OpenAuth />
165168
</button>
166169
</PopoverTrigger>

0 commit comments

Comments
 (0)