summaryrefslogtreecommitdiff
path: root/src/modules/result/components/MoreMenu.tsx
blob: cd4e8be606e5e3739eca32d128b53a664770710c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use client";
import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, useDisclosure } from '@nextui-org/react'
import { MoreVerticalIcon } from 'lucide-react'
import React, { useState, useEffect } from 'react'
import ImportModal from './ImportModal';
import ProductModal from './ProductModal';
import getClientCredential from '@/common/libs/getClientCredential';

type Credential = {
  team: string;
};

const MoreMenu = () => {
  const [credential, setCredential] = useState<Credential | null>(null);
  const importModal = useDisclosure();
  const productModal = useDisclosure();

  useEffect(() => {
    const cred = getClientCredential();
    setCredential(cred);
  }, []);

  if (!credential || credential.team !== 'VERIFICATION') {
    return null;
  }

  return credential && credential.team == 'VERIFICATION' && (
    <>
      <Dropdown>
        <DropdownTrigger>
          <Button variant="flat" className="px-2.5 min-w-fit">
            <MoreVerticalIcon size={20} />
          </Button>
        </DropdownTrigger>
        <DropdownMenu>
          <DropdownItem key="product" onPress={productModal.onOpen}>
            Product List
          </DropdownItem>
          <DropdownItem key="import" onPress={importModal.onOpen}>
            Import Product
          </DropdownItem>
        </DropdownMenu>
      </Dropdown>

      <ProductModal modal={productModal} />
      <ImportModal modal={importModal} />
    </>
  )
}

export default MoreMenu