This commit is contained in:
2025-10-09 09:02:15 +07:00
parent f7c96a0258
commit 4b11ee2180
4 changed files with 50 additions and 5 deletions

View File

@@ -1,12 +1,27 @@
import { createContext } from 'react'
import { createContext, useEffect } from 'react'
import RouterSetup from './RouterSetup'
import { useSelector } from 'react-redux'
import { useDispatch, useSelector } from 'react-redux'
import type { StoreType } from './stores'
import Loading from './components/Loading'
import { Apis } from './apis'
import { userAction } from './stores/slices/user.slice'
export default function App() {
const userStore = useSelector((store: StoreType) => store.user)
const dipatch = useDispatch()
useEffect(() => {
if(userStore.data && !userStore.loading) {
try {
Apis.cart.getCartByUserId(userStore.data.id)
.then(res => {
dipatch(userAction.initCartData(res))
})
}catch(err) {
}
}
}, [userStore.data, userStore.loading])
return (
<>
{