summaryrefslogtreecommitdiff
path: root/src-migrate/modules/cart/components/CartItemSelect.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/modules/cart/components/CartItemSelect.tsx')
-rw-r--r--src-migrate/modules/cart/components/CartItemSelect.tsx45
1 files changed, 0 insertions, 45 deletions
diff --git a/src-migrate/modules/cart/components/CartItemSelect.tsx b/src-migrate/modules/cart/components/CartItemSelect.tsx
deleted file mode 100644
index f44b0d7e..00000000
--- a/src-migrate/modules/cart/components/CartItemSelect.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { Checkbox, Spinner } from '@chakra-ui/react'
-import React, { useState } from 'react'
-import { getAuth } from '~/common/libs/auth'
-import { CartItem } from '~/common/types/cart'
-import { upsertUserCart } from '~/services/cart'
-import { useCartStore } from '../stores/useCartStore'
-
-type Props = {
- item: CartItem
-}
-
-const CartItemSelect = ({ item }: Props) => {
- const auth = getAuth()
- const { loadCart } = useCartStore()
-
- const [isLoad, setIsLoad] = useState<boolean>(false)
-
- const handleChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
- if (typeof auth !== 'object') return
-
- setIsLoad(true)
- await upsertUserCart(auth.id, item.cart_type, item.id, item.quantity, e.target.checked)
- await loadCart(auth.id)
- setIsLoad(false)
- }
-
- return (
- <div className='w-5 my-auto'>
- {isLoad && (
- <Spinner className='my-auto' size='sm' />
- )}
- {!isLoad && (
- <Checkbox
- borderColor='gray.600'
- colorScheme='red'
- size='lg'
- isChecked={item.selected}
- onChange={handleChange}
- />
- )}
- </div>
- )
-}
-
-export default CartItemSelect \ No newline at end of file