commit
This commit is contained in:
40
src/app/dashboard/employee-directory/[id]/edit/page.tsx
Normal file
40
src/app/dashboard/employee-directory/[id]/edit/page.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import PageContainer from '@/components/layout/page-container';
|
||||
import EmployeeForm from '@/features/employees/components/employee-form';
|
||||
import {
|
||||
getEmployeeByIdForOrganization,
|
||||
serializeEmployee
|
||||
} from '@/features/employees/server/employee-data';
|
||||
import { requireHRDDashboardAccess } from '@/lib/auth/page-guards';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Dashboard: Edit Employee'
|
||||
};
|
||||
|
||||
type PageProps = {
|
||||
params: Promise<{ id: string }>;
|
||||
};
|
||||
|
||||
export default async function Page(props: PageProps) {
|
||||
const access = await requireHRDDashboardAccess();
|
||||
const params = await props.params;
|
||||
const employee = await getEmployeeByIdForOrganization({
|
||||
id: Number(params.id),
|
||||
organizationId: access.organization.id
|
||||
});
|
||||
|
||||
if (!employee) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<PageContainer pageTitle='แก้ไขข้อมูลพนักงาน' pageDescription='ปรับปรุงข้อมูล Employee Master'>
|
||||
<EmployeeForm
|
||||
initialData={serializeEmployee(employee)}
|
||||
pageTitle='แก้ไขข้อมูลพนักงาน'
|
||||
organizationName={access.organization.name}
|
||||
returnPath='/dashboard/employee-directory'
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
28
src/app/dashboard/employee-directory/[id]/page.tsx
Normal file
28
src/app/dashboard/employee-directory/[id]/page.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import PageContainer from '@/components/layout/page-container';
|
||||
import { EmployeeDirectoryDetailPage } from '@/features/employee-directory/components/employee-directory-detail-page';
|
||||
import { requireHRDDashboardAccess } from '@/lib/auth/page-guards';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Dashboard: Employee Directory Detail'
|
||||
};
|
||||
|
||||
type PageProps = {
|
||||
params: Promise<{ id: string }>;
|
||||
};
|
||||
|
||||
export default async function Page(props: PageProps) {
|
||||
const access = await requireHRDDashboardAccess();
|
||||
const params = await props.params;
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
pageTitle='รายชื่อพนักงานทั้งหมด'
|
||||
pageDescription='รายละเอียดข้อมูลพนักงาน ชั่วโมงอบรม และประวัติการอบรมรายบุคคล'
|
||||
>
|
||||
<EmployeeDirectoryDetailPage
|
||||
organizationId={access.organization.id}
|
||||
employeeId={params.id}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
35
src/app/dashboard/employee-directory/[id]/targets/page.tsx
Normal file
35
src/app/dashboard/employee-directory/[id]/targets/page.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
|
||||
import PageContainer from '@/components/layout/page-container';
|
||||
import { employeeDirectoryTargetQueryOptions } from '@/features/employee-directory/api/queries';
|
||||
import { EmployeeTargetForm } from '@/features/employee-directory/components/employee-target-form';
|
||||
import { requireHRDDashboardAccess } from '@/lib/auth/page-guards';
|
||||
import { getQueryClient } from '@/lib/query-client';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Dashboard: Employee Targets'
|
||||
};
|
||||
|
||||
type PageProps = {
|
||||
params: Promise<{ id: string }>;
|
||||
};
|
||||
|
||||
export default async function Page(props: PageProps) {
|
||||
await requireHRDDashboardAccess();
|
||||
const params = await props.params;
|
||||
const year = new Date().getUTCFullYear();
|
||||
const employeeId = Number(params.id);
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
await queryClient.fetchQuery(employeeDirectoryTargetQueryOptions(employeeId, year));
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
pageTitle='กำหนดเป้าหมาย K / S / A'
|
||||
pageDescription='จัดการเป้าหมายชั่วโมงอบรมรายบุคคล'
|
||||
>
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<EmployeeTargetForm employeeId={employeeId} year={year} />
|
||||
</HydrationBoundary>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
25
src/app/dashboard/employee-directory/create/page.tsx
Normal file
25
src/app/dashboard/employee-directory/create/page.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import PageContainer from '@/components/layout/page-container';
|
||||
import EmployeeForm from '@/features/employees/components/employee-form';
|
||||
import { requireHRDDashboardAccess } from '@/lib/auth/page-guards';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Dashboard: Create Employee'
|
||||
};
|
||||
|
||||
export default async function Page() {
|
||||
const access = await requireHRDDashboardAccess();
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
pageTitle='สร้างรายชื่อพนักงาน'
|
||||
pageDescription='เพิ่มข้อมูลพนักงานเข้าสู่ Employee Directory'
|
||||
>
|
||||
<EmployeeForm
|
||||
initialData={null}
|
||||
pageTitle='สร้างรายชื่อพนักงาน'
|
||||
organizationName={access.organization.name}
|
||||
returnPath='/dashboard/employee-directory'
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
46
src/app/dashboard/employee-directory/page.tsx
Normal file
46
src/app/dashboard/employee-directory/page.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import PageContainer from '@/components/layout/page-container';
|
||||
import { EmployeeDirectoryHeader } from '@/features/employee-directory/components/employee-directory-header';
|
||||
import EmployeeDirectoryListingPage from '@/features/employee-directory/components/employee-directory-listing';
|
||||
import { requireHRDDashboardAccess } from '@/lib/auth/page-guards';
|
||||
import { searchParamsCache } from '@/lib/searchparams';
|
||||
import type { SearchParams } from 'nuqs/server';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Dashboard: Employee Directory'
|
||||
};
|
||||
|
||||
type PageProps = {
|
||||
searchParams: Promise<SearchParams>;
|
||||
};
|
||||
|
||||
export default async function Page(props: PageProps) {
|
||||
await requireHRDDashboardAccess();
|
||||
|
||||
const searchParams = await props.searchParams;
|
||||
searchParamsCache.parse(searchParams);
|
||||
const search = searchParamsCache.get('search');
|
||||
const company = searchParamsCache.get('company');
|
||||
const department = searchParamsCache.get('department');
|
||||
const position = searchParamsCache.get('position');
|
||||
const status = searchParamsCache.get('status');
|
||||
const sort = searchParamsCache.get('sort');
|
||||
const filters = {
|
||||
page: searchParamsCache.get('page'),
|
||||
limit: searchParamsCache.get('perPage'),
|
||||
...(search ? { search } : {}),
|
||||
...(company ? { company } : {}),
|
||||
...(department ? { department } : {}),
|
||||
...(position ? { position } : {}),
|
||||
...(status ? { status } : {}),
|
||||
...(sort ? { sort } : {})
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<div className='flex min-w-0 flex-1 flex-col gap-4 md:gap-5'>
|
||||
<EmployeeDirectoryHeader />
|
||||
<EmployeeDirectoryListingPage filters={filters} />
|
||||
</div>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user