diff --git a/src/app/(dashboard)/layout.tsx b/src/app/(dashboard)/layout.tsx
index d7868a0..67225e6 100644
--- a/src/app/(dashboard)/layout.tsx
+++ b/src/app/(dashboard)/layout.tsx
@@ -1,6 +1,6 @@
"use client"
import { DocumentCurrencyDollarIcon, HomeIcon, UsersIcon } from "@heroicons/react/24/outline";
-import { InputLabel, MenuItem, Select, TextField } from "@mui/material";
+import { Autocomplete, InputLabel, MenuItem, Select, TextField } from "@mui/material";
import { DatePicker } from "@mui/x-date-pickers";
import { BarChart2, CircleDollarSign, LogOut, RefreshCcw } from "lucide-react";
import Link from "next/link";
@@ -13,6 +13,7 @@ import { Filter } from "@/services/types";
import { useAppDispatch, useAppSelector } from "@/lib/hooks";
import { setFilter } from "@/lib/slice/filter";
import { format } from "date-fns";
+import { useGetFilterOptionsQuery } from "@/services/api";
export default function DashboardLayout({children}:{children: React.ReactNode}) {
@@ -20,6 +21,7 @@ export default function DashboardLayout({children}:{children: React.ReactNode})
const pathname = usePathname();
const dispatch = useAppDispatch();
const filter = useAppSelector((state) => state.filter.filter);
+ const {data: filterOptions } = useGetFilterOptionsQuery(filter);
return (
@@ -81,7 +83,7 @@ export default function DashboardLayout({children}:{children: React.ReactNode})
CN
-
+
dispatch(setFilter({...filter, end_date: format(date ?? new Date(), "yyyy-MM-dd")}))}
/>
-
-
-
-
-
-
-
+
+
option.name}
+ renderInput={(params) => }
+ onChange={(e, value) => dispatch(setFilter({...filter, organization_code: value?.codes ?? ""}))}
+ />
diff --git a/src/services/api.ts b/src/services/api.ts
index e3c17f5..a2c53d8 100644
--- a/src/services/api.ts
+++ b/src/services/api.ts
@@ -1,10 +1,18 @@
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
-import { AttendanceRange, AttendanceSummary, EmployeeSummary, MonthlyAttendance, MonthlyEmployee, ResignationCategory, ResignationReason, ResignationType as ResignationType, ResignSummary } from './types'
+import { AttendanceRange, AttendanceSummary, EmployeeSummary, FilterOptions, MonthlyAttendance, MonthlyEmployee, ResignationCategory, ResignationReason, ResignationType as ResignationType, ResignSummary } from './types'
import { Response , Filter} from './types'
export const api = createApi({
- baseQuery: fetchBaseQuery({ baseUrl: 'https://erp.julongindonesia.com:8443/api' }),
+ baseQuery: fetchBaseQuery({ baseUrl: 'http://localhost:8080' }),
endpoints: (builder) => ({
+ getFilterOptions: builder.query({
+ query: (params) => ({ url: '/dashboard/filter-options', params }),
+ transformResponse: (response: Response) => {
+ if (response.status === "success") {
+ return response.data!;
+ }
+ },
+ }),
getEmployeeSummary: builder.query({
query: (params) => ({ url: '/dashboard/employee', params }),
transformResponse: (response: Response) => {
@@ -80,6 +88,6 @@ export const api = createApi({
}),
})
-export const { useGetEmployeeSummaryQuery, useGetMonthlyEmployeeQuery, useGetMonthlyAttendanceQuery,
+export const { useGetFilterOptionsQuery, useGetEmployeeSummaryQuery, useGetMonthlyEmployeeQuery, useGetMonthlyAttendanceQuery,
useGetOrganizationAttendanceQuery, useGetAttendanceRangeQuery, useGetResignSummaryQuery, useGetResignTypeQuery,
useGetResignCategoryQuery, useGetResignReasonQuery } = api
\ No newline at end of file
diff --git a/src/services/types.ts b/src/services/types.ts
index d6e39ee..708259d 100644
--- a/src/services/types.ts
+++ b/src/services/types.ts
@@ -19,6 +19,20 @@ export interface Filter{
job_name?: string;
}
+export interface FilterOptions{
+ regions: {
+ name: string;
+ codes: string;
+ }[];
+ organizations: {
+ code: string;
+ name: string;
+ }[];
+ estates: {
+ name: string;
+ }[];
+}
+
export type EmployeeSummary = {
id: string;
organization_code: string;