mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
update active order after login
This commit is contained in:
@@ -6,6 +6,7 @@ import { LoginMutation } from '@framework/schema'
|
|||||||
import { LOCAL_STORAGE_KEY } from 'src/utils/constanst.utils'
|
import { LOCAL_STORAGE_KEY } from 'src/utils/constanst.utils'
|
||||||
import { errorMapping } from 'src/utils/errrorMapping'
|
import { errorMapping } from 'src/utils/errrorMapping'
|
||||||
import { loginMutation } from '@framework/utils/mutations/log-in-mutation'
|
import { loginMutation } from '@framework/utils/mutations/log-in-mutation'
|
||||||
|
import { useGetActiveOrder } from '../cart'
|
||||||
|
|
||||||
interface LoginInput {
|
interface LoginInput {
|
||||||
username: string
|
username: string
|
||||||
@@ -16,6 +17,7 @@ const useLogin = () => {
|
|||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [error, setError] = useState<CommonError | null>(null)
|
const [error, setError] = useState<CommonError | null>(null)
|
||||||
const { mutate } = useActiveCustomer()
|
const { mutate } = useActiveCustomer()
|
||||||
|
const { mutate: mutateOrder } = useGetActiveOrder()
|
||||||
|
|
||||||
const login = (options: LoginInput,
|
const login = (options: LoginInput,
|
||||||
fCallBack: (isSuccess: boolean, message?: string) => void
|
fCallBack: (isSuccess: boolean, message?: string) => void
|
||||||
@@ -34,6 +36,7 @@ const useLogin = () => {
|
|||||||
if (authToken != null) {
|
if (authToken != null) {
|
||||||
localStorage.setItem(LOCAL_STORAGE_KEY.TOKEN, authToken)
|
localStorage.setItem(LOCAL_STORAGE_KEY.TOKEN, authToken)
|
||||||
mutate()
|
mutate()
|
||||||
|
mutateOrder()
|
||||||
}
|
}
|
||||||
fCallBack(true)
|
fCallBack(true)
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user