Files
hats-app/app/(dashboard)/iam-here/page.tsx
T
Ichsan Kurniawan 7f8e6637e4 Move auth config and build admin menus
Extract NextAuth configuration into a shared library, load admin sidebar items from role permissions, and update related RBAC types and UI.
2026-11-06 18:25:54 +07:00

53 lines
2.0 KiB
TypeScript

import { FC, Suspense, lazy } from 'react';
import { type Metadata } from 'next';
import { Separator } from '@/components/ui/separator';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import PageLoading from '@/components/loader/PageLoading';
import { fetchDataWithPost } from '@/lib/fetchData';
import { getServerSession } from 'next-auth';
import { redirect } from 'next/navigation';
import { authOptions } from '@/lib/auth';
const FormComponent = lazy(() => import('./components/FormComponent'))
export const metadata: Metadata = {
title: "Update Your Current Work Location and Condition (I'am Here) - HIS Attendance Task System (H.A.T.s)",
}
type Props = {};
const IamHerePage: FC<Props> = async () => {
const session = await getServerSession(authOptions)
const res = await fetchDataWithPost('/presence/last-status/today', { nik: session?.user.detail.nik })
if (res && res.is_checkin && res.device_code === '11001') {
redirect('/')
}
if (res && !res.is_checkin) {
redirect('/')
}
return (
<>
<div className='flex-1 w-full md:w-[800px] mx-auto px-5 py-10 md:p-10 pb-10'>
<Card>
<CardHeader>
<div className='flex justify-center items-center flex-col'>
<CardTitle className="text-lg font-medium">I'am Here</CardTitle>
<p className="text-sm text-muted-foreground text-center sm:px-20">Update your presence information (location, condition or other necessary information) with the latest data.</p>
</div>
</CardHeader>
<Separator className='w-10/12 xl:w-11/12 mx-auto' />
<CardContent className='mt-6'>
<Suspense fallback={<PageLoading />}>
<FormComponent />
</Suspense>
</CardContent>
</Card>
</div>
</>
);
}
export default IamHerePage;