added cargoType

This commit is contained in:
Samandar Turgunboyev
2025-08-25 19:03:15 +05:00
parent 7c47c1e942
commit dc80d43e15
37 changed files with 2158 additions and 184 deletions

View File

@@ -22,7 +22,7 @@ import EditItemModal from '@/routes/private/items/components/EditItemModal';
import { notifyUnknownError } from '@/services/notification';
import { getBoxStatusStyles, getStatusColor } from '@/theme/getStatusBoxStyles';
import { Add, Check, Circle, Delete, Edit, FilterList, FilterListOff, Search } from '@mui/icons-material';
import { Box, Stack, Typography } from '@mui/material';
import { Box, FormControl, MenuItem, Select, Stack, Typography } from '@mui/material';
import { useEffect, useMemo, useState } from 'react';
import AsyncSelect from 'react-select/async';
@@ -40,6 +40,7 @@ const DashboardGoodsPage = (props: Props) => {
const [partyFilter, setPartyFilter] = useState<{ label: string; value: number } | undefined>(undefined);
const [boxFilter, setBoxFilter] = useState<{ label: string; value: number } | undefined>(undefined);
const [boxStatusFilter, setBoxStatusFilter] = useState<BoxStatus | undefined>(undefined);
const [cargoType, setCargoType] = useState<'AUTO' | 'AVIA'>(user?.role === 'ADMIN' ? 'AVIA' : user?.cargoType || 'AUTO');
const [deleteIds, setDeleteIds] = useState<number[]>([]);
@@ -53,13 +54,14 @@ const DashboardGoodsPage = (props: Props) => {
partyId: partyFilter?.value,
trekId: trackKeyword,
direction: 'desc',
cargoType,
sort: 'id',
}),
{
selectData(data) {
return data.data.data;
},
dependencies: [page, boxStatusFilter, boxFilter, partyFilter],
dependencies: [page, boxStatusFilter, boxFilter, partyFilter, cargoType],
}
);
@@ -133,11 +135,12 @@ const DashboardGoodsPage = (props: Props) => {
}
};
const { data: defaultPartyOptions } = useRequest(() => party_requests.getAll({}), {
const { data: defaultPartyOptions } = useRequest(() => party_requests.getAll({ cargoType }), {
enabled: true,
selectData(data) {
return data.data.data.data.map(p => ({ value: p.id, label: p.name }));
},
dependencies: [cargoType],
placeholderData: [],
});
@@ -145,6 +148,7 @@ const DashboardGoodsPage = (props: Props) => {
() =>
box_requests.getAll({
partyId: partyFilter?.value,
cargoType,
}),
{
enabled: !!partyFilter,
@@ -387,7 +391,22 @@ const DashboardGoodsPage = (props: Props) => {
/>
<BaseInput value={trackKeyword} onChange={handleTrackKeyword} placeholder={t('filter_track_id')} />
{user?.role === 'ADMIN' && (
<FormControl size='small' sx={{ minWidth: 200 }}>
<Select
value={cargoType ?? ''}
onChange={e => {
const value = e.target.value || undefined;
setCargoType(value as 'AVIA' | 'AUTO');
setPage(1);
}}
displayEmpty
>
<MenuItem value='AVIA'>AVIA</MenuItem>
<MenuItem value='AUTO'>AUTO</MenuItem>
</Select>
</FormControl>
)}
<BaseButton colorVariant='gray' startIcon={<FilterListOff />} size='small' onClick={resetFilter}>
{t('reset_filter')}
</BaseButton>