mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into fix/adjustment-issue-13-apr-26
This commit is contained in:
@@ -33,18 +33,18 @@ import { generateReportExpensePDF } from '../export/ReportExpenseExportPDF';
|
|||||||
import { generateReportExpenseExcel } from '../export/ReportExpenseExportXLSX';
|
import { generateReportExpenseExcel } from '../export/ReportExpenseExportXLSX';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import {
|
import {
|
||||||
KandangApi,
|
|
||||||
LocationApi,
|
LocationApi,
|
||||||
NonstockApi,
|
NonstockApi,
|
||||||
SupplierApi,
|
SupplierApi,
|
||||||
} from '@/services/api/master-data';
|
} from '@/services/api/master-data';
|
||||||
import { Supplier } from '@/types/api/master-data/supplier';
|
import { Supplier } from '@/types/api/master-data/supplier';
|
||||||
import { Kandang } from '@/types/api/master-data/kandang';
|
|
||||||
import { Nonstock } from '@/types/api/master-data/nonstock';
|
import { Nonstock } from '@/types/api/master-data/nonstock';
|
||||||
import { ColumnDef } from '@tanstack/react-table';
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
import { httpClient } from '@/services/http/client';
|
import { httpClient } from '@/services/http/client';
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
import ButtonFilter from '@/components/helper/ButtonFilter';
|
import ButtonFilter from '@/components/helper/ButtonFilter';
|
||||||
|
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
|
||||||
|
import { ProjectFlockKandangApi } from '@/services/api/production/project-flock-kandang';
|
||||||
|
|
||||||
interface ReportExpenseTabProps {
|
interface ReportExpenseTabProps {
|
||||||
tabId: string;
|
tabId: string;
|
||||||
@@ -136,7 +136,7 @@ const ReportExpenseTab = ({ tabId }: ReportExpenseTabProps) => {
|
|||||||
options: locationOptions,
|
options: locationOptions,
|
||||||
isLoadingOptions: isLoadingLocations,
|
isLoadingOptions: isLoadingLocations,
|
||||||
loadMore: loadMoreLocations,
|
loadMore: loadMoreLocations,
|
||||||
} = useSelect<Kandang>(LocationApi.basePath, 'id', 'name', 'search');
|
} = useSelect<Location>(LocationApi.basePath, 'id', 'name', 'search');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
setInputValue: setSupplierInputValue,
|
setInputValue: setSupplierInputValue,
|
||||||
@@ -146,14 +146,14 @@ const ReportExpenseTab = ({ tabId }: ReportExpenseTabProps) => {
|
|||||||
} = useSelect<Supplier>(SupplierApi.basePath, 'id', 'name', 'search');
|
} = useSelect<Supplier>(SupplierApi.basePath, 'id', 'name', 'search');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
setInputValue: setKandangInputValue,
|
setInputValue: setProjectFlockKandangInputValue,
|
||||||
options: kandangOptions,
|
options: projectFlockKandangOptions,
|
||||||
isLoadingOptions: isLoadingKandangs,
|
isLoadingOptions: isLoadingProjectFlockKandangs,
|
||||||
loadMore: loadMoreKandangs,
|
loadMore: loadMoreProjectFlockKandangs,
|
||||||
} = useSelect<Kandang>(
|
} = useSelect<ProjectFlockKandang>(
|
||||||
KandangApi.basePath,
|
ProjectFlockKandangApi.basePath,
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name_with_period',
|
||||||
'search',
|
'search',
|
||||||
formik.values.location_id?.value
|
formik.values.location_id?.value
|
||||||
? { location_id: String(formik.values.location_id.value) }
|
? { location_id: String(formik.values.location_id.value) }
|
||||||
@@ -643,14 +643,14 @@ const ReportExpenseTab = ({ tabId }: ReportExpenseTabProps) => {
|
|||||||
<SelectInput
|
<SelectInput
|
||||||
label='Kandang'
|
label='Kandang'
|
||||||
placeholder='Pilih Kandang'
|
placeholder='Pilih Kandang'
|
||||||
options={kandangOptions}
|
options={projectFlockKandangOptions}
|
||||||
isLoading={isLoadingKandangs}
|
isLoading={isLoadingProjectFlockKandangs}
|
||||||
value={kandangValue}
|
value={kandangValue}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
formik.setFieldValue('kandang_id', val);
|
formik.setFieldValue('kandang_id', val);
|
||||||
}}
|
}}
|
||||||
onInputChange={setKandangInputValue}
|
onInputChange={setProjectFlockKandangInputValue}
|
||||||
onMenuScrollToBottom={loadMoreKandangs}
|
onMenuScrollToBottom={loadMoreProjectFlockKandangs}
|
||||||
isClearable
|
isClearable
|
||||||
isDisabled={!formik.values.location_id}
|
isDisabled={!formik.values.location_id}
|
||||||
className={{ wrapper: 'w-full' }}
|
className={{ wrapper: 'w-full' }}
|
||||||
|
|||||||
@@ -43,15 +43,7 @@ export const ProductionResultFilterSchema = yup.object({
|
|||||||
}
|
}
|
||||||
return !!value;
|
return !!value;
|
||||||
}),
|
}),
|
||||||
kandang_id: yup
|
kandang_id: yup.mixed<OptionType>().nullable(),
|
||||||
.mixed<OptionType>()
|
|
||||||
.required('Kandang wajib dipilih')
|
|
||||||
.test('is-not-empty', 'Kandang wajib dipilih', (value) => {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return value.length > 0;
|
|
||||||
}
|
|
||||||
return !!value;
|
|
||||||
}),
|
|
||||||
}) as yup.ObjectSchema<ProductionResultFilterFormType>;
|
}) as yup.ObjectSchema<ProductionResultFilterFormType>;
|
||||||
|
|
||||||
export type ProductionResultFilterValues = yup.InferType<
|
export type ProductionResultFilterValues = yup.InferType<
|
||||||
|
|||||||
+28
-11
@@ -46,6 +46,7 @@ import Modal, { useModal } from '@/components/Modal';
|
|||||||
import { formatNumber } from '@/lib/helper';
|
import { formatNumber } from '@/lib/helper';
|
||||||
import Pagination from '@/components/Pagination';
|
import Pagination from '@/components/Pagination';
|
||||||
import ProductionResultSkeleton from '@/components/pages/report/production-result/skeleton/ProductionResultSkeleton';
|
import ProductionResultSkeleton from '@/components/pages/report/production-result/skeleton/ProductionResultSkeleton';
|
||||||
|
import { ProjectFlock } from '@/types/api/production/project-flock';
|
||||||
|
|
||||||
interface ProductionResultTabProps {
|
interface ProductionResultTabProps {
|
||||||
tabId: string;
|
tabId: string;
|
||||||
@@ -238,6 +239,17 @@ const ProductionResultContent = ({ tabId }: ProductionResultTabProps) => {
|
|||||||
? String(values.kandang_id.value)
|
? String(values.kandang_id.value)
|
||||||
: undefined,
|
: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const selectedProjectFlockKandangRawData = isResponseSuccess(
|
||||||
|
projectFlockKandangsRawData
|
||||||
|
)
|
||||||
|
? projectFlockKandangsRawData.data.find(
|
||||||
|
(item) => item.id === values.kandang_id?.value
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
setSelectedProjectFlockKandang(selectedProjectFlockKandangRawData);
|
||||||
|
|
||||||
filterModal.closeModal();
|
filterModal.closeModal();
|
||||||
setIsSubmitted(true);
|
setIsSubmitted(true);
|
||||||
setPage(1);
|
setPage(1);
|
||||||
@@ -255,6 +267,9 @@ const ProductionResultContent = ({ tabId }: ProductionResultTabProps) => {
|
|||||||
formik.validateForm();
|
formik.validateForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [selectedProjectFlockKandang, setSelectedProjectFlockKandang] =
|
||||||
|
useState<ProjectFlockKandang | undefined>();
|
||||||
|
|
||||||
// ===== OPTIONS =====
|
// ===== OPTIONS =====
|
||||||
const {
|
const {
|
||||||
setInputValue: setAreaInputValue,
|
setInputValue: setAreaInputValue,
|
||||||
@@ -279,7 +294,7 @@ const ProductionResultContent = ({ tabId }: ProductionResultTabProps) => {
|
|||||||
options: projectFlockOptions,
|
options: projectFlockOptions,
|
||||||
isLoadingOptions: isLoadingProjectFlocks,
|
isLoadingOptions: isLoadingProjectFlocks,
|
||||||
loadMore: loadMoreProjectFlocks,
|
loadMore: loadMoreProjectFlocks,
|
||||||
} = useSelect<BaseKandang>(
|
} = useSelect<ProjectFlock>(
|
||||||
ProjectFlockApi.basePath,
|
ProjectFlockApi.basePath,
|
||||||
'id',
|
'id',
|
||||||
'flock_name',
|
'flock_name',
|
||||||
@@ -300,10 +315,11 @@ const ProductionResultContent = ({ tabId }: ProductionResultTabProps) => {
|
|||||||
options: projectFlockKandangOptions,
|
options: projectFlockKandangOptions,
|
||||||
isLoadingOptions: isLoadingProjectFlockKandangs,
|
isLoadingOptions: isLoadingProjectFlockKandangs,
|
||||||
loadMore: loadMoreProjectFlockKandangs,
|
loadMore: loadMoreProjectFlockKandangs,
|
||||||
} = useSelect<BaseKandang>(
|
rawData: projectFlockKandangsRawData,
|
||||||
|
} = useSelect<ProjectFlockKandang>(
|
||||||
ProjectFlockKandangApi.basePath,
|
ProjectFlockKandangApi.basePath,
|
||||||
'id',
|
'id',
|
||||||
'kandang.name',
|
'name_with_period',
|
||||||
'search',
|
'search',
|
||||||
{
|
{
|
||||||
area_id: formik.values.area_id?.value
|
area_id: formik.values.area_id?.value
|
||||||
@@ -359,13 +375,15 @@ const ProductionResultContent = ({ tabId }: ProductionResultTabProps) => {
|
|||||||
([url]: string[]) => httpClient<BaseApiResponse<ProjectFlockKandang[]>>(url)
|
([url]: string[]) => httpClient<BaseApiResponse<ProjectFlockKandang[]>>(url)
|
||||||
);
|
);
|
||||||
|
|
||||||
const projectFlockKandangs = useMemo(
|
const projectFlockKandangs = useMemo(() => {
|
||||||
() =>
|
if (selectedProjectFlockKandang) {
|
||||||
isResponseSuccess(projectFlockKandangsData)
|
return [selectedProjectFlockKandang];
|
||||||
? projectFlockKandangsData.data
|
}
|
||||||
: null,
|
|
||||||
[projectFlockKandangsData]
|
return isResponseSuccess(projectFlockKandangsData)
|
||||||
);
|
? projectFlockKandangsData.data
|
||||||
|
: null;
|
||||||
|
}, [projectFlockKandangsData, selectedProjectFlockKandang]);
|
||||||
|
|
||||||
const projectFlockKandangMetadata = useMemo(
|
const projectFlockKandangMetadata = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -804,7 +822,6 @@ const ProductionResultContent = ({ tabId }: ProductionResultTabProps) => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<SelectInput
|
<SelectInput
|
||||||
required
|
|
||||||
label='Kandang'
|
label='Kandang'
|
||||||
placeholder='Pilih Kandang'
|
placeholder='Pilih Kandang'
|
||||||
options={projectFlockKandangOptions}
|
options={projectFlockKandangOptions}
|
||||||
|
|||||||
Reference in New Issue
Block a user