summaryrefslogtreecommitdiff
path: root/app/lib/api/auth.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/api/auth.ts')
-rw-r--r--app/lib/api/auth.ts42
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