mirror of
https://github.com/vercel/commerce.git
synced 2025-07-24 18:51:23 +00:00
commit b10e930476d8bbe82f679f3ae8ed44cea733898f Merge:a2c34aa
8531476 Author: Sammii <sammii.h@icloud.com> Date: Wed Apr 24 20:05:09 2024 +0100 Merge pull request #1 from Sammii-HK/feat/restyle-store Feat/restyle store commit 85314765721447f5612cb59b7e668653606e7b7b Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 20:03:12 2024 +0100 responsive design app page carousel commit d5563a7355c2581c29ebf3f11799e1047c0c29dd Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 19:57:47 2024 +0100 updating mobile carousel tile size commit 9976d0d427ea92dab510bface5da9a4e89feabee Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 19:30:07 2024 +0100 updating combox import commitf6a365df82
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 19:16:08 2024 +0100 styling label price commitcf89e3b064
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 19:08:16 2024 +0100 styling accordians and drop downs commit49f3776ba8
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:53:14 2024 +0100 updating search and carousel styling commit7666a25f91
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:37:29 2024 +0100 styling product description commitb8280101ad
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:18:11 2024 +0100 removing `-full` from all rounded elements commit77480edd79
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:15:27 2024 +0100 styling cart component commit3ec0c4d567
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:06:53 2024 +0100 updating styling commitefcab21893
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:06:43 2024 +0100 updating carousel for correct types commitb14934af84
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:57:31 2024 +0100 styling tile commit0c72e76bad
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:56:50 2024 +0100 styling label commitca24a30543
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:54:54 2024 +0100 update main app layout for dark view commit57c1c4cac9
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:52:53 2024 +0100 commenting out weight li on description content commitd2f0ac2041
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:52:02 2024 +0100 updating carousel to new style commit545717006d
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:50:55 2024 +0100 updating getAllLiveProducts to handle no param commit0bf97ecdf6
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:50:39 2024 +0100 styling and adjusting footer & navbar commit18200b4e84
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:50:00 2024 +0100 updating cart to bag commit82c30cdda8
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:48:32 2024 +0100 SKUs page file check commite88a45b9d5
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:47:30 2024 +0100 updatibng Prose import path commit5e81519f98
Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:45:58 2024 +0100 updating app page metadata commit9c9a5c035b
Author: Samantha Kellow <sammii.h@icloud.com> Date: Tue Apr 23 21:25:05 2024 +0100 making borders muted commit8a40e08e41
Author: Samantha Kellow <sammii.h@icloud.com> Date: Tue Apr 23 20:37:35 2024 +0100 moving ui components to own folder 🧹
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { useRouter } from 'next/navigation';
|
|
import { useTransition } from 'react';
|
|
|
|
import { MinusIcon, PlusIcon } from '@heroicons/react/24/outline';
|
|
import clsx from 'clsx';
|
|
import { removeItem, updateItemQuantity } from 'components/cart/actions';
|
|
import LoadingDots from 'components/ui/loading-dots';
|
|
import type { CartItem } from 'lib/shopify/types';
|
|
|
|
export default function EditItemQuantityButton({
|
|
item,
|
|
type
|
|
}: {
|
|
item: CartItem;
|
|
type: 'plus' | 'minus';
|
|
}) {
|
|
const router = useRouter();
|
|
const [isPending, startTransition] = useTransition();
|
|
|
|
return (
|
|
<button
|
|
aria-label={type === 'plus' ? 'Increase item quantity' : 'Reduce item quantity'}
|
|
onClick={() => {
|
|
startTransition(async () => {
|
|
const error =
|
|
type === 'minus' && item.quantity - 1 === 0
|
|
? await removeItem(item.id)
|
|
: await updateItemQuantity({
|
|
lineId: item.id,
|
|
variantId: item.merchandise.id,
|
|
quantity: type === 'plus' ? item.quantity + 1 : item.quantity - 1
|
|
});
|
|
|
|
if (error) {
|
|
alert(error);
|
|
return;
|
|
}
|
|
|
|
router.refresh();
|
|
});
|
|
}}
|
|
disabled={isPending}
|
|
className={clsx(
|
|
'ease flex h-full min-w-[36px] max-w-[36px] flex-none items-center justify-center rounded px-2 transition-all duration-200 hover:border-neutral-800 hover:opacity-80',
|
|
{
|
|
'cursor-not-allowed': isPending,
|
|
'ml-auto': type === 'minus'
|
|
}
|
|
)}
|
|
>
|
|
{isPending ? (
|
|
<LoadingDots className="bg-black dark:bg-white" />
|
|
) : type === 'plus' ? (
|
|
<PlusIcon className="h-4 w-4 dark:text-neutral-500" />
|
|
) : (
|
|
<MinusIcon className="h-4 w-4 dark:text-neutral-500" />
|
|
)}
|
|
</button>
|
|
);
|
|
}
|