diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-11-17 15:14:46 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-11-17 15:14:46 +0700 |
| commit | e101de1a0bc1ab08c2bed1fe2bed0ec3ad45a442 (patch) | |
| tree | 14834b231116a1d8060b4c02f664fd23850fa99a | |
| parent | 05ef2c3712192df547587b7d02416f6be0419e1f (diff) | |
Create get credential lib and result constant
| -rw-r--r-- | src/common/constants/result.ts | 5 | ||||
| -rw-r--r-- | src/common/libs/getClientCredential.ts | 9 | ||||
| -rw-r--r-- | src/common/libs/getServerCredential.ts | 8 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/common/constants/result.ts b/src/common/constants/result.ts new file mode 100644 index 0000000..229bc87 --- /dev/null +++ b/src/common/constants/result.ts @@ -0,0 +1,5 @@ +export const SHOWING_SELECTIONS = [ + { key: "1", value: "", label: "Semua" }, + { key: "2", value: "diff", label: "Selisih" }, + { key: "3", value: "not-diff", label: "Tidak Selisih" }, +]; diff --git a/src/common/libs/getClientCredential.ts b/src/common/libs/getClientCredential.ts new file mode 100644 index 0000000..fc0bd76 --- /dev/null +++ b/src/common/libs/getClientCredential.ts @@ -0,0 +1,9 @@ +"use client"; +import { getCookie } from "cookies-next"; +import { Credential } from "../types/auth"; + +export default function getClientCredential(): Credential | null { + const credentialStr = getCookie("credential"); + + return credentialStr ? JSON.parse(credentialStr) : null; +} diff --git a/src/common/libs/getServerCredential.ts b/src/common/libs/getServerCredential.ts new file mode 100644 index 0000000..58ffdad --- /dev/null +++ b/src/common/libs/getServerCredential.ts @@ -0,0 +1,8 @@ +import { cookies } from "next/headers"; +import { Credential } from "../types/auth"; + +export default function getServerCredential(): Credential | null { + const credentialStr = cookies().get("credential")?.value; + + return credentialStr ? JSON.parse(credentialStr) : null; +} |
