diff --git a/src/api/master-plant-section.jsx b/src/api/master-plant-section.jsx index 5f5f266..594723b 100644 --- a/src/api/master-plant-section.jsx +++ b/src/api/master-plant-section.jsx @@ -2,12 +2,15 @@ import { SendRequest } from '../components/Global/ApiRequest'; const getAllPlantSection = async (queryParams) => { try { + // Ensure queryParams is URLSearchParams object + const params = queryParams instanceof URLSearchParams ? queryParams : new URLSearchParams(queryParams); + const response = await SendRequest({ method: 'get', - prefix: `plant-sub-section?${queryParams.toString()}`, + prefix: `plant-sub-section?${params.toString()}`, }); console.log('getAllPlantSection response:', response); - console.log('Query params:', queryParams.toString()); + console.log('Query params:', params.toString()); // Backend response structure: // { @@ -23,17 +26,23 @@ const getAllPlantSection = async (queryParams) => { // Check if backend returns paginated data if (response.paging) { - const totalData = response.data?.[0]?.total_data || response.rows || response.data?.length || 0; + // Extract total_data from first record, or fallback to total_limit or rows + const totalData = response.data?.[0]?.total_data || response.paging.total_limit || response.rows || response.data?.length || 0; + + // Use total_limit as total count, handle 0 values for page/limit + const currentPage = response.paging.current_page || 1; + const currentLimit = response.paging.current_limit || 10; + const totalPages = response.paging.total_page || Math.ceil(totalData / currentLimit); return { status: response.statusCode || 200, data: { data: response.data || [], paging: { - page: response.paging.current_page || 1, - limit: response.paging.current_limit || 10, + page: currentPage, + limit: currentLimit, total: totalData, - page_total: response.paging.total_page || Math.ceil(totalData / (response.paging.current_limit || 10)) + page_total: totalPages }, total: totalData } @@ -41,9 +50,9 @@ const getAllPlantSection = async (queryParams) => { } // Fallback: If backend returns all data without pagination (old behavior) - const params = Object.fromEntries(queryParams); - const currentPage = parseInt(params.page) || 1; - const currentLimit = parseInt(params.limit) || 10; + const parsedParams = Object.fromEntries(params); + const currentPage = parseInt(parsedParams.page) || 1; + const currentLimit = parseInt(parsedParams.limit) || 10; const allData = response.data || []; const totalData = allData.length; diff --git a/src/pages/master/plantSection/component/DetailPlantSection.jsx b/src/pages/master/plantSection/component/DetailPlantSection.jsx index 3a3e1a6..b0ce132 100644 --- a/src/pages/master/plantSection/component/DetailPlantSection.jsx +++ b/src/pages/master/plantSection/component/DetailPlantSection.jsx @@ -64,39 +64,7 @@ const DetailPlantSection = ({ visible, onCancel, onOk, form, editingKey, readOnl rules={[{ required: true, message: 'Silakan masukkan nama sub section!' }]} style={{ marginBottom: 0 }} > - - - -
- Nama Plant - * - - - -
-
- Lokasi Plant - * - - - -
-
- Deskripsi - - +
diff --git a/src/pages/master/plantSection/component/ListPlantSection.jsx b/src/pages/master/plantSection/component/ListPlantSection.jsx index 743b737..a6a812c 100644 --- a/src/pages/master/plantSection/component/ListPlantSection.jsx +++ b/src/pages/master/plantSection/component/ListPlantSection.jsx @@ -26,38 +26,26 @@ const ListPlantSection = ({ title: 'No', dataIndex: 'sub_section_id', key: 'sub_section_id', - width: '10%', + width: '8%', render: (text, record, index) => index + 1, }, + { + title: 'Kode Sub Section', + dataIndex: 'sub_section_code', + key: 'sub_section_code', + width: '20%', + }, { title: 'Nama Sub Section', dataIndex: 'sub_section_name', key: 'sub_section_name', + width: '35%', }, - { - title: 'Kode Plant', - dataIndex: 'kode_plant', - key: 'kode_plant', - }, - { - title: 'Nama Plant', - dataIndex: 'nama_plant', - key: 'nama_plant', - }, - { - title: 'Lokasi Plant', - dataIndex: 'lokasi_plant', - key: 'lokasi_plant', - }, - { - title: 'Deskripsi', - dataIndex: 'deskripsi', - key: 'deskripsi', - }, + { title: 'Aksi', key: 'action', - width: '15%', + width: '10%', render: (_, record) => (