Compare commits
8 Commits
15f08bffe8
...
a00aaff29d
Author | SHA1 | Date | |
---|---|---|---|
a00aaff29d | |||
ad1f948641 | |||
bd66f00b81 | |||
9a20c9f098 | |||
d48f8011c1 | |||
f2319542e7 | |||
3fb01392f0 | |||
1dd14caed2 |
1
__mocks__/file-mock.ts
Normal file
1
__mocks__/file-mock.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = 'file';
|
7
babel.config.js
Normal file
7
babel.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
presets: [
|
||||||
|
'@babel/preset-env',
|
||||||
|
'@babel/preset-typescript',
|
||||||
|
['@babel/preset-react', { runtime: 'automatic' }],
|
||||||
|
],
|
||||||
|
};
|
@ -1,12 +1,13 @@
|
|||||||
import globals from "globals";
|
import globals from 'globals';
|
||||||
import pluginJs from "@eslint/js";
|
import pluginJs from '@eslint/js';
|
||||||
import tseslint from "typescript-eslint";
|
import tseslint from 'typescript-eslint';
|
||||||
import pluginReact from "eslint-plugin-react";
|
import pluginReact from 'eslint-plugin-react';
|
||||||
import stylistic from '@stylistic/eslint-plugin';
|
import stylistic from '@stylistic/eslint-plugin';
|
||||||
import pluginImport from 'eslint-plugin-import';
|
import pluginImport from 'eslint-plugin-import';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{ files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] },
|
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
|
||||||
|
|
||||||
{ languageOptions: { globals: globals.browser } },
|
{ languageOptions: { globals: globals.browser } },
|
||||||
pluginJs.configs.recommended,
|
pluginJs.configs.recommended,
|
||||||
...tseslint.configs.recommended,
|
...tseslint.configs.recommended,
|
||||||
@ -14,35 +15,38 @@ export default [
|
|||||||
{
|
{
|
||||||
plugins: {
|
plugins: {
|
||||||
'@stylistic': stylistic,
|
'@stylistic': stylistic,
|
||||||
'import': pluginImport,
|
import: pluginImport,
|
||||||
},
|
},
|
||||||
"rules": {
|
rules: {
|
||||||
"no-unused-vars": "off",
|
'no-unused-vars': 'off',
|
||||||
"@typescript-eslint/no-unused-vars": [
|
'@typescript-eslint/no-unused-vars': [
|
||||||
"warn", // or "error"
|
'warn', // or "error"
|
||||||
{
|
{
|
||||||
"argsIgnorePattern": "^_",
|
argsIgnorePattern: '^_',
|
||||||
"varsIgnorePattern": "^_",
|
varsIgnorePattern: '^_',
|
||||||
"caughtErrorsIgnorePattern": "^_"
|
caughtErrorsIgnorePattern: '^_',
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
"sort-imports": ["off"],
|
'sort-imports': ['off'],
|
||||||
"import/order": [
|
'import/order': [
|
||||||
"error",
|
'error',
|
||||||
{
|
{
|
||||||
"groups": [
|
groups: [
|
||||||
"builtin",
|
'builtin',
|
||||||
"external",
|
'external',
|
||||||
"internal",
|
'internal',
|
||||||
"parent",
|
'parent',
|
||||||
["sibling", "index"]
|
['sibling', 'index'],
|
||||||
],
|
],
|
||||||
"newlines-between": "always",
|
'newlines-between': 'always',
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
semi: ["error", "always"],
|
semi: ['error', 'always'],
|
||||||
'@stylistic/indent': ['error', 2],
|
'@stylistic/indent': ['error', 2],
|
||||||
'react/prop-types': 'off'
|
'react/prop-types': 'off',
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
ignores: ['babel.config.js'],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
17
jest-preset-it/jest-preset.ts
Normal file
17
jest-preset-it/jest-preset.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
module.exports = {
|
||||||
|
transform: {
|
||||||
|
'^.+\\.tsx?$': 'babel-jest',
|
||||||
|
},
|
||||||
|
coverageProvider: 'v8',
|
||||||
|
coverageDirectory: 'coverage',
|
||||||
|
collectCoverageFrom: ['**/src/**/*.{ts,tsx}', '!**/src/app.tsx'],
|
||||||
|
collectCoverage: true,
|
||||||
|
clearMocks: true,
|
||||||
|
moduleNameMapper: {
|
||||||
|
'\\.(svg|webp)$': '<rootDir>/__mocks__/file',
|
||||||
|
},
|
||||||
|
testEnvironmentOptions: {
|
||||||
|
customExportConditions: [''],
|
||||||
|
},
|
||||||
|
testEnvironment: 'jest-fixed-jsdom',
|
||||||
|
};
|
@ -86,6 +86,15 @@
|
|||||||
"dry-wash.arm.master.drawer.inputPhone.placeholder": "Enter Phone Number",
|
"dry-wash.arm.master.drawer.inputPhone.placeholder": "Enter Phone Number",
|
||||||
"dry-wash.arm.master.drawer.button.save": "Save",
|
"dry-wash.arm.master.drawer.button.save": "Save",
|
||||||
"dry-wash.arm.master.drawer.button.cancel": "Cancel",
|
"dry-wash.arm.master.drawer.button.cancel": "Cancel",
|
||||||
|
"dry-wash.arm.master.drawer.toast.create-master": "Master created",
|
||||||
|
"dry-wash.arm.master.drawer.toast.error.empty-fields": "Fields cannot be empty",
|
||||||
|
"dry-wash.arm.master.drawer.toast.error.base": "Error",
|
||||||
|
"dry-wash.arm.master.drawer.toast.error.create-master": "Error creating master",
|
||||||
|
"dry-wash.arm.master.drawer.toast.error.create-master-details": "Failed to add master. Please try again",
|
||||||
|
"dry-wash.arm.master.drawer.form.name.required": "Master name is required",
|
||||||
|
"dry-wash.arm.master.drawer.form.phone.required": "Phone number is required",
|
||||||
|
"dry-wash.arm.master.drawer.form.phone.pattern": "Invalid phone number",
|
||||||
|
"dry-wash.arm.master.drawer.form.name.minLength": "Name must contain at least 2 characters",
|
||||||
"dry-wash.arm.master.sideBar.orders": "Orders",
|
"dry-wash.arm.master.sideBar.orders": "Orders",
|
||||||
"dry-wash.arm.master.sideBar.master": "Masters",
|
"dry-wash.arm.master.sideBar.master": "Masters",
|
||||||
"dry-wash.arm.master.sideBar.title": "Dry Master",
|
"dry-wash.arm.master.sideBar.title": "Dry Master",
|
||||||
|
@ -36,6 +36,15 @@
|
|||||||
"dry-wash.arm.master.drawer.inputPhone.placeholder": "Введите номер телефона",
|
"dry-wash.arm.master.drawer.inputPhone.placeholder": "Введите номер телефона",
|
||||||
"dry-wash.arm.master.drawer.button.save": "Сохранить",
|
"dry-wash.arm.master.drawer.button.save": "Сохранить",
|
||||||
"dry-wash.arm.master.drawer.button.cancel": "Отменить",
|
"dry-wash.arm.master.drawer.button.cancel": "Отменить",
|
||||||
|
"dry-wash.arm.master.drawer.toast.create-master": "Мастер создан",
|
||||||
|
"dry-wash.arm.master.drawer.toast.error.empty-fields": "Поля не могут быть пустыми",
|
||||||
|
"dry-wash.arm.master.drawer.toast.error.base": "Ошибка",
|
||||||
|
"dry-wash.arm.master.drawer.toast.error.create-master": "Ошибка при создании мастера",
|
||||||
|
"dry-wash.arm.master.drawer.toast.error.create-master-details": "Не удалось добавить мастера. Попробуйте еще раз",
|
||||||
|
"dry-wash.arm.master.drawer.form.name.required": "Имя мастера обязательно",
|
||||||
|
"dry-wash.arm.master.drawer.form.phone.required": "Телефон обязателен",
|
||||||
|
"dry-wash.arm.master.drawer.form.phone.pattern": "Некорректный номер телефона",
|
||||||
|
"dry-wash.arm.master.drawer.form.name.minLength": "Имя должно содержать минимум 2 символа",
|
||||||
"dry-wash.arm.master.sideBar.orders": "Заказы",
|
"dry-wash.arm.master.sideBar.orders": "Заказы",
|
||||||
"dry-wash.arm.master.sideBar.master": "Мастера",
|
"dry-wash.arm.master.sideBar.master": "Мастера",
|
||||||
"dry-wash.arm.master.sideBar.title": "Сухой мастер",
|
"dry-wash.arm.master.sideBar.title": "Сухой мастер",
|
||||||
|
5276
package-lock.json
generated
5276
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -4,7 +4,7 @@
|
|||||||
"description": "<a id=\"readme-top\"></a>",
|
"description": "<a id=\"readme-top\"></a>",
|
||||||
"main": "./src/index.tsx",
|
"main": "./src/index.tsx",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "jest -u",
|
||||||
"start": "brojs server --port=8099 --with-open-browser",
|
"start": "brojs server --port=8099 --with-open-browser",
|
||||||
"build": "npm run clean && brojs build --dev",
|
"build": "npm run clean && brojs build --dev",
|
||||||
"build:prod": "npm run clean && brojs build",
|
"build:prod": "npm run clean && brojs build",
|
||||||
@ -18,6 +18,10 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@brojs/cli": "^1.8.4",
|
"@brojs/cli": "^1.8.4",
|
||||||
|
"@babel/core": "^7.26.7",
|
||||||
|
"@babel/preset-env": "^7.26.7",
|
||||||
|
"@babel/preset-react": "^7.26.3",
|
||||||
|
"@babel/preset-typescript": "^7.26.0",
|
||||||
"@chakra-ui/icons": "^2.2.4",
|
"@chakra-ui/icons": "^2.2.4",
|
||||||
"@chakra-ui/react": "^2.10.5",
|
"@chakra-ui/react": "^2.10.5",
|
||||||
"@emotion/react": "^11.4.1",
|
"@emotion/react": "^11.4.1",
|
||||||
@ -26,12 +30,19 @@
|
|||||||
"@lottiefiles/react-lottie-player": "^3.5.4",
|
"@lottiefiles/react-lottie-player": "^3.5.4",
|
||||||
"@pbe/react-yandex-maps": "^1.2.5",
|
"@pbe/react-yandex-maps": "^1.2.5",
|
||||||
"@reduxjs/toolkit": "^2.5.0",
|
"@reduxjs/toolkit": "^2.5.0",
|
||||||
|
"@testing-library/dom": "^10.4.0",
|
||||||
|
"@testing-library/react": "^16.2.0",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
|
"babel-jest": "^29.7.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"express": "^4.21.1",
|
"express": "^4.21.1",
|
||||||
"framer-motion": "^6.2.8",
|
"framer-motion": "^6.2.8",
|
||||||
"i18next": "^23.16.4",
|
"i18next": "^23.16.4",
|
||||||
|
"jest": "^29.7.0",
|
||||||
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
|
"jest-fixed-jsdom": "^0.0.9",
|
||||||
"keycloak-js": "^23.0.7",
|
"keycloak-js": "^23.0.7",
|
||||||
|
"msw": "^2.7.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-hook-form": "^7.53.2",
|
"react-hook-form": "^7.53.2",
|
||||||
@ -39,7 +50,9 @@
|
|||||||
"react-icons": "^5.3.0",
|
"react-icons": "^5.3.0",
|
||||||
"react-phone-number-input": "^3.4.9",
|
"react-phone-number-input": "^3.4.9",
|
||||||
"react-redux": "^9.2.0",
|
"react-redux": "^9.2.0",
|
||||||
"react-router-dom": "^6.27.0"
|
"react-router-dom": "^6.27.0",
|
||||||
|
"ts-jest": "^29.2.5",
|
||||||
|
"ts-node": "^10.9.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.14.0",
|
"@eslint/js": "^9.14.0",
|
||||||
@ -50,6 +63,10 @@
|
|||||||
"eslint-plugin-react": "^7.37.2",
|
"eslint-plugin-react": "^7.37.2",
|
||||||
"globals": "^15.11.0",
|
"globals": "^15.11.0",
|
||||||
"prettier": "3.3.3",
|
"prettier": "3.3.3",
|
||||||
|
"typescript": "^5.7.3",
|
||||||
"typescript-eslint": "^8.12.2"
|
"typescript-eslint": "^8.12.2"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"preset": "./jest-preset-it/jest-preset.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,52 @@
|
|||||||
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
||||||
import { getConfigValue } from '@brojs/cli';
|
import { getConfigValue } from '@brojs/cli';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { Master } from '../../models/api/master';
|
import { Master } from '../../models/api/master';
|
||||||
|
import { OrderProps } from '../../components/OrderItem/OrderItem';
|
||||||
|
|
||||||
import { extractBodyFromResponse } from './utils';
|
import { extractBodyFromResponse } from './utils';
|
||||||
|
|
||||||
|
export type UpdateMasterPayload = Required<Pick<Master, 'id'>> &
|
||||||
|
Partial<Omit<Master, 'id'>>;
|
||||||
|
|
||||||
|
type UpdateOrderProps = Required<Pick<OrderProps, 'id'>> &
|
||||||
|
Partial<Pick<OrderProps, 'status' | 'notes'>> & {
|
||||||
|
master?: string;
|
||||||
|
};
|
||||||
|
|
||||||
export const api = createApi({
|
export const api = createApi({
|
||||||
reducerPath: 'api',
|
reducerPath: 'api',
|
||||||
baseQuery: fetchBaseQuery({ baseUrl: getConfigValue('dry-wash.api') }),
|
baseQuery: fetchBaseQuery({ baseUrl: getConfigValue('dry-wash.api') }),
|
||||||
tagTypes: ['Masters'],
|
tagTypes: ['Masters', 'Orders'],
|
||||||
endpoints: (builder) => ({
|
endpoints: (builder) => ({
|
||||||
getMasters: builder.query<Master[], void>({
|
getMasters: builder.query<Master[], void>({
|
||||||
query: () => ({ url: '/arm/masters' }),
|
query: () => ({ url: '/arm/masters' }),
|
||||||
transformResponse: extractBodyFromResponse<Master[]>,
|
transformResponse: extractBodyFromResponse<Master[]>,
|
||||||
providesTags: ['Masters'],
|
providesTags: ['Masters'],
|
||||||
}),
|
}),
|
||||||
|
updateOrders: builder.mutation<void, UpdateOrderProps>({
|
||||||
|
query: ({ id, status, notes, master }) => ({
|
||||||
|
url: `/order/${id}`,
|
||||||
|
method: 'PATCH',
|
||||||
|
body: { status, notes, master },
|
||||||
|
}),
|
||||||
|
invalidatesTags: ['Orders'],
|
||||||
|
}),
|
||||||
|
getOrders: builder.query<OrderProps[], { date: Date }>({
|
||||||
|
query: ({ date }) => {
|
||||||
|
const startDate = dayjs(date).startOf('day').toISOString();
|
||||||
|
const endDate = dayjs(date).endOf('day').toISOString();
|
||||||
|
return {
|
||||||
|
url: '/arm/orders',
|
||||||
|
method: 'POST',
|
||||||
|
body: { startDate, endDate },
|
||||||
|
};
|
||||||
|
},
|
||||||
|
transformResponse: extractBodyFromResponse<OrderProps[]>,
|
||||||
|
providesTags: ['Orders'],
|
||||||
|
}),
|
||||||
|
|
||||||
addMaster: builder.mutation<void, Pick<Master, 'name' | 'phone'>>({
|
addMaster: builder.mutation<void, Pick<Master, 'name' | 'phone'>>({
|
||||||
query: (master) => ({
|
query: (master) => ({
|
||||||
url: '/arm/masters',
|
url: '/arm/masters',
|
||||||
@ -23,5 +55,29 @@ export const api = createApi({
|
|||||||
}),
|
}),
|
||||||
invalidatesTags: ['Masters'],
|
invalidatesTags: ['Masters'],
|
||||||
}),
|
}),
|
||||||
|
deleteMaster: builder.mutation<void, { id: string }>({
|
||||||
|
query: ({ id }) => ({
|
||||||
|
url: `/arm/masters/${id}`,
|
||||||
|
method: 'DELETE',
|
||||||
|
}),
|
||||||
|
invalidatesTags: ['Masters'],
|
||||||
|
}),
|
||||||
|
updateMaster: builder.mutation<void, UpdateMasterPayload>({
|
||||||
|
query: ({ id, name, phone }) => ({
|
||||||
|
url: `/arm/masters/${id}`,
|
||||||
|
method: 'PATCH',
|
||||||
|
body: { name, phone },
|
||||||
|
}),
|
||||||
|
invalidatesTags: ['Masters'],
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const {
|
||||||
|
useGetMastersQuery,
|
||||||
|
useAddMasterMutation,
|
||||||
|
useDeleteMasterMutation,
|
||||||
|
useUpdateMasterMutation,
|
||||||
|
useGetOrdersQuery,
|
||||||
|
useUpdateOrdersMutation,
|
||||||
|
} = api;
|
||||||
|
@ -12,4 +12,4 @@ export const extractErrorMessageFromResponse = ({ data }: FetchBaseQueryError) =
|
|||||||
if (typeof data === 'object' && 'message' in data && typeof data.message === 'string') {
|
if (typeof data === 'object' && 'message' in data && typeof data.message === 'string') {
|
||||||
return data.message;
|
return data.message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
139
src/api/arm.ts
139
src/api/arm.ts
@ -1,139 +0,0 @@
|
|||||||
import { getConfigValue } from '@brojs/cli';
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
|
|
||||||
enum ArmEndpoints {
|
|
||||||
ORDERS = '/arm/orders',
|
|
||||||
MASTERS = '/arm/masters',
|
|
||||||
}
|
|
||||||
|
|
||||||
const armService = () => {
|
|
||||||
const endpoint = getConfigValue('dry-wash.api');
|
|
||||||
|
|
||||||
const fetchOrders = async ({ date }: { date: Date }) => {
|
|
||||||
const startDate = dayjs(date).startOf('day').toISOString();
|
|
||||||
const endDate = dayjs(date).endOf('day').toISOString();
|
|
||||||
|
|
||||||
const response = await fetch(`${endpoint}${ArmEndpoints.ORDERS}`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ startDate, endDate }),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch orders: ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await response.json();
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchMasters = async () => {
|
|
||||||
const response = await fetch(`${endpoint}${ArmEndpoints.MASTERS}`);
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch masters: ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await response.json();
|
|
||||||
};
|
|
||||||
|
|
||||||
const addMaster = async ({
|
|
||||||
name,
|
|
||||||
phone,
|
|
||||||
}: {
|
|
||||||
name: string;
|
|
||||||
phone: string;
|
|
||||||
}) => {
|
|
||||||
const response = await fetch(`${endpoint}${ArmEndpoints.MASTERS}`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ name, phone }),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch masters: ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await response.json();
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteMaster = async ({ id }: { id: string }) => {
|
|
||||||
const response = await fetch(`${endpoint}${ArmEndpoints.MASTERS}/${id}`, {
|
|
||||||
method: 'DELETE',
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch masters: ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await response.json();
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateOrders = async ({
|
|
||||||
id,
|
|
||||||
status,
|
|
||||||
notes,
|
|
||||||
masterId,
|
|
||||||
}: {
|
|
||||||
id: string;
|
|
||||||
status?: string;
|
|
||||||
notes?: string;
|
|
||||||
masterId?: string;
|
|
||||||
}) => {
|
|
||||||
const body = JSON.stringify({ status, notes, masterId });
|
|
||||||
|
|
||||||
const response = await fetch(`${endpoint}/order/${id}`, {
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch update masters: ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await response.json();
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateMaster = async ({
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
phone,
|
|
||||||
}: {
|
|
||||||
id: string;
|
|
||||||
name?: string;
|
|
||||||
phone?: string;
|
|
||||||
}) => {
|
|
||||||
const body = JSON.stringify({ name, phone });
|
|
||||||
|
|
||||||
const response = await fetch(`${endpoint}${ArmEndpoints.MASTERS}/${id}`, {
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch update masters: ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await response.json();
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
fetchOrders,
|
|
||||||
fetchMasters,
|
|
||||||
addMaster,
|
|
||||||
deleteMaster,
|
|
||||||
updateMaster,
|
|
||||||
updateOrders,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export { armService, ArmEndpoints };
|
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Editable,
|
Editable,
|
||||||
EditableInput,
|
EditableInput,
|
||||||
@ -14,22 +14,18 @@ import {
|
|||||||
import { CheckIcon, CloseIcon, EditIcon } from '@chakra-ui/icons';
|
import { CheckIcon, CloseIcon, EditIcon } from '@chakra-ui/icons';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { useUpdateMasterMutation } from '../../__data__/service/api';
|
||||||
|
|
||||||
interface EditableWrapperProps {
|
interface EditableWrapperProps {
|
||||||
value: string;
|
value: string;
|
||||||
onSubmit: ({
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
phone,
|
|
||||||
}: {
|
|
||||||
id: string;
|
|
||||||
name?: string;
|
|
||||||
phone?: string;
|
|
||||||
}) => Promise<unknown>;
|
|
||||||
as: 'phone' | 'name';
|
as: 'phone' | 'name';
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditableWrapper = ({ value, onSubmit, as, id }: EditableWrapperProps) => {
|
const EditableWrapper = ({ value, as, id }: EditableWrapperProps) => {
|
||||||
|
const [updateMaster, { isError, isSuccess, error }] =
|
||||||
|
useUpdateMasterMutation();
|
||||||
|
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.arm.master.editable',
|
keyPrefix: 'dry-wash.arm.master.editable',
|
||||||
});
|
});
|
||||||
@ -40,11 +36,13 @@ const EditableWrapper = ({ value, onSubmit, as, id }: EditableWrapperProps) => {
|
|||||||
const handleSubmit = async (newValue: string) => {
|
const handleSubmit = async (newValue: string) => {
|
||||||
if (currentValue === newValue) return;
|
if (currentValue === newValue) return;
|
||||||
|
|
||||||
try {
|
await updateMaster({ id, [as]: newValue });
|
||||||
await onSubmit({ id, [as]: newValue });
|
|
||||||
|
|
||||||
setCurrentValue(newValue);
|
setCurrentValue(newValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isSuccess) {
|
||||||
toast({
|
toast({
|
||||||
title: 'Успешно!',
|
title: 'Успешно!',
|
||||||
description: 'Данные обновлены.',
|
description: 'Данные обновлены.',
|
||||||
@ -53,7 +51,11 @@ const EditableWrapper = ({ value, onSubmit, as, id }: EditableWrapperProps) => {
|
|||||||
isClosable: true,
|
isClosable: true,
|
||||||
position: 'top-right',
|
position: 'top-right',
|
||||||
});
|
});
|
||||||
} catch (error) {
|
}
|
||||||
|
}, [isSuccess]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isError) {
|
||||||
toast({
|
toast({
|
||||||
title: 'Ошибка!',
|
title: 'Ошибка!',
|
||||||
description: 'Не удалось обновить данные.',
|
description: 'Не удалось обновить данные.',
|
||||||
@ -64,7 +66,7 @@ const EditableWrapper = ({ value, onSubmit, as, id }: EditableWrapperProps) => {
|
|||||||
});
|
});
|
||||||
console.error('Ошибка при обновлении данных:', error);
|
console.error('Ошибка при обновлении данных:', error);
|
||||||
}
|
}
|
||||||
};
|
}, [isError, error]);
|
||||||
|
|
||||||
function EditableControls() {
|
function EditableControls() {
|
||||||
const {
|
const {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
Menu,
|
Menu,
|
||||||
MenuButton,
|
MenuButton,
|
||||||
@ -10,7 +10,7 @@ import {
|
|||||||
import { EditIcon } from '@chakra-ui/icons';
|
import { EditIcon } from '@chakra-ui/icons';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { armService } from '../../api/arm';
|
import { useDeleteMasterMutation } from '../../__data__/service/api';
|
||||||
|
|
||||||
interface MasterActionsMenu {
|
interface MasterActionsMenu {
|
||||||
id: string;
|
id: string;
|
||||||
@ -21,12 +21,17 @@ const MasterActionsMenu = ({ id }: MasterActionsMenu) => {
|
|||||||
keyPrefix: 'dry-wash.arm.master.table.actionsMenu',
|
keyPrefix: 'dry-wash.arm.master.table.actionsMenu',
|
||||||
});
|
});
|
||||||
|
|
||||||
const { deleteMaster } = armService();
|
const [deleteMaster, { isSuccess, isError, error, isLoading }] =
|
||||||
|
useDeleteMasterMutation();
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
const handleClickDelete = async () => {
|
const handleClickDelete = async () => {
|
||||||
try {
|
await deleteMaster({ id });
|
||||||
await deleteMaster({ id });
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isSuccess) {
|
||||||
toast({
|
toast({
|
||||||
title: 'Мастер удалён.',
|
title: 'Мастер удалён.',
|
||||||
description: `Мастер с ID "${id}" успешно удалён.`,
|
description: `Мастер с ID "${id}" успешно удалён.`,
|
||||||
@ -35,7 +40,11 @@ const MasterActionsMenu = ({ id }: MasterActionsMenu) => {
|
|||||||
isClosable: true,
|
isClosable: true,
|
||||||
position: 'top-right',
|
position: 'top-right',
|
||||||
});
|
});
|
||||||
} catch (error) {
|
}
|
||||||
|
}, [isSuccess]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isError) {
|
||||||
toast({
|
toast({
|
||||||
title: 'Ошибка удаления мастера.',
|
title: 'Ошибка удаления мастера.',
|
||||||
description: 'Не удалось удалить мастера. Попробуйте ещё раз.',
|
description: 'Не удалось удалить мастера. Попробуйте ещё раз.',
|
||||||
@ -46,13 +55,15 @@ const MasterActionsMenu = ({ id }: MasterActionsMenu) => {
|
|||||||
});
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
};
|
}, [isError]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuButton icon={<EditIcon />} as={IconButton} variant='outline' />
|
<MenuButton icon={<EditIcon />} as={IconButton} variant='outline' />
|
||||||
<MenuList>
|
<MenuList>
|
||||||
<MenuItem onClick={handleClickDelete}>{t('delete')}</MenuItem>
|
<MenuItem onClick={handleClickDelete} isDisabled={isLoading}>
|
||||||
|
{t('delete')}
|
||||||
|
</MenuItem>
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
import { useForm, SubmitHandler } from 'react-hook-form';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
FormControl,
|
FormControl,
|
||||||
@ -14,107 +15,136 @@ import {
|
|||||||
useToast,
|
useToast,
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputLeftElement,
|
InputLeftElement,
|
||||||
|
FormErrorMessage,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { PhoneIcon } from '@chakra-ui/icons';
|
import { PhoneIcon } from '@chakra-ui/icons';
|
||||||
|
|
||||||
import { api } from '../../__data__/service/api';
|
import { api } from '../../__data__/service/api';
|
||||||
|
import showToast from '../../helpers/showToast';
|
||||||
|
import { DrawerInputs } from '../../models/arm/form';
|
||||||
|
|
||||||
const MasterDrawer = ({ isOpen, onClose }) => {
|
interface MasterDrawerProps {
|
||||||
const [addMaster, { error, isSuccess }] = api.useAddMasterMutation();
|
isOpen: boolean;
|
||||||
const toast = useToast();
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
const [newMaster, setNewMaster] = useState({ name: '', phone: '' });
|
const MasterDrawer = ({ isOpen, onClose }: MasterDrawerProps) => {
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<DrawerInputs>();
|
||||||
|
|
||||||
const handleSave = async () => {
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.arm.master.drawer',
|
||||||
|
});
|
||||||
|
|
||||||
|
const onSubmit: SubmitHandler<DrawerInputs> = async (data) => {
|
||||||
const trimMaster = {
|
const trimMaster = {
|
||||||
phone: newMaster.phone.trim(),
|
name: data.name.trim(),
|
||||||
name: newMaster.name.trim(),
|
phone: data.phone.trim(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (trimMaster.name === '' || trimMaster.phone === '') {
|
const isEmptyFields = trimMaster.name === '' || trimMaster.phone === '';
|
||||||
|
|
||||||
|
if (isEmptyFields) {
|
||||||
|
showToast({
|
||||||
|
toast,
|
||||||
|
title: t('toast.error.base'),
|
||||||
|
description: t('toast.error.empty-fields'),
|
||||||
|
status: 'error',
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
addMaster(trimMaster);
|
await addMaster(trimMaster);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [addMaster, { error, isSuccess }] = api.useAddMasterMutation();
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
toast({
|
showToast({
|
||||||
title: 'Мастер создан.',
|
toast,
|
||||||
description: `Мастер "${newMaster.name}" успешно добавлен.`,
|
title: t('toast.create-master'),
|
||||||
status: 'success',
|
status: 'success',
|
||||||
duration: 5000,
|
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
});
|
||||||
|
reset();
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
}, [isSuccess]);
|
}, [isSuccess]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) {
|
if (error) {
|
||||||
toast({
|
showToast({
|
||||||
title: 'Ошибка при создании мастера.',
|
toast,
|
||||||
description: 'Не удалось добавить мастера. Попробуйте еще раз.',
|
title: t('toast.error.create-master'),
|
||||||
|
description: t('toast.error.create-master-details'),
|
||||||
status: 'error',
|
status: 'error',
|
||||||
duration: 5000,
|
|
||||||
isClosable: true,
|
|
||||||
position: 'top-right',
|
|
||||||
});
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
const { t } = useTranslation('~', {
|
|
||||||
keyPrefix: 'dry-wash.arm.master.drawer',
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer isOpen={isOpen} onClose={onClose} size='md'>
|
<Drawer isOpen={isOpen} onClose={onClose} size='md'>
|
||||||
<DrawerOverlay />
|
<DrawerOverlay />
|
||||||
<DrawerContent>
|
<DrawerContent>
|
||||||
<DrawerCloseButton />
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<DrawerHeader>{t('title')}</DrawerHeader>
|
<DrawerCloseButton />
|
||||||
<DrawerBody>
|
<DrawerHeader>{t('title')}</DrawerHeader>
|
||||||
<FormControl mb='4'>
|
<DrawerBody>
|
||||||
<FormLabel>{t('inputName.label')}</FormLabel>
|
<FormControl mb='4' isInvalid={!!errors.name}>
|
||||||
<Input
|
<FormLabel>{t('inputName.label')}</FormLabel>
|
||||||
// isInvalid
|
|
||||||
value={newMaster.name}
|
|
||||||
onChange={(e) =>
|
|
||||||
setNewMaster({ ...newMaster, name: e.target.value })
|
|
||||||
}
|
|
||||||
placeholder={t('inputName.placeholder')}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormControl>
|
|
||||||
<FormLabel>{t('inputPhone.label')}</FormLabel>
|
|
||||||
|
|
||||||
<InputGroup>
|
|
||||||
<InputLeftElement pointerEvents='none'>
|
|
||||||
<PhoneIcon color='gray.300' />
|
|
||||||
</InputLeftElement>
|
|
||||||
<Input
|
<Input
|
||||||
// isInvalid
|
{...register('name', {
|
||||||
value={newMaster.phone}
|
required: t('form.name.required'),
|
||||||
onChange={(e) =>
|
minLength: {
|
||||||
setNewMaster({ ...newMaster, phone: e.target.value })
|
value: 2,
|
||||||
}
|
message: t('form.name.minLength'),
|
||||||
placeholder={t('inputPhone.placeholder')}
|
},
|
||||||
|
})}
|
||||||
|
placeholder={t('inputName.placeholder')}
|
||||||
/>
|
/>
|
||||||
</InputGroup>
|
<FormErrorMessage>
|
||||||
</FormControl>
|
{errors.name && errors.name.message}
|
||||||
</DrawerBody>
|
</FormErrorMessage>
|
||||||
<DrawerFooter>
|
</FormControl>
|
||||||
<Button colorScheme='teal' mr={3} onClick={handleSave}>
|
<FormControl isInvalid={!!errors.phone}>
|
||||||
{t('button.save')}
|
<FormLabel>{t('inputPhone.label')}</FormLabel>
|
||||||
</Button>
|
<InputGroup>
|
||||||
<Button variant='ghost' onClick={onClose}>
|
<InputLeftElement pointerEvents='none'>
|
||||||
{t('button.cancel')}
|
<PhoneIcon color='gray.300' />
|
||||||
</Button>
|
</InputLeftElement>
|
||||||
</DrawerFooter>
|
<Input
|
||||||
|
{...register('phone', {
|
||||||
|
required: t('form.phone.required'),
|
||||||
|
pattern: {
|
||||||
|
value: /^(\+7|8)\d{10}$/,
|
||||||
|
message: t('form.phone.pattern'),
|
||||||
|
},
|
||||||
|
setValueAs: (value) => value.replace(/[^\d+]/g, ''),
|
||||||
|
})}
|
||||||
|
placeholder={t('inputPhone.placeholder')}
|
||||||
|
/>
|
||||||
|
</InputGroup>
|
||||||
|
<FormErrorMessage>
|
||||||
|
{errors.phone && errors.phone.message}
|
||||||
|
</FormErrorMessage>
|
||||||
|
</FormControl>
|
||||||
|
</DrawerBody>
|
||||||
|
<DrawerFooter>
|
||||||
|
<Button colorScheme='teal' mr={3} type='submit'>
|
||||||
|
{t('button.save')}
|
||||||
|
</Button>
|
||||||
|
<Button variant='ghost' onClick={onClose}>
|
||||||
|
{t('button.cancel')}
|
||||||
|
</Button>
|
||||||
|
</DrawerFooter>
|
||||||
|
</form>
|
||||||
</DrawerContent>
|
</DrawerContent>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
);
|
);
|
||||||
|
@ -5,10 +5,8 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import MasterActionsMenu from '../MasterActionsMenu';
|
import MasterActionsMenu from '../MasterActionsMenu';
|
||||||
import { getTimeSlot } from '../../lib';
|
import { getTimeSlot } from '../../lib';
|
||||||
import EditableWrapper from '../Editable/Editable';
|
import EditableWrapper from '../Editable/Editable';
|
||||||
import { armService } from '../../api/arm';
|
|
||||||
|
|
||||||
const MasterItem = ({ name, phone, id, schedule }) => {
|
const MasterItem = ({ name, phone, id, schedule }) => {
|
||||||
const { updateMaster } = armService();
|
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.arm.master',
|
keyPrefix: 'dry-wash.arm.master',
|
||||||
});
|
});
|
||||||
@ -16,12 +14,7 @@ const MasterItem = ({ name, phone, id, schedule }) => {
|
|||||||
return (
|
return (
|
||||||
<Tr>
|
<Tr>
|
||||||
<Td>
|
<Td>
|
||||||
<EditableWrapper
|
<EditableWrapper id={id} as={'name'} value={name} />
|
||||||
id={id}
|
|
||||||
as={'name'}
|
|
||||||
value={name}
|
|
||||||
onSubmit={updateMaster}
|
|
||||||
/>
|
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
{schedule?.length > 0 ? (
|
{schedule?.length > 0 ? (
|
||||||
@ -37,12 +30,7 @@ const MasterItem = ({ name, phone, id, schedule }) => {
|
|||||||
)}
|
)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<EditableWrapper
|
<EditableWrapper id={id} as={'phone'} value={phone} />
|
||||||
id={id}
|
|
||||||
as={'phone'}
|
|
||||||
value={phone}
|
|
||||||
onSubmit={updateMaster}
|
|
||||||
/>
|
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<MasterActionsMenu id={id} />
|
<MasterActionsMenu id={id} />
|
||||||
|
@ -19,7 +19,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import MasterItem from '../MasterItem';
|
import MasterItem from '../MasterItem';
|
||||||
import MasterDrawer from '../MasterDrawer';
|
import MasterDrawer from '../MasterDrawer';
|
||||||
import { api } from '../../__data__/service/api';
|
import { useGetMastersQuery } from '../../__data__/service/api';
|
||||||
|
|
||||||
const TABLE_HEADERS = [
|
const TABLE_HEADERS = [
|
||||||
'name' as const,
|
'name' as const,
|
||||||
@ -35,12 +35,7 @@ const Masters = () => {
|
|||||||
keyPrefix: 'dry-wash.arm.master',
|
keyPrefix: 'dry-wash.arm.master',
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const { data: masters, error, isLoading, isSuccess } = useGetMastersQuery();
|
||||||
data: masters,
|
|
||||||
error,
|
|
||||||
isLoading,
|
|
||||||
isSuccess,
|
|
||||||
} = api.useGetMastersQuery();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -5,7 +5,7 @@ import dayjs from 'dayjs';
|
|||||||
|
|
||||||
import { getTimeSlot } from '../../lib';
|
import { getTimeSlot } from '../../lib';
|
||||||
import { Master } from '../../models/api/master';
|
import { Master } from '../../models/api/master';
|
||||||
import { armService } from '../../api/arm';
|
import { useUpdateOrdersMutation } from '../../__data__/service/api';
|
||||||
|
|
||||||
const statuses = [
|
const statuses = [
|
||||||
'pending' as const,
|
'pending' as const,
|
||||||
@ -54,8 +54,7 @@ const OrderItem = ({
|
|||||||
allMasters,
|
allMasters,
|
||||||
id,
|
id,
|
||||||
}: OrderProps) => {
|
}: OrderProps) => {
|
||||||
const { updateOrders } = armService();
|
const [updateOrders] = useUpdateOrdersMutation();
|
||||||
|
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.arm.order',
|
keyPrefix: 'dry-wash.arm.order',
|
||||||
});
|
});
|
||||||
@ -72,16 +71,16 @@ const OrderItem = ({
|
|||||||
|
|
||||||
if (selectedMaster) {
|
if (selectedMaster) {
|
||||||
setMaster(masterName);
|
setMaster(masterName);
|
||||||
updateOrders({ id, masterId: selectedMaster.id });
|
updateOrders({ id, master: selectedMaster.id });
|
||||||
} else {
|
} else {
|
||||||
console.error('Master not found');
|
console.error('Master not found');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handeChangeStatus = (e: ChangeEvent<HTMLSelectElement>) => {
|
const handeChangeStatus = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
const status = e.target.value;
|
const status = e.target.value as OrderProps['status'];
|
||||||
updateOrders({ id, status });
|
updateOrders({ id, status });
|
||||||
setStatus(e.target.value as OrderProps['status']);
|
setStatus(status);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -17,9 +17,11 @@ import dayjs from 'dayjs';
|
|||||||
|
|
||||||
import OrderItem from '../OrderItem';
|
import OrderItem from '../OrderItem';
|
||||||
import { OrderProps } from '../OrderItem/OrderItem';
|
import { OrderProps } from '../OrderItem/OrderItem';
|
||||||
import { armService } from '../../api/arm';
|
|
||||||
import DateNavigator from '../DateNavigator';
|
import DateNavigator from '../DateNavigator';
|
||||||
import { Master } from '../../models/api/master';
|
import {
|
||||||
|
useGetMastersQuery,
|
||||||
|
useGetOrdersQuery,
|
||||||
|
} from '../../__data__/service/api';
|
||||||
|
|
||||||
const TABLE_HEADERS = [
|
const TABLE_HEADERS = [
|
||||||
'carNumber' as const,
|
'carNumber' as const,
|
||||||
@ -34,47 +36,41 @@ const Orders = () => {
|
|||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.arm.order',
|
keyPrefix: 'dry-wash.arm.order',
|
||||||
});
|
});
|
||||||
|
|
||||||
const { fetchOrders } = armService();
|
|
||||||
const { fetchMasters } = armService();
|
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
const [orders, setOrders] = useState<OrderProps[]>([]);
|
|
||||||
const [allMasters, setAllMasters] = useState<Master[]>([]);
|
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
const [currentDate, setCurrentDate] = useState(new Date());
|
const [currentDate, setCurrentDate] = useState(new Date());
|
||||||
|
const {
|
||||||
|
data: orders,
|
||||||
|
isLoading: isOrdersLoading,
|
||||||
|
isSuccess: isOrdersSuccess,
|
||||||
|
isError: isOrdersError,
|
||||||
|
error: ordersError,
|
||||||
|
} = useGetOrdersQuery({ date: currentDate });
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: masters,
|
||||||
|
isLoading: isMastersLoading,
|
||||||
|
isSuccess: isMastersSuccess,
|
||||||
|
isError: isMastersError,
|
||||||
|
error: mastersError,
|
||||||
|
} = useGetMastersQuery();
|
||||||
|
|
||||||
|
const isLoading = isOrdersLoading || isMastersLoading;
|
||||||
|
const isSuccess = isOrdersSuccess && isMastersSuccess;
|
||||||
|
const isError = isOrdersError || isMastersError;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
if (isError) {
|
||||||
setLoading(true);
|
toast({
|
||||||
setError(null);
|
title: t('error.title'),
|
||||||
|
// description: errorMessage,
|
||||||
try {
|
status: 'error',
|
||||||
const [ordersData, mastersData] = await Promise.all([
|
duration: 5000,
|
||||||
fetchOrders({ date: currentDate }),
|
isClosable: true,
|
||||||
fetchMasters(),
|
position: 'bottom-right',
|
||||||
]);
|
});
|
||||||
|
}
|
||||||
setOrders(ordersData.body);
|
}, [isError, ordersError, mastersError, toast, t]);
|
||||||
setAllMasters(mastersData.body);
|
|
||||||
} catch (err) {
|
|
||||||
setError(err.message);
|
|
||||||
toast({
|
|
||||||
title: t('error.title'),
|
|
||||||
status: 'error',
|
|
||||||
duration: 5000,
|
|
||||||
isClosable: true,
|
|
||||||
position: 'bottom-right',
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
loadData();
|
|
||||||
}, [currentDate, toast, t]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box p='8'>
|
<Box p='8'>
|
||||||
@ -103,25 +99,24 @@ const Orders = () => {
|
|||||||
</Tr>
|
</Tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
<Tbody>
|
<Tbody>
|
||||||
{loading && (
|
{isLoading && (
|
||||||
<Tr>
|
<Tr>
|
||||||
<Td colSpan={TABLE_HEADERS.length} textAlign='center' py='8'>
|
<Td colSpan={TABLE_HEADERS.length} textAlign='center' py='8'>
|
||||||
<Spinner size='lg' />
|
<Spinner size='lg' />
|
||||||
</Td>
|
</Td>
|
||||||
</Tr>
|
</Tr>
|
||||||
)}
|
)}
|
||||||
{!loading && orders.length === 0 && !error && (
|
{isSuccess && orders.length === 0 && (
|
||||||
<Tr>
|
<Tr>
|
||||||
<Td colSpan={TABLE_HEADERS.length}>
|
<Td colSpan={TABLE_HEADERS.length}>
|
||||||
<Text>{t('table.empty')}</Text>
|
<Text>{t('table.empty')}</Text>
|
||||||
</Td>
|
</Td>
|
||||||
</Tr>
|
</Tr>
|
||||||
)}
|
)}
|
||||||
{!loading &&
|
{isSuccess &&
|
||||||
!error &&
|
|
||||||
orders.map((order, index) => (
|
orders.map((order, index) => (
|
||||||
<OrderItem
|
<OrderItem
|
||||||
allMasters={allMasters}
|
allMasters={masters}
|
||||||
key={index}
|
key={index}
|
||||||
{...order}
|
{...order}
|
||||||
status={order.status as OrderProps['status']}
|
status={order.status as OrderProps['status']}
|
||||||
|
21
src/helpers/showToast.ts
Normal file
21
src/helpers/showToast.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { UseToastOptions } from '@chakra-ui/react';
|
||||||
|
|
||||||
|
interface ShowToast {
|
||||||
|
toast: (options: UseToastOptions) => void;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
status: 'info' | 'warning' | 'success' | 'error';
|
||||||
|
}
|
||||||
|
|
||||||
|
const showToast = ({ toast, title, description, status }: ShowToast) => {
|
||||||
|
toast({
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
status,
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default showToast;
|
@ -10,4 +10,4 @@ type ErrorResponse = {
|
|||||||
message: ErrorMessage;
|
message: ErrorMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BaseResponse<Body> = SuccessResponse<Body> | ErrorResponse;
|
export type BaseResponse<Body> = SuccessResponse<Body> | ErrorResponse;
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
export * from './common';
|
export * from './common';
|
||||||
export * from './order';
|
export * from './order';
|
||||||
|
4
src/models/arm/form.ts
Normal file
4
src/models/arm/form.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export type DrawerInputs = {
|
||||||
|
phone: string;
|
||||||
|
name: string;
|
||||||
|
};
|
325
src/pages/__tests__/__snapshots__/arm.test.tsx.snap
Normal file
325
src/pages/__tests__/__snapshots__/arm.test.tsx.snap
Normal file
@ -0,0 +1,325 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`Arm Page render 1`] = `
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="css-1yeiifd"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="css-1fp6kaj"
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
class="chakra-heading css-9q1d0h"
|
||||||
|
>
|
||||||
|
title
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
class="chakra-stack css-1oen434"
|
||||||
|
>
|
||||||
|
<hr
|
||||||
|
aria-orientation="horizontal"
|
||||||
|
class="chakra-divider css-1upb9tn"
|
||||||
|
/>
|
||||||
|
<a
|
||||||
|
class="chakra-button css-uxt1e8"
|
||||||
|
href="/auth/login"
|
||||||
|
>
|
||||||
|
orders
|
||||||
|
</a>
|
||||||
|
<hr
|
||||||
|
aria-orientation="horizontal"
|
||||||
|
class="chakra-divider css-1upb9tn"
|
||||||
|
/>
|
||||||
|
<a
|
||||||
|
class="chakra-button css-uxt1e8"
|
||||||
|
href="/auth/login"
|
||||||
|
>
|
||||||
|
master
|
||||||
|
</a>
|
||||||
|
<hr
|
||||||
|
aria-orientation="horizontal"
|
||||||
|
class="chakra-divider css-1upb9tn"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="css-sy55x5"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="css-hpgf8j"
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
class="chakra-heading css-r7q7qr"
|
||||||
|
>
|
||||||
|
title
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
class="css-1me9tx"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="chakra-button css-4xx2wk"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="chakra-icon css-onkibi"
|
||||||
|
focusable="false"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<p
|
||||||
|
class="chakra-text css-1bntq7d"
|
||||||
|
>
|
||||||
|
2/2/2025
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
class="chakra-button css-4xx2wk"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="chakra-icon css-onkibi"
|
||||||
|
focusable="false"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<table
|
||||||
|
class="chakra-table css-0"
|
||||||
|
>
|
||||||
|
<thead
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
<tr
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.carNumber
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.orderDate
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.status
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.masters
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.telephone
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.location
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
<tr
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
<td
|
||||||
|
class="css-12rlgei"
|
||||||
|
colspan="6"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="chakra-spinner css-1y7joxr"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="css-8b45rq"
|
||||||
|
>
|
||||||
|
Loading...
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Arm Page render 2`] = `
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="css-1yeiifd"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="css-1fp6kaj"
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
class="chakra-heading css-9q1d0h"
|
||||||
|
>
|
||||||
|
title
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
class="chakra-stack css-1oen434"
|
||||||
|
>
|
||||||
|
<hr
|
||||||
|
aria-orientation="horizontal"
|
||||||
|
class="chakra-divider css-1upb9tn"
|
||||||
|
/>
|
||||||
|
<a
|
||||||
|
class="chakra-button css-uxt1e8"
|
||||||
|
href="/auth/login"
|
||||||
|
>
|
||||||
|
orders
|
||||||
|
</a>
|
||||||
|
<hr
|
||||||
|
aria-orientation="horizontal"
|
||||||
|
class="chakra-divider css-1upb9tn"
|
||||||
|
/>
|
||||||
|
<a
|
||||||
|
class="chakra-button css-uxt1e8"
|
||||||
|
href="/auth/login"
|
||||||
|
>
|
||||||
|
master
|
||||||
|
</a>
|
||||||
|
<hr
|
||||||
|
aria-orientation="horizontal"
|
||||||
|
class="chakra-divider css-1upb9tn"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="css-sy55x5"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="css-hpgf8j"
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
class="chakra-heading css-r7q7qr"
|
||||||
|
>
|
||||||
|
title
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
class="css-1me9tx"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="chakra-button css-4xx2wk"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="chakra-icon css-onkibi"
|
||||||
|
focusable="false"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<p
|
||||||
|
class="chakra-text css-1bntq7d"
|
||||||
|
>
|
||||||
|
2/2/2025
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
class="chakra-button css-4xx2wk"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="chakra-icon css-onkibi"
|
||||||
|
focusable="false"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<table
|
||||||
|
class="chakra-table css-0"
|
||||||
|
>
|
||||||
|
<thead
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
<tr
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.carNumber
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.orderDate
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.status
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.masters
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.telephone
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
table.header.location
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
<tr
|
||||||
|
class="css-0"
|
||||||
|
>
|
||||||
|
<td
|
||||||
|
class="css-12rlgei"
|
||||||
|
colspan="6"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="chakra-spinner css-1y7joxr"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="css-8b45rq"
|
||||||
|
>
|
||||||
|
Loading...
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
130
src/pages/__tests__/arm.test.tsx
Normal file
130
src/pages/__tests__/arm.test.tsx
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
describe,
|
||||||
|
it,
|
||||||
|
expect,
|
||||||
|
jest,
|
||||||
|
beforeAll,
|
||||||
|
afterEach,
|
||||||
|
afterAll,
|
||||||
|
} from '@jest/globals';
|
||||||
|
import { render, screen, waitFor } from '@testing-library/react';
|
||||||
|
import { http, HttpResponse } from 'msw';
|
||||||
|
import { setupServer } from 'msw/node';
|
||||||
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
|
|
||||||
|
import Page from '../arm';
|
||||||
|
|
||||||
|
const server = setupServer(
|
||||||
|
http.post('/api/arm/orders', () => {
|
||||||
|
return HttpResponse.json({
|
||||||
|
success: true,
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
id: 'order1',
|
||||||
|
carNumber: 'A123BC',
|
||||||
|
startWashTime: '2024-11-24T10:30:00.000Z',
|
||||||
|
endWashTime: '2024-11-24T16:30:00.000Z',
|
||||||
|
orderDate: '2024-11-24T08:41:46.366Z',
|
||||||
|
status: 'pending',
|
||||||
|
phone: '79001234563',
|
||||||
|
location: 'Казань, ул. Баумана, 1',
|
||||||
|
master: {
|
||||||
|
name: 'Олег Макаров',
|
||||||
|
phone: '79001234567',
|
||||||
|
id: '23423442',
|
||||||
|
},
|
||||||
|
notes: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'order2',
|
||||||
|
carNumber: 'A245BC',
|
||||||
|
startWashTime: '2024-11-24T11:30:00.000Z',
|
||||||
|
endWashTime: '2024-11-24T17:30:00.000Z',
|
||||||
|
orderDate: '2024-11-24T07:40:46.366Z',
|
||||||
|
status: 'progress',
|
||||||
|
phone: '79001234567',
|
||||||
|
location: 'Казань, ул. Баумана, 43',
|
||||||
|
master: [],
|
||||||
|
notes: '',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
http.get('/api/arm/masters', () => {
|
||||||
|
return HttpResponse.json({
|
||||||
|
success: true,
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
id: '4545423234',
|
||||||
|
name: 'Иван Иванов',
|
||||||
|
phone: '+7 900 123 45 67',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Олег Макаров',
|
||||||
|
phone: '79001234567',
|
||||||
|
id: '23423442',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '345354234',
|
||||||
|
name: 'Иван Галкин',
|
||||||
|
schedule: [
|
||||||
|
{
|
||||||
|
id: 'order1',
|
||||||
|
startWashTime: '2024-11-24T10:30:00.000Z',
|
||||||
|
endWashTime: '2024-11-24T16:30:00.000Z',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'order2',
|
||||||
|
startWashTime: '2024-11-24T11:30:00.000Z',
|
||||||
|
endWashTime: '2024-11-24T17:30:00.000Z',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
phone: '+7 900 123 45 67',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
jest.mock('react-i18next', () => {
|
||||||
|
return {
|
||||||
|
useTranslation: () => {
|
||||||
|
return {
|
||||||
|
t: (key: never) => `${key}`,
|
||||||
|
i18n: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.mock('@brojs/cli', () => {
|
||||||
|
return {
|
||||||
|
getNavigationValue: () => '/auth/login',
|
||||||
|
getConfigValue: () => '/api',
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Arm Page', () => {
|
||||||
|
beforeAll(() => server.listen());
|
||||||
|
afterEach(() => server.resetHandlers());
|
||||||
|
afterAll(() => server.close());
|
||||||
|
|
||||||
|
it('render ', async () => {
|
||||||
|
server.events.on('request:start', ({ request }) => {
|
||||||
|
console.log('Outgoing:', request.method, request.url);
|
||||||
|
});
|
||||||
|
|
||||||
|
const { container } = render(
|
||||||
|
<BrowserRouter>
|
||||||
|
<Page mockUser={{ name: 'ilnaz' }} />
|
||||||
|
</BrowserRouter>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(container).toMatchSnapshot();
|
||||||
|
|
||||||
|
await waitFor(() => screen.getByText('A123BC'));
|
||||||
|
|
||||||
|
expect(container).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
@ -6,8 +6,12 @@ import LayoutArm from '../../components/LayoutArm';
|
|||||||
import authLogin from '../../keycloak';
|
import authLogin from '../../keycloak';
|
||||||
import { URLs } from '../../__data__/urls';
|
import { URLs } from '../../__data__/urls';
|
||||||
|
|
||||||
const Page = () => {
|
interface PageProps {
|
||||||
const [user, setUser] = useState(null);
|
mockUser?: { name: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
const Page = ({ mockUser }: PageProps) => {
|
||||||
|
const [user, setUser] = useState(mockUser || null);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ router.delete('/arm/masters/:id', (req, res) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.patch('/orders/:id', (req, res) => {
|
router.patch('/order/:id', (req, res) => {
|
||||||
res
|
res
|
||||||
.status(/error/.test(STUBS.orders) ? 500 : 200)
|
.status(/error/.test(STUBS.orders) ? 500 : 200)
|
||||||
.send(
|
.send(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user