initial provider

This commit is contained in:
Kasper
2021-09-14 17:23:36 +02:00
parent 5b4d1b57d4
commit cc83c1f0e9
66 changed files with 1665 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
import { MutationHook } from '@commerce/utils/types'
import useLogout, { UseLogout } from '@commerce/auth/use-logout'
import { useCallback } from 'react'
import Cookies from 'js-cookie'
export default useLogout as UseLogout<typeof handler>
export const handler: MutationHook<any> = {
fetchOptions: {
query: 'auth',
method: 'logout',
},
async fetcher({ options, fetch }) {
await fetch({ ...options })
return null
},
useHook:
({ fetch }) =>
() => {
return useCallback(
async function logout(input) {
const data = await fetch({ input })
return data
},
[fetch]
)
},
}