mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
54 lines
2.0 KiB
TypeScript
54 lines
2.0 KiB
TypeScript
import { FC, Suspense, lazy } from 'react';
|
|
import { type Metadata } from 'next';
|
|
import { redirect } from 'next/navigation';
|
|
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 { authOptions } from '@/pages/api/auth/[...nextauth]';
|
|
|
|
const FormComponent = lazy(() => import('./components/FormComponent'))
|
|
|
|
export const metadata: Metadata = {
|
|
title: "I'am Here",
|
|
description: "Employee update presence page.",
|
|
}
|
|
|
|
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-40 md: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">Update your presence 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; |