summaryrefslogtreecommitdiff
path: root/src-migrate/modules/cart/components/ItemSelect.tsx
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-05-31 14:33:24 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-05-31 14:33:24 +0700
commit3f992f62c54e09254c48d653c2cd138df1cbd8e2 (patch)
tree3c2bc8de3f99b162aeb44c4ac138367cb1ea7332 /src-migrate/modules/cart/components/ItemSelect.tsx
parent2a1dea70b8f0062fe8eebeb7139a7b77a24e220b (diff)
<miqdad> fix error deployment
Diffstat (limited to 'src-migrate/modules/cart/components/ItemSelect.tsx')
-rw-r--r--src-migrate/modules/cart/components/ItemSelect.tsx22
1 files changed, 12 insertions, 10 deletions
diff --git a/src-migrate/modules/cart/components/ItemSelect.tsx b/src-migrate/modules/cart/components/ItemSelect.tsx
index 72ab49aa..f95ee36c 100644
--- a/src-migrate/modules/cart/components/ItemSelect.tsx
+++ b/src-migrate/modules/cart/components/ItemSelect.tsx
@@ -11,11 +11,11 @@ import {
checkboxUpdateState,
} from '~/utils/cart';
-type Props = {
+interface Props {
item: CartItem;
-};
+}
-const CartItemSelect = ({ item }: Props) => {
+const CartItemSelect: React.FC<Props> = ({ item }) => {
const auth = getAuth();
const { updateCartItem, cart, loadCart } = useCartStore();
const [isUpdating, setIsUpdating] = useState<boolean>(false);
@@ -23,7 +23,7 @@ const CartItemSelect = ({ item }: Props) => {
// Subscribe to global checkbox update state
useEffect(() => {
- const handleUpdateStateChange = (isUpdating) => {
+ const handleUpdateStateChange = (isUpdating: boolean): void => {
// This component doesn't need to react to global state changes
// Individual checkboxes are managed independently
};
@@ -36,7 +36,10 @@ const CartItemSelect = ({ item }: Props) => {
useEffect(() => {
if (isUpdating) return;
- const selectedItems = getSelectedItemsFromCookie();
+ const selectedItems = getSelectedItemsFromCookie() as Record<
+ number,
+ boolean
+ >;
const storedState = selectedItems[item.id];
if (storedState !== undefined) {
@@ -62,7 +65,7 @@ const CartItemSelect = ({ item }: Props) => {
}, [item.id, item.selected, localSelected, cart, updateCartItem, isUpdating]);
const handleChange = useCallback(
- async (e: React.ChangeEvent<HTMLInputElement>) => {
+ async (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => {
if (typeof auth !== 'object' || !cart || isUpdating) return;
const newSelectedState = e.target.checked;
@@ -70,7 +73,7 @@ const CartItemSelect = ({ item }: Props) => {
// Update local state immediately
setLocalSelected(newSelectedState);
setIsUpdating(true);
- checkboxUpdateState.startUpdate(item.id);
+ checkboxUpdateState.startUpdate();
try {
// Update cookie immediately for responsive UI
@@ -107,14 +110,13 @@ const CartItemSelect = ({ item }: Props) => {
loadCart(auth.id);
} finally {
setIsUpdating(false);
- checkboxUpdateState.endUpdate(item.id);
+ checkboxUpdateState.endUpdate();
}
},
[auth, cart, item, isUpdating, updateCartItem, loadCart]
);
- const isDisabled =
- isUpdating || checkboxUpdateState.isCheckboxUpdating(item.id);
+ const isDisabled: boolean = isUpdating;
return (
<div className='w-6 my-auto relative'>