fix: place orders in the model
Some checks are pending
it-academy/dry-wash-pl/pipeline/pr-main Build started...
it-academy/dry-wash-pl/pipeline/head This commit looks good

This commit is contained in:
2025-02-08 22:36:30 +03:00
parent ed8ae95436
commit 658e23d4e3
5 changed files with 45 additions and 44 deletions

View File

@@ -19,7 +19,7 @@ import {
import { useTranslation } from 'react-i18next';
import { PhoneIcon } from '@chakra-ui/icons';
import { api } from '../../__data__/service/api';
import { useAddMasterMutation } from '../../__data__/service/api';
import { DrawerInputs } from '../../models/arm/form';
import useShowToast from '../../hooks/useShowToast';
@@ -56,7 +56,7 @@ const MasterDrawer = ({ isOpen, onClose }: MasterDrawerProps) => {
await addMaster(trimMaster);
};
const [addMaster, { error, isSuccess }] = api.useAddMasterMutation();
const [addMaster, { error, isSuccess }] = useAddMasterMutation();
const showToast = useShowToast();
useEffect(() => {

View File

@@ -4,35 +4,8 @@ import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import { getTimeSlot } from '../../lib';
import { Master } from '../../models/api/master';
import { useUpdateOrdersMutation } from '../../__data__/service/api';
const statuses = [
'pending' as const,
'progress' as const,
'working' as const,
'canceled' as const,
'complete' as const,
];
type GetArrItemType<ArrType> =
ArrType extends Array<infer ItemType> ? ItemType : never;
export type OrderProps = {
carNumber?: string;
startWashTime?: string;
endWashTime?: string;
orderDate?: string;
status?: GetArrItemType<typeof statuses>;
phone?: string;
location?: string;
master: Master;
notes: '';
allMasters: Master[];
id: string;
};
type Status = (typeof statuses)[number];
import { OrderArm, Status, statuses } from '../../models/api';
const statusColors: Record<Status, string> = {
pending: 'yellow.100',
@@ -53,7 +26,7 @@ const OrderItem = ({
master,
allMasters,
id,
}: OrderProps) => {
}: OrderArm) => {
const [updateOrders] = useUpdateOrdersMutation();
const { t } = useTranslation('~', {
keyPrefix: 'dry-wash.arm.order',
@@ -78,7 +51,7 @@ const OrderItem = ({
};
const handeChangeStatus = (e: ChangeEvent<HTMLSelectElement>) => {
const status = e.target.value as OrderProps['status'];
const status = e.target.value as OrderArm['status'];
updateOrders({ id, status });
setStatus(status);
};