diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-10-21 14:54:11 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-10-21 14:54:11 +0700 |
| commit | 83d1a1c558293e1b14c9a5847628e7661f749c66 (patch) | |
| tree | 5f083f90192df0fc2aff41e3dd1c3c84f2592352 /app/lib/api/auth.ts | |
| parent | 30c5eb5776fcc60f023ad6aa51153cb375c87930 (diff) | |
initial commit
Diffstat (limited to 'app/lib/api/auth.ts')
| -rw-r--r-- | app/lib/api/auth.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/app/lib/api/auth.ts b/app/lib/api/auth.ts new file mode 100644 index 0000000..d954dc5 --- /dev/null +++ b/app/lib/api/auth.ts @@ -0,0 +1,42 @@ +import { deleteCookie, getCookie, setCookie } from "cookies-next" + +type AuthProps = { + id: number; + parentId: number; + parentName: string; + partnerId: number; + name: string; + email: string; + phone: string; + npwp: string; + mobile: string; + external: boolean; + company: boolean; + pricelist: string | null; + token: string; + feature : { + onlyReadyStock : boolean, + soApproval : boolean + } + }; + +const getAuth = () : AuthProps | boolean => { + const auth = getCookie('auth') + + if (auth) return JSON.parse(auth) + return false + +} + +const setAuth = (user : AuthProps) : boolean => { + setCookie('auth', JSON.stringify(user)) + return true +} + + +const deleteAuth = () : boolean => { + deleteCookie('auth') + return true +} + +export { getAuth , setAuth, deleteAuth}
\ No newline at end of file |
