"use client"; import React, { useEffect } from "react"; import { PeopleFormData, PeopleSchema, } from "../Pages/people/superusers/peopleschema1"; import PeoplePageForm1 from "../Pages/people/superusers/peopleform1"; import PeoplePage1 from "../Pages/people/superusers/peoplepage1"; import PeopleInfo1 from "../Pages/people/superusers/peopleinfo1"; import { peopleList } from "@/apicalls/people/people"; interface Pagination { page: number; size: number; totalCount: number; allCount: number; totalPages: number; orderField: string[]; orderType: string[]; pageCount: number; } const defaultPagination: Pagination = { page: 1, size: 1, totalCount: 0, allCount: 0, totalPages: 0, orderField: ["uu_id"], orderType: ["asc"], pageCount: 0, }; function app000003() { const [modifyEnable, setModifyEnable] = React.useState(false); const [isCreate, setIsCreate] = React.useState(false); const [selectedId, setSelectedId] = React.useState(null); const [tableData, setTableData] = React.useState([]); const [pagination, setPagination] = React.useState(defaultPagination); const fecthData = async ({ // Add any parameters if needed page = 1, pageSize = 10, orderBy = ["asc"], orderType = ["uu_id"], query = {}, }) => { // Simulate an API call const result = await peopleList({ page, size: pageSize, orderField: orderType, orderType: orderBy, query: query, }); setTableData(result?.data || []); setPagination(result?.pagination || {}); }; const fetchDataRef = React.useCallback(({ page = 1, pageSize = 10, orderBy = ["asc"], orderType = ["uu_id"], query = {}, }) => { peopleList({ page, size: pageSize, orderField: orderType, orderType: orderBy, query: query, }).then(result => { setTableData(result?.data || []); setPagination(result?.pagination || {}); }); }, []); useEffect(() => { const timer = setTimeout(() => { fetchDataRef({ page: pagination.page, pageSize: pagination.size, orderBy: pagination.orderField, orderType: pagination.orderType, query: {}, }); }, 300); // 300ms debounce return () => clearTimeout(timer); }, [pagination.page, pagination.size, fetchDataRef]); const onSubmit = (data: PeopleFormData) => { console.log("Form data:", data); // Submit to API or do other operations }; const handleUpdateModify = (uuid: string) => { setSelectedId(uuid); setModifyEnable(false); }; const handleView = (uuid: string) => { setSelectedId(uuid); setModifyEnable(true); }; return ( <>
setIsCreate(true)} /> {!isCreate ? (
{!selectedId ? ( ) : ( item.uu_id === selectedId) || {}} onSubmit={onSubmit} modifyEnable={modifyEnable} setSelectedId={() => setSelectedId(null)} /> )}
) : ( <> setIsCreate(null)} /> )}
); } export default app000003;