Merge branch 'dev' into 'main'

Dev

See merge request azizziy/cpost!21
This commit is contained in:
Azizbek Usmonov
2025-05-29 12:57:37 +05:00
2 changed files with 30 additions and 24 deletions

View File

@@ -20,6 +20,7 @@ import { useMyTranslation } from '@/hooks/useMyTranslation';
import { FormValues, RealCreateBoxBodyType, UpdateRealBoxBodyType } from '@/data/real-box/real-box.model'; import { FormValues, RealCreateBoxBodyType, UpdateRealBoxBodyType } from '@/data/real-box/real-box.model';
import get from 'lodash.get'; import get from 'lodash.get';
import useRequest from '@/hooks/useRequest'; import useRequest from '@/hooks/useRequest';
import useInput from '@/hooks/useInput';
const StyledCreateBox = styled(Box)` const StyledCreateBox = styled(Box)`
.item-row { .item-row {
@@ -48,6 +49,7 @@ interface Props {
const DashboardCreateRealBoxPage = ({ initialValues, partiesData }: Props) => { const DashboardCreateRealBoxPage = ({ initialValues, partiesData }: Props) => {
const { user, isAdmin: isAdminUser } = useAuthContext(); const { user, isAdmin: isAdminUser } = useAuthContext();
const editMode = !!initialValues?.id; const editMode = !!initialValues?.id;
const [keyword, handleKeyword] = useState('');
const t = useMyTranslation(); const t = useMyTranslation();
const params = useSearchParams(); const params = useSearchParams();
const { push } = useMyNavigation(); const { push } = useMyNavigation();
@@ -65,6 +67,8 @@ const DashboardCreateRealBoxPage = ({ initialValues, partiesData }: Props) => {
finished: false, finished: false,
}); });
console.log(keyword, "keyword");
const { const {
register, register,
control, control,
@@ -116,6 +120,7 @@ const DashboardCreateRealBoxPage = ({ initialValues, partiesData }: Props) => {
() => () =>
box_requests.getAll({ box_requests.getAll({
partyId: partyId, partyId: partyId,
cargoId: keyword
}), }),
{ {
selectData: (data) => data?.data?.data ?? [], selectData: (data) => data?.data?.data ?? [],
@@ -287,6 +292,7 @@ const DashboardCreateRealBoxPage = ({ initialValues, partiesData }: Props) => {
<AsyncSelect <AsyncSelect
onChange={(newValue: any) => { onChange={(newValue: any) => {
paketField.onChange(newValue?.value ?? ''); paketField.onChange(newValue?.value ?? '');
handleKeyword(newValue?.label ?? '');
}} }}
defaultValue={ defaultValue={
editMode && initialValues?.paketIds?.[index] editMode && initialValues?.paketIds?.[index]
@@ -312,6 +318,7 @@ const DashboardCreateRealBoxPage = ({ initialValues, partiesData }: Props) => {
try { try {
const res = await box_requests.getAll({ const res = await box_requests.getAll({
partyId, partyId,
cargoId: inputValue,
}); });
return res.data.data.data.map((box: any) => ({ return res.data.data.data.map((box: any) => ({
label: box.box_name || box.name || `Box ${box.id}`, label: box.box_name || box.name || `Box ${box.id}`,
@@ -330,35 +337,34 @@ const DashboardCreateRealBoxPage = ({ initialValues, partiesData }: Props) => {
<FormHelperText sx={{ color: 'red' }}>{requiredText}</FormHelperText> <FormHelperText sx={{ color: 'red' }}>{requiredText}</FormHelperText>
)} )}
</Box> </Box>
{fields.length > 1 && ( <BaseIconButton
<Box className="item-row-field"> size="small"
<BaseIconButton colorVariant="icon-error"
size="small" sx={{ flexShrink: 0, height: 'auto', marginTop: 1 }}
colorVariant="icon-error" onClick={() => removePaket(index)}
sx={{ flexShrink: 0, height: 'auto', marginTop: 1 }} >
onClick={() => removePaket(index)} <Close />
> </BaseIconButton>
<Close />
</BaseIconButton>
</Box>
)}
</Box> </Box>
))} ))}
<Stack alignItems="center" mt={2}> <BaseButton
<BaseButton variant="outlined"
sx={{ backgroundColor: '#239D5F' }} onClick={appendPaket}
startIcon={<AddCircleRounded />} startIcon={<AddCircleRounded />}
onClick={appendPaket} >
> {t('add_packet')}
{t('add_more')} </BaseButton>
</BaseButton>
</Stack>
</Stack> </Stack>
</Grid> </Grid>
</Grid> </Grid>
<BaseButton type="submit" colorVariant="blue" loading={loading}> <BaseButton
{editMode ? t('update') : t('create')} variant="contained"
type="submit"
disabled={loading}
fullWidth
>
{editMode ? t('update_box') : t('create_box')}
</BaseButton> </BaseButton>
</Box> </Box>
</StyledCreateBox> </StyledCreateBox>

View File

@@ -54,7 +54,7 @@ const DashboardRealBoxesPage = (props: Props) => {
() => () =>
real_box_requests.getAll({ real_box_requests.getAll({
page: page, page: page,
cargoId: keyword, boxName: keyword,
status: boxStatusFilter, status: boxStatusFilter,
direction: 'desc', direction: 'desc',
sort: 'id', sort: 'id',