mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +00:00
fix(FE): implement lazy load select project flock
This commit is contained in:
@@ -102,34 +102,47 @@ const ProjectFlockForm = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Fetch Data
|
// Fetch Data
|
||||||
const { isLoadingOptions: isLoadingFlocks, options: optionsFlock } =
|
const {
|
||||||
useSelect(FlockApi.basePath, 'id', 'name');
|
setInputValue: setInputValueFlock,
|
||||||
|
isLoadingOptions: isLoadingFlocks,
|
||||||
|
options: optionsFlock,
|
||||||
|
loadMore: loadMoreFlock,
|
||||||
|
} = useSelect(FlockApi.basePath, 'id', 'name', '', {
|
||||||
|
project_category: selectedCategory,
|
||||||
|
});
|
||||||
|
|
||||||
const { options: optionsArea, isLoadingOptions: isLoadingAreas } = useSelect(
|
const {
|
||||||
AreaApi.basePath,
|
setInputValue: setInputValueArea,
|
||||||
'id',
|
options: optionsArea,
|
||||||
'name'
|
isLoadingOptions: isLoadingAreas,
|
||||||
);
|
loadMore: loadMoreArea,
|
||||||
|
} = useSelect(AreaApi.basePath, 'id', 'name');
|
||||||
|
|
||||||
const { options: optionsLocation, isLoadingOptions: isLoadingLocations } =
|
const {
|
||||||
useSelect(LocationApi.basePath, 'id', 'name', '', {
|
options: optionsLocation,
|
||||||
area_id:
|
isLoadingOptions: isLoadingLocations,
|
||||||
selectedArea != ''
|
setInputValue: setInputValueLocation,
|
||||||
? selectedArea
|
loadMore: loadMoreLocation,
|
||||||
: ((initialValues?.area?.id ?? '') as string),
|
} = useSelect(LocationApi.basePath, 'id', 'name', '', {
|
||||||
});
|
area_id:
|
||||||
|
selectedArea != ''
|
||||||
|
? selectedArea
|
||||||
|
: ((initialValues?.area?.id ?? '') as string),
|
||||||
|
});
|
||||||
|
|
||||||
const { options: optionsFcr, isLoadingOptions: isLoadingFcrs } = useSelect(
|
const {
|
||||||
FcrApi.basePath,
|
options: optionsFcr,
|
||||||
'id',
|
isLoadingOptions: isLoadingFcrs,
|
||||||
'name'
|
setInputValue: setInputValueFcr,
|
||||||
);
|
loadMore: loadMoreFcr,
|
||||||
|
} = useSelect(FcrApi.basePath, 'id', 'name');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
options: optionsProductionStandards,
|
options: optionsProductionStandards,
|
||||||
isLoadingOptions: isLoadingProductionStandards,
|
isLoadingOptions: isLoadingProductionStandards,
|
||||||
|
setInputValue: setInputValueProductionStandard,
|
||||||
|
loadMore: loadMoreProductionStandard,
|
||||||
} = useSelect(ProductionStandardApi.basePath, 'id', 'name', '', {
|
} = useSelect(ProductionStandardApi.basePath, 'id', 'name', '', {
|
||||||
search: '',
|
|
||||||
project_category: selectedCategory,
|
project_category: selectedCategory,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -153,6 +166,8 @@ const ProjectFlockForm = ({
|
|||||||
options: optionsNonstock,
|
options: optionsNonstock,
|
||||||
rawData: nonstocks,
|
rawData: nonstocks,
|
||||||
isLoadingOptions: isLoadingNonstocks,
|
isLoadingOptions: isLoadingNonstocks,
|
||||||
|
setInputValue: setInputValueNonstock,
|
||||||
|
loadMore: loadMoreNonstock,
|
||||||
} = useSelect<Nonstock>(NonstockApi.basePath, 'id', 'name');
|
} = useSelect<Nonstock>(NonstockApi.basePath, 'id', 'name');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -722,6 +737,8 @@ const ProjectFlockForm = ({
|
|||||||
formik.touched.area_id && Boolean(formik.errors.area_id)
|
formik.touched.area_id && Boolean(formik.errors.area_id)
|
||||||
}
|
}
|
||||||
errorMessage={formik.errors.area_id as string}
|
errorMessage={formik.errors.area_id as string}
|
||||||
|
onInputChange={setInputValueArea}
|
||||||
|
onMenuScrollToBottom={loadMoreArea}
|
||||||
isClearable
|
isClearable
|
||||||
isDisabled={formType != 'add'}
|
isDisabled={formType != 'add'}
|
||||||
/>
|
/>
|
||||||
@@ -740,6 +757,8 @@ const ProjectFlockForm = ({
|
|||||||
formik.touched.location_id &&
|
formik.touched.location_id &&
|
||||||
Boolean(formik.errors.location_id)
|
Boolean(formik.errors.location_id)
|
||||||
}
|
}
|
||||||
|
onInputChange={setInputValueLocation}
|
||||||
|
onMenuScrollToBottom={loadMoreLocation}
|
||||||
errorMessage={formik.errors.location_id as string}
|
errorMessage={formik.errors.location_id as string}
|
||||||
isClearable
|
isClearable
|
||||||
isDisabled={formType != 'add' || disabledLocation}
|
isDisabled={formType != 'add' || disabledLocation}
|
||||||
@@ -766,6 +785,8 @@ const ProjectFlockForm = ({
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
options={optionsFlock}
|
options={optionsFlock}
|
||||||
|
onInputChange={setInputValueFlock}
|
||||||
|
onMenuScrollToBottom={loadMoreFlock}
|
||||||
isLoading={isLoadingFlocks}
|
isLoading={isLoadingFlocks}
|
||||||
isError={
|
isError={
|
||||||
formik.touched.flock_name && Boolean(formik.errors.flock_name)
|
formik.touched.flock_name && Boolean(formik.errors.flock_name)
|
||||||
@@ -781,6 +802,8 @@ const ProjectFlockForm = ({
|
|||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
optionChangeHandler(val, 'fcr');
|
optionChangeHandler(val, 'fcr');
|
||||||
}}
|
}}
|
||||||
|
onInputChange={setInputValueFcr}
|
||||||
|
onMenuScrollToBottom={loadMoreFcr}
|
||||||
options={optionsFcr}
|
options={optionsFcr}
|
||||||
isLoading={isLoadingFcrs}
|
isLoading={isLoadingFcrs}
|
||||||
isError={formik.touched.fcr_id && Boolean(formik.errors.fcr_id)}
|
isError={formik.touched.fcr_id && Boolean(formik.errors.fcr_id)}
|
||||||
@@ -808,6 +831,8 @@ const ProjectFlockForm = ({
|
|||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
optionChangeHandler(val, 'production_standard');
|
optionChangeHandler(val, 'production_standard');
|
||||||
}}
|
}}
|
||||||
|
onInputChange={setInputValueProductionStandard}
|
||||||
|
onMenuScrollToBottom={loadMoreProductionStandard}
|
||||||
options={optionsProductionStandards}
|
options={optionsProductionStandards}
|
||||||
isLoading={isLoadingProductionStandards}
|
isLoading={isLoadingProductionStandards}
|
||||||
isError={
|
isError={
|
||||||
@@ -892,6 +917,8 @@ const ProjectFlockForm = ({
|
|||||||
isLoading={isLoadingNonstocks}
|
isLoading={isLoadingNonstocks}
|
||||||
placeholder='Pilih barang non stock'
|
placeholder='Pilih barang non stock'
|
||||||
value={formik.values.project_budgets[index].nonstock}
|
value={formik.values.project_budgets[index].nonstock}
|
||||||
|
onInputChange={setInputValueNonstock}
|
||||||
|
onMenuScrollToBottom={loadMoreNonstock}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
const updatedBudgets = [
|
const updatedBudgets = [
|
||||||
...formik.values.project_budgets,
|
...formik.values.project_budgets,
|
||||||
|
|||||||
Reference in New Issue
Block a user