From 07819844d5ef7e323fd956eacfedecb2f4f4bb80 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Nov 2023 15:16:23 +0700 Subject: Update result feature --- src/common/components/Authenticated/index.tsx | 5 ++--- src/common/constants/team.ts | 5 ++++- src/common/stores/useResultStore.ts | 10 ++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/components/Authenticated/index.tsx b/src/common/components/Authenticated/index.tsx index cf7086e..3957a8d 100644 --- a/src/common/components/Authenticated/index.tsx +++ b/src/common/components/Authenticated/index.tsx @@ -1,10 +1,9 @@ -import { cookies } from 'next/headers' +import getServerCredential from '@/common/libs/getServerCredential' import { redirect } from 'next/navigation' import React from 'react' const Authenticated = ({ children }: { children: React.ReactNode }) => { - const credentialStr = cookies().get('credential')?.value - const credential: Credential | null = credentialStr ? JSON.parse(credentialStr) : null + const credential = getServerCredential() if (!credential) redirect('/login') diff --git a/src/common/constants/team.ts b/src/common/constants/team.ts index cfb895b..8daad6a 100644 --- a/src/common/constants/team.ts +++ b/src/common/constants/team.ts @@ -1,12 +1,15 @@ import { TeamAliases } from "../types/team"; -export const teamAliases: TeamAliases = { +export const TEAM_ALIASES: TeamAliases = { COUNT1: { name: "Hitung 1", }, COUNT2: { name: "Hitung 2", }, + COUNT3: { + name: "Hitung 3", + }, VERIFICATION: { name: "Verifikasi", }, diff --git a/src/common/stores/useResultStore.ts b/src/common/stores/useResultStore.ts index d8da56c..09e8146 100644 --- a/src/common/stores/useResultStore.ts +++ b/src/common/stores/useResultStore.ts @@ -1,20 +1,25 @@ import { create } from "zustand"; +import { SelectOption } from "../types/select"; type State = { filter: { search: string; company: string; + show: string; }; + companies: SelectOption[]; }; type Action = { updateFilter: (name: string, value: string) => void; + setCompanies: (data: SelectOption[]) => void; }; export const useResultStore = create((set) => ({ filter: { search: "", company: "", + show: "1", }, updateFilter: (name, value) => set((state) => ({ @@ -23,4 +28,9 @@ export const useResultStore = create((set) => ({ [name]: value, }, })), + companies: [], + setCompanies: (data) => + set(() => ({ + companies: data, + })), })); -- cgit v1.2.3