mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
refactor(FE-316): Add submission state to apply filters
This commit is contained in:
@@ -191,6 +191,9 @@ const UniformityTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
const bulkRejectModal = useModal();
|
||||
const filterModal = useModal();
|
||||
|
||||
// ===== SUBMISSION STATE =====
|
||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
||||
|
||||
// ===== FILTER STATE =====
|
||||
const [filterLocation, setFilterLocation] = useState<OptionType | null>(null);
|
||||
const [filterProjectFlock, setFilterProjectFlock] =
|
||||
@@ -311,17 +314,19 @@ const UniformityTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
const basePath = UniformityApi.basePath;
|
||||
const queryParams = new URLSearchParams();
|
||||
|
||||
if (filterProjectFlockKandangId) {
|
||||
queryParams.append(
|
||||
'project_flock_kandang_id',
|
||||
filterProjectFlockKandangId.toString()
|
||||
);
|
||||
}
|
||||
if (filterStartDate) {
|
||||
queryParams.append('start_date', filterStartDate);
|
||||
}
|
||||
if (filterEndDate) {
|
||||
queryParams.append('end_date', filterEndDate);
|
||||
if (isSubmitted) {
|
||||
if (filterProjectFlockKandangId) {
|
||||
queryParams.append(
|
||||
'project_flock_kandang_id',
|
||||
filterProjectFlockKandangId.toString()
|
||||
);
|
||||
}
|
||||
if (filterStartDate) {
|
||||
queryParams.append('start_date', filterStartDate);
|
||||
}
|
||||
if (filterEndDate) {
|
||||
queryParams.append('end_date', filterEndDate);
|
||||
}
|
||||
}
|
||||
|
||||
const tableQueryString = getTableFilterQueryString();
|
||||
@@ -336,6 +341,7 @@ const UniformityTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
const queryString = queryParams.toString();
|
||||
return queryString ? `${basePath}?${queryString}` : basePath;
|
||||
}, [
|
||||
isSubmitted,
|
||||
filterProjectFlockKandangId,
|
||||
filterStartDate,
|
||||
filterEndDate,
|
||||
@@ -383,6 +389,7 @@ const UniformityTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
}, []);
|
||||
|
||||
const handleApplyFilters = useCallback(() => {
|
||||
setIsSubmitted(true);
|
||||
filterModal.closeModal();
|
||||
}, [filterModal]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user