Files
hats-app/app/admin/administration/user/[id]/page.tsx
T
2025-12-19 13:57:55 +07:00

146 lines
7.6 KiB
TypeScript

import { FC } from 'react';
import { type Metadata } from 'next';
import Link from 'next/link';
import dayjs from 'dayjs';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import fetchData from '@/lib/fetchData';
import { Button } from '@/components/ui/button';
import { type IUser } from '../component/type';
export const metadata: Metadata = {
title: "Admin | User Detail",
}
type Props = {
params: Promise<{ id: string | undefined }>
};
const UserDetailPage: FC<Props> = async ({ params }) => {
const id = (await params).id
const data: IUser = await fetchData(`/user/${id}`)
return (
<>
<Card>
<CardHeader className='flex flex-col sm:flex-row items-center justify-between space-y-3 sm:space-y-0'>
<div className='flex items-center sm:space-x-5'>
<Link href='/admin/administration/user' className='hidden sm:block'>
<Button variant='outline' size='icon'>
<i className="ti ti-arrow-left text-xl"></i>
</Button>
</Link>
<div className='space-y-1'>
<CardTitle>User Detail</CardTitle>
<CardDescription>Detail of user id {id}</CardDescription>
</div>
</div>
{data.status.code === 'A' &&
<Link href={`create?is_update=true&id=${id}`} className='w-full sm:w-max'>
<Button variant='secondary' className='w-full'>
Edit <i className="ti ti-edit ml-2 text-lg"></i>
</Button>
</Link>
}
</CardHeader>
<CardContent>
<div className='grid grid-cols-1 sm:grid-cols-2 font-medium gap-y-5'>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Fullname</span>
<span>{data?.fullname}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Nickname</span>
<span>{data?.nickname}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Email address</span>
<span className='lowercase'>{data?.email}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Phone</span>
<span>{data.phone_number || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>NIK</span>
<span>{data?.nik}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>NIKTG</span>
<span>{data?.niktg || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Company</span>
<span>{data?.company?.name}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Area</span>
<span>{data?.area?.name}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Department</span>
<span>{data?.division?.name}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Role</span>
<span>{data?.role?.name}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Employee Type</span>
<span>{data?.employee_type?.name || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Position</span>
<span>{data?.position?.name || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Birthday</span>
<span>{data?.birthday ? dayjs(data?.birthday).format('MMM DD, YYYY') : '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Gender</span>
<span>{data?.gender || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Hire Date</span>
<span>{data?.hire_date ? dayjs(data?.hire_date).format('MMM DD, YYYY') : '-'}</span>
</div><div className='flex flex-col'>
<span className='text-muted-foreground'>Contract Expiration Date</span>
<span>{data?.contract_expiration_date ? dayjs(data?.contract_expiration_date).format('MMM DD, YYYY') : '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Is Extend Contract</span>
<span>{data?.is_extend_contract || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Office Email</span>
<span>{data?.email_office || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Personal Email</span>
<span>{data?.email_personal || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Last Education</span>
<span>{data?.last_education || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Resign Date</span>
<span>{data?.resign_date ? dayjs(data?.resign_date).format('MMM DD, YYYY') : '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Resign Reason</span>
<span>{data?.resign_reason || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground'>Post Company</span>
<span>{data?.post_company || '-'}</span>
</div>
</div>
</CardContent>
</Card>
</>
);
}
export default UserDetailPage;