Skip to content

Commit

Permalink
feat: limit user create
Browse files Browse the repository at this point in the history
  • Loading branch information
Vann-Dev committed May 10, 2024
1 parent 5204c2b commit 2e8af54
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
12 changes: 9 additions & 3 deletions app/dashboard/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,15 @@ export default function Page() {
<h1 className='text-primary font-semibold text-5xl'>Panel Akun</h1>

<div className="flex gap-5 flex-wrap">
<button onClick={() => addUser()} className='hover:opacity-80 transition-opacity bg-primary px-4 py-2 rounded-xl text-background w-fit font-semibold'>
Tambah Pengguna
</button>
{userData?.data.length! >= 20 ? (
<div className='hover:opacity-80 transition-opacity opacity-70 bg-primary px-4 py-2 rounded-xl text-background w-fit font-semibold'>
Maksimal User Tercapai
</div>
) : (
<button onClick={() => addUser()} className='hover:opacity-80 transition-opacity bg-primary px-4 py-2 rounded-xl text-background w-fit font-semibold'>
Tambah Pengguna
</button>
)}
<Link href={"/dashboard/account/attendance"} className="hover:opacity-80 transition-opacity bg-secondary px-4 py-2 rounded-xl text-text w-fit font-semibold">
Absensi
</Link>
Expand Down
34 changes: 22 additions & 12 deletions app/dashboard/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,15 @@ export default function Page() {
<div className='container pt-10 md:pt-20 flex flex-col gap-y-6 md:gap-y-10'>
<h1 className='text-primary font-semibold text-5xl'>Panel Admin</h1>

<button onClick={addAccount} className='bg-primary px-4 py-2 rounded-xl text-background w-fit font-semibold'>
Tambah Akun
</button>
{accountsData?.data.length! >= 20 ? (
<div className='bg-primary px-4 py-2 rounded-xl opacity-70 text-background w-fit font-semibold'>
Maksimal Akun Tercapai
</div>
) : (
<button onClick={addAccount} className='bg-primary px-4 py-2 rounded-xl text-background w-fit font-semibold'>
Tambah Akun
</button>
)}

<input onChange={(e) => search(e.target.value)} className="bg-background px-4 py-2 rounded-lg border-2 border-primary focus:outline-none" placeholder="Cari"></input>

Expand All @@ -123,15 +129,19 @@ export default function Page() {
<TableCell>{account.email}</TableCell>
<TableCell className='text-right'>{new Date(account.createdAt).toLocaleString()}</TableCell>
<TableCell className='text-right flex items-center gap-x-3 justify-end'>
<button onClick={() => editAccount(account.id)}>
<Pencil className='stroke-blue-500' />
</button>
<button onClick={() => deleteCurrentAccount(account.id)}>
{loading ?
<LoaderCircle className='animate-spin stroke-red-500' /> :
<Trash2 className='stroke-red-500' />
}
</button>
{account.id !== "clw0qw8iy0000x2qbkdn3c9m3" && (
<>
<button onClick={() => editAccount(account.id)}>
<Pencil className='stroke-blue-500' />
</button>
<button onClick={() => deleteCurrentAccount(account.id)}>
{loading ?
<LoaderCircle className='animate-spin stroke-red-500' /> :
<Trash2 className='stroke-red-500' />
}
</button>
</>
)}
</TableCell>
</TableRow>
))}
Expand Down

0 comments on commit 2e8af54

Please sign in to comment.