fix: place orders in the model
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user