Compare commits
25 Commits
v0.2.0
...
feature/up
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f92125e6d | |||
| 3ea501161c | |||
| e8634c396f | |||
| edddf6d857 | |||
| 1276b13fec | |||
| 2aa361e3db | |||
|
|
4cda998bd7 | ||
| 9b0bda3cda | |||
| cad31605d9 | |||
| 1dee68b65d | |||
| 6096cfc15c | |||
| fc699e7890 | |||
|
|
3e0e570ff6 | ||
| 7b24804498 | |||
| 5498122109 | |||
| ef90173b80 | |||
| c7162d0045 | |||
| 885ad16782 | |||
|
|
5e24537919 | ||
| 707a77d7ad | |||
|
|
8a0dff682b | ||
|
|
b8606ac05f | ||
| 6218b6f5d8 | |||
| 8cc8391a09 | |||
| e2c65fd39c |
@@ -24,6 +24,7 @@
|
|||||||
"dry-wash.order-create.form.car-body-field.label": "Car body type",
|
"dry-wash.order-create.form.car-body-field.label": "Car body type",
|
||||||
"dry-wash.order-create.form.washing-datetime-field.label": "What time is the car available?",
|
"dry-wash.order-create.form.washing-datetime-field.label": "What time is the car available?",
|
||||||
"dry-wash.order-create.form.washing-location-field.label": "Where is the car located?",
|
"dry-wash.order-create.form.washing-location-field.label": "Where is the car located?",
|
||||||
|
"dry-wash.order-create.form.washing-location-field.placeholder": "Enter the address or select on the map",
|
||||||
"dry-wash.order-create.form.washing-location-field.help": "For example, 55.754364, 48.743295 Universitetskaya Street, 1, Innopolis, Verkhneuslonsky district, Republic of Tatarstan (Tatarstan), 420500",
|
"dry-wash.order-create.form.washing-location-field.help": "For example, 55.754364, 48.743295 Universitetskaya Street, 1, Innopolis, Verkhneuslonsky district, Republic of Tatarstan (Tatarstan), 420500",
|
||||||
"dry-wash.order-create.car-body-select.placeholder": "Not specified",
|
"dry-wash.order-create.car-body-select.placeholder": "Not specified",
|
||||||
"dry-wash.order-create.car-body-select.options.sedan": "Sedan",
|
"dry-wash.order-create.car-body-select.options.sedan": "Sedan",
|
||||||
@@ -38,6 +39,15 @@
|
|||||||
"dry-wash.order-create.car-body-select.options.sports-car" : "Sports-car",
|
"dry-wash.order-create.car-body-select.options.sports-car" : "Sports-car",
|
||||||
"dry-wash.order-create.car-body-select.options.other": "Other",
|
"dry-wash.order-create.car-body-select.options.other": "Other",
|
||||||
"dry-wash.order-create.form.submit-button.label": "Submit",
|
"dry-wash.order-create.form.submit-button.label": "Submit",
|
||||||
|
"dry-wash.order-view.title": "Your order",
|
||||||
|
"dry-wash.order-view.error.title": "Error",
|
||||||
|
"dry-wash.order-view.fetch.error": "Failed to fetch the details of order #{{number}}",
|
||||||
|
"dry-wash.order-view.details.title": "Order #{{number}}",
|
||||||
|
"dry-wash.order-view.details.owner": "Owner",
|
||||||
|
"dry-wash.order-view.details.car": "Car",
|
||||||
|
"dry-wash.order-view.details.location": "Where",
|
||||||
|
"dry-wash.order-view.details.datetime-range": "When",
|
||||||
|
"dry-wash.order-view.details.alert": "The operator will contact you about the payment at the specified phone number",
|
||||||
"dry-wash.arm.master.add": "Add",
|
"dry-wash.arm.master.add": "Add",
|
||||||
"dry-wash.arm.order.title": "Orders",
|
"dry-wash.arm.order.title": "Orders",
|
||||||
"dry-wash.arm.order.table.empty": "Table empty",
|
"dry-wash.arm.order.table.empty": "Table empty",
|
||||||
@@ -52,6 +62,7 @@
|
|||||||
"dry-wash.arm.order.table.header.washingTime": "Washing Time",
|
"dry-wash.arm.order.table.header.washingTime": "Washing Time",
|
||||||
"dry-wash.arm.order.table.header.orderDate": "Order Date",
|
"dry-wash.arm.order.table.header.orderDate": "Order Date",
|
||||||
"dry-wash.arm.order.table.header.status": "Status",
|
"dry-wash.arm.order.table.header.status": "Status",
|
||||||
|
"dry-wash.arm.order.table.header.masters": "Master",
|
||||||
"dry-wash.arm.order.table.header.telephone": "Telephone",
|
"dry-wash.arm.order.table.header.telephone": "Telephone",
|
||||||
"dry-wash.arm.order.table.header.location": "Location",
|
"dry-wash.arm.order.table.header.location": "Location",
|
||||||
"dry-wash.arm.master.title": "Masters",
|
"dry-wash.arm.master.title": "Masters",
|
||||||
@@ -62,6 +73,10 @@
|
|||||||
"dry-wash.arm.master.table.header.phone": "Phone",
|
"dry-wash.arm.master.table.header.phone": "Phone",
|
||||||
"dry-wash.arm.master.table.header.actions": "Actions",
|
"dry-wash.arm.master.table.header.actions": "Actions",
|
||||||
"dry-wash.arm.master.table.actionsMenu.delete": "Delete Master",
|
"dry-wash.arm.master.table.actionsMenu.delete": "Delete Master",
|
||||||
|
"dry-wash.arm.master.schedule.empty": "free",
|
||||||
|
"dry-wash.arm.master.editable.aria.cancel": "Undo changes",
|
||||||
|
"dry-wash.arm.master.editable.aria.save": "Save changes ",
|
||||||
|
"dry-wash.arm.master.editable.aria.edit": "Edit",
|
||||||
"dry-wash.arm.master.drawer.title": "Add New Master",
|
"dry-wash.arm.master.drawer.title": "Add New Master",
|
||||||
"dry-wash.arm.master.drawer.inputName.label": "Full Name",
|
"dry-wash.arm.master.drawer.inputName.label": "Full Name",
|
||||||
"dry-wash.arm.master.drawer.inputName.placeholder": "Enter Full Name",
|
"dry-wash.arm.master.drawer.inputName.placeholder": "Enter Full Name",
|
||||||
@@ -77,5 +92,6 @@
|
|||||||
"dry-wash.notFound.button.back": "Back to Home",
|
"dry-wash.notFound.button.back": "Back to Home",
|
||||||
"dry-wash.errorBoundary.title": "Something went wrong",
|
"dry-wash.errorBoundary.title": "Something went wrong",
|
||||||
"dry-wash.errorBoundary.description": "We are already working on fixing the issue",
|
"dry-wash.errorBoundary.description": "We are already working on fixing the issue",
|
||||||
"dry-wash.errorBoundary.button.reload": "Reload Page"
|
"dry-wash.errorBoundary.button.reload": "Reload Page",
|
||||||
|
"dry-wash.washTime.timeSlot": "{{start}} - {{end}}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"dry-wash.arm.order.table.header.washingTime": "Время мойки",
|
"dry-wash.arm.order.table.header.washingTime": "Время мойки",
|
||||||
"dry-wash.arm.order.table.header.orderDate": "Дата заказа",
|
"dry-wash.arm.order.table.header.orderDate": "Дата заказа",
|
||||||
"dry-wash.arm.order.table.header.status": "Статус",
|
"dry-wash.arm.order.table.header.status": "Статус",
|
||||||
|
"dry-wash.arm.order.table.header.masters": "Мастер",
|
||||||
"dry-wash.arm.order.table.header.telephone": "Телефон",
|
"dry-wash.arm.order.table.header.telephone": "Телефон",
|
||||||
"dry-wash.arm.order.table.header.location": "Расположение",
|
"dry-wash.arm.order.table.header.location": "Расположение",
|
||||||
"dry-wash.arm.order.table.empty": "Список пуст",
|
"dry-wash.arm.order.table.empty": "Список пуст",
|
||||||
@@ -23,6 +24,10 @@
|
|||||||
"dry-wash.arm.master.table.header.phone": "Телефон",
|
"dry-wash.arm.master.table.header.phone": "Телефон",
|
||||||
"dry-wash.arm.master.table.header.actions": "Действия",
|
"dry-wash.arm.master.table.header.actions": "Действия",
|
||||||
"dry-wash.arm.master.table.actionsMenu.delete": "Удалить мастера",
|
"dry-wash.arm.master.table.actionsMenu.delete": "Удалить мастера",
|
||||||
|
"dry-wash.arm.master.schedule.empty": "Свободен",
|
||||||
|
"dry-wash.arm.master.editable.aria.cancel": "Отменить изменения",
|
||||||
|
"dry-wash.arm.master.editable.aria.save": "Сохранить изменения",
|
||||||
|
"dry-wash.arm.master.editable.aria.edit": "Редактировать",
|
||||||
"dry-wash.arm.master.drawer.title": "Добавить нового мастера",
|
"dry-wash.arm.master.drawer.title": "Добавить нового мастера",
|
||||||
"dry-wash.arm.master.drawer.inputName.label": "ФИО",
|
"dry-wash.arm.master.drawer.inputName.label": "ФИО",
|
||||||
"dry-wash.arm.master.drawer.inputName.placeholder": "Введите ФИО",
|
"dry-wash.arm.master.drawer.inputName.placeholder": "Введите ФИО",
|
||||||
@@ -58,20 +63,30 @@
|
|||||||
"dry-wash.order-create.form.car-body-field.label": "Тип кузова автомобиля",
|
"dry-wash.order-create.form.car-body-field.label": "Тип кузова автомобиля",
|
||||||
"dry-wash.order-create.form.washing-datetime-field.label": "В какое время автомобиль доступен?",
|
"dry-wash.order-create.form.washing-datetime-field.label": "В какое время автомобиль доступен?",
|
||||||
"dry-wash.order-create.form.washing-location-field.label": "Где находится автомобиль?",
|
"dry-wash.order-create.form.washing-location-field.label": "Где находится автомобиль?",
|
||||||
|
"dry-wash.order-create.form.washing-location-field.placeholder": "Введите адрес или выберите на карте",
|
||||||
"dry-wash.order-create.form.washing-location-field.help": "Например, 55.754364, 48.743295 Университетская улица, 1, Иннополис, Верхнеуслонский район, Республика Татарстан (Татарстан), 420500",
|
"dry-wash.order-create.form.washing-location-field.help": "Например, 55.754364, 48.743295 Университетская улица, 1, Иннополис, Верхнеуслонский район, Республика Татарстан (Татарстан), 420500",
|
||||||
"dry-wash.order-create.car-body-select.placeholder": "Не указан",
|
"dry-wash.order-create.car-body-select.placeholder": "Не указан",
|
||||||
"dry-wash.order-create.car-body-select.options.sedan": "Седан",
|
"dry-wash.order-create.car-body-select.options.sedan": "Седан",
|
||||||
"dry-wash.order-create.car-body-select.options.hatchback" : "Хэтчбек",
|
"dry-wash.order-create.car-body-select.options.hatchback": "Хэтчбек",
|
||||||
"dry-wash.order-create.car-body-select.options.crossover" : "Кроссовер",
|
"dry-wash.order-create.car-body-select.options.crossover": "Кроссовер",
|
||||||
"dry-wash.order-create.car-body-select.options.suv" : "Внедорожник",
|
"dry-wash.order-create.car-body-select.options.suv": "Внедорожник",
|
||||||
"dry-wash.order-create.car-body-select.options.station-wagon" : "Универсал",
|
"dry-wash.order-create.car-body-select.options.station-wagon": "Универсал",
|
||||||
"dry-wash.order-create.car-body-select.options.coupe" : "Купе",
|
"dry-wash.order-create.car-body-select.options.coupe": "Купе",
|
||||||
"dry-wash.order-create.car-body-select.options.minivan" : "Минивэн",
|
"dry-wash.order-create.car-body-select.options.minivan": "Минивэн",
|
||||||
"dry-wash.order-create.car-body-select.options.pickup" : "Пикап",
|
"dry-wash.order-create.car-body-select.options.pickup": "Пикап",
|
||||||
"dry-wash.order-create.car-body-select.options.liftback" : "Лифтбек",
|
"dry-wash.order-create.car-body-select.options.liftback": "Лифтбек",
|
||||||
"dry-wash.order-create.car-body-select.options.sports-car" : "Спорткар",
|
"dry-wash.order-create.car-body-select.options.sports-car": "Спорткар",
|
||||||
"dry-wash.order-create.car-body-select.options.other": "Другой",
|
"dry-wash.order-create.car-body-select.options.other": "Другой",
|
||||||
"dry-wash.order-create.form.submit-button.label": "Отправить",
|
"dry-wash.order-create.form.submit-button.label": "Отправить",
|
||||||
|
"dry-wash.order-view.title": "Ваш заказ",
|
||||||
|
"dry-wash.order-view.error.title": "Ошибка",
|
||||||
|
"dry-wash.order-view.fetch.error": "Не удалось загрузить детали заказа №{{number}}",
|
||||||
|
"dry-wash.order-view.details.title": "Заказ №{{number}}",
|
||||||
|
"dry-wash.order-view.details.owner": "Владелец",
|
||||||
|
"dry-wash.order-view.details.car": "Автомобиль",
|
||||||
|
"dry-wash.order-view.details.location": "Где",
|
||||||
|
"dry-wash.order-view.details.datetime-range": "Когда",
|
||||||
|
"dry-wash.order-view.details.alert": "С вами свяжется оператор насчет оплаты по указанному номеру телефона",
|
||||||
"dry-wash.notFound.title": "Страница не найдена",
|
"dry-wash.notFound.title": "Страница не найдена",
|
||||||
"dry-wash.notFound.description": "К сожалению, запрашиваемая вами страница не существует.",
|
"dry-wash.notFound.description": "К сожалению, запрашиваемая вами страница не существует.",
|
||||||
"dry-wash.notFound.button.back": "Вернуться на главную",
|
"dry-wash.notFound.button.back": "Вернуться на главную",
|
||||||
@@ -79,4 +94,4 @@
|
|||||||
"dry-wash.errorBoundary.description": "Мы уже работаем над исправлением проблемы",
|
"dry-wash.errorBoundary.description": "Мы уже работаем над исправлением проблемы",
|
||||||
"dry-wash.errorBoundary.button.reload": "Перезагрузить страницу",
|
"dry-wash.errorBoundary.button.reload": "Перезагрузить страницу",
|
||||||
"dry-wash.washTime.timeSlot": "{{start}} - {{end}}"
|
"dry-wash.washTime.timeSlot": "{{start}} - {{end}}"
|
||||||
}
|
}
|
||||||
|
|||||||
69
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "dry-wash",
|
"name": "dry-wash",
|
||||||
"version": "0.2.0",
|
"version": "0.4.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "dry-wash",
|
"name": "dry-wash",
|
||||||
"version": "0.2.0",
|
"version": "0.4.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@brojs/cli": "^1.6.3",
|
"@brojs/cli": "^1.6.3",
|
||||||
@@ -16,11 +16,13 @@
|
|||||||
"@emotion/styled": "^11.3.0",
|
"@emotion/styled": "^11.3.0",
|
||||||
"@fontsource/open-sans": "^5.1.0",
|
"@fontsource/open-sans": "^5.1.0",
|
||||||
"@lottiefiles/react-lottie-player": "^3.5.4",
|
"@lottiefiles/react-lottie-player": "^3.5.4",
|
||||||
|
"@pbe/react-yandex-maps": "^1.2.5",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
"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",
|
||||||
|
"keycloak-js": "^23.0.7",
|
||||||
"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",
|
||||||
@@ -3594,6 +3596,21 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@pbe/react-yandex-maps": {
|
||||||
|
"version": "1.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pbe/react-yandex-maps/-/react-yandex-maps-1.2.5.tgz",
|
||||||
|
"integrity": "sha512-cBojin5e1fPx9XVCAqHQJsCnHGMeBNsP0TrNfpWCrPFfxb30ye+JgcGr2mn767Gbr1d+RufBLRiUcX2kaiAwjQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/yandex-maps": "2.1.29"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.x || ^17.x || ^18.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@pkgjs/parseargs": {
|
"node_modules/@pkgjs/parseargs": {
|
||||||
"version": "0.11.0",
|
"version": "0.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||||
@@ -3774,6 +3791,12 @@
|
|||||||
"@types/react": "*"
|
"@types/react": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/yandex-maps": {
|
||||||
|
"version": "2.1.29",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/yandex-maps/-/yandex-maps-2.1.29.tgz",
|
||||||
|
"integrity": "sha512-nuibRWj3RU/9KXlCzTrRtDE+n6V9l7NbT9JakicqZ5OXIdwyb6blvV2Uwn6lB58WYm3DSUDP2I2AWlnWMc8z2w==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "8.12.2",
|
"version": "8.12.2",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.12.2.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.12.2.tgz",
|
||||||
@@ -4707,6 +4730,25 @@
|
|||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/base64-js": {
|
||||||
|
"version": "1.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||||
|
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/binary-extensions": {
|
"node_modules/binary-extensions": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
|
||||||
@@ -8136,6 +8178,11 @@
|
|||||||
"node": ">= 10.13.0"
|
"node": ">= 10.13.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/js-sha256": {
|
||||||
|
"version": "0.10.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.10.1.tgz",
|
||||||
|
"integrity": "sha512-5obBtsz9301ULlsgggLg542s/jqtddfOpV5KJc4hajc9JV8GeY2gZHSVpYBn4nWqAUTJ9v+xwtbJ1mIBgIH5Vw=="
|
||||||
|
},
|
||||||
"node_modules/js-tokens": {
|
"node_modules/js-tokens": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||||
@@ -8229,6 +8276,24 @@
|
|||||||
"node": ">=4.0"
|
"node": ">=4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/jwt-decode": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/keycloak-js": {
|
||||||
|
"version": "23.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/keycloak-js/-/keycloak-js-23.0.7.tgz",
|
||||||
|
"integrity": "sha512-OmszsKzBhhm5yP4W1q/tMd+nNnKpOAdeVYcoGhphlv8Fj1bNk4wRTYzp7pn5BkvueLz7fhvKHz7uOc33524YrA==",
|
||||||
|
"dependencies": {
|
||||||
|
"base64-js": "^1.5.1",
|
||||||
|
"js-sha256": "^0.10.1",
|
||||||
|
"jwt-decode": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/keygrip": {
|
"node_modules/keygrip": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.1.0.tgz",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dry-wash",
|
"name": "dry-wash",
|
||||||
"version": "0.2.0",
|
"version": "0.4.0",
|
||||||
"description": "<a id=\"readme-top\"></a>",
|
"description": "<a id=\"readme-top\"></a>",
|
||||||
"main": "./src/index.tsx",
|
"main": "./src/index.tsx",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -24,11 +24,13 @@
|
|||||||
"@emotion/styled": "^11.3.0",
|
"@emotion/styled": "^11.3.0",
|
||||||
"@fontsource/open-sans": "^5.1.0",
|
"@fontsource/open-sans": "^5.1.0",
|
||||||
"@lottiefiles/react-lottie-player": "^3.5.4",
|
"@lottiefiles/react-lottie-player": "^3.5.4",
|
||||||
|
"@pbe/react-yandex-maps": "^1.2.5",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
"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",
|
||||||
|
"keycloak-js": "^23.0.7",
|
||||||
"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",
|
||||||
|
|||||||
@@ -8,8 +8,14 @@ enum ArmEndpoints {
|
|||||||
const armService = () => {
|
const armService = () => {
|
||||||
const endpoint = getConfigValue('dry-wash.api');
|
const endpoint = getConfigValue('dry-wash.api');
|
||||||
|
|
||||||
const fetchOrders = async () => {
|
const fetchOrders = async ({ date }: { date: Date }) => {
|
||||||
const response = await fetch(`${endpoint}${ArmEndpoints.ORDERS}`);
|
const response = await fetch(`${endpoint}${ArmEndpoints.ORDERS}`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ date }),
|
||||||
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Failed to fetch orders: ${response.status}`);
|
throw new Error(`Failed to fetch orders: ${response.status}`);
|
||||||
@@ -28,7 +34,67 @@ const armService = () => {
|
|||||||
return await response.json();
|
return await response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
return { fetchOrders, fetchMasters };
|
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 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 };
|
||||||
};
|
};
|
||||||
|
|
||||||
export { armService, ArmEndpoints };
|
export { armService, ArmEndpoints };
|
||||||
|
|||||||
25
src/api/landing.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { getConfigValue } from '@brojs/cli';
|
||||||
|
|
||||||
|
import { Order } from '../models/landing';
|
||||||
|
|
||||||
|
enum LandingEndpoints {
|
||||||
|
ORDER_VIEW = '/order'
|
||||||
|
}
|
||||||
|
|
||||||
|
const LandingService = () => {
|
||||||
|
const endpoint = getConfigValue('dry-wash.api');
|
||||||
|
|
||||||
|
const fetchOrder = async (orderId: Order.Id) => {
|
||||||
|
const response = await fetch(`${endpoint}${LandingEndpoints.ORDER_VIEW}/${orderId}`);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to fetch order: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await response.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
return { fetchOrder };
|
||||||
|
};
|
||||||
|
|
||||||
|
export { LandingService, LandingEndpoints };
|
||||||
BIN
src/assets/images/car-body-type/coupe.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/assets/images/car-body-type/crossover.webp
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/assets/images/car-body-type/hatchback.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
10
src/assets/images/car-body-type/index.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
export { default as CoupeImg } from './coupe.webp';
|
||||||
|
export { default as CrossoverImg } from './crossover.webp';
|
||||||
|
export { default as HatchbackImg } from './hatchback.webp';
|
||||||
|
export { default as LiftbackImg } from './liftback.webp';
|
||||||
|
export { default as MinivanImg } from './minivan.webp';
|
||||||
|
export { default as PickupImg } from './pickup.webp';
|
||||||
|
export { default as SedanImg } from './sedan.webp';
|
||||||
|
export { default as SportsCarImg } from './sports-car.webp';
|
||||||
|
export { default as StationWagonImg } from './station-wagon.webp';
|
||||||
|
export { default as SuvImg } from './suv.webp';
|
||||||
BIN
src/assets/images/car-body-type/liftback.webp
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/assets/images/car-body-type/minivan.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/assets/images/car-body-type/pickup.webp
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/assets/images/car-body-type/sedan.webp
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/assets/images/car-body-type/sports-car.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/assets/images/car-body-type/station-wagon.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/assets/images/car-body-type/suv.webp
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
@@ -1 +1,2 @@
|
|||||||
|
export * from './car-body-type';
|
||||||
export { default as DemoVideoPosterImg } from './demo-video-poster.webp';
|
export { default as DemoVideoPosterImg } from './demo-video-poster.webp';
|
||||||
31
src/components/DateNavigator/DateNavigator.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Box, Button, Text } from '@chakra-ui/react';
|
||||||
|
import { ArrowBackIcon, ArrowForwardIcon } from '@chakra-ui/icons';
|
||||||
|
|
||||||
|
interface DateNavigatorProps {
|
||||||
|
currentDate: Date;
|
||||||
|
onPreviousDate: () => void;
|
||||||
|
onNextDate: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DateNavigator = ({
|
||||||
|
currentDate,
|
||||||
|
onPreviousDate,
|
||||||
|
onNextDate,
|
||||||
|
}: DateNavigatorProps) => {
|
||||||
|
return (
|
||||||
|
<Box display='flex' alignItems='center' justifyContent='flex-start' mb='5'>
|
||||||
|
<Button onClick={onPreviousDate}>
|
||||||
|
<ArrowBackIcon />
|
||||||
|
</Button>
|
||||||
|
<Text mx='4' fontSize='lg' fontWeight='bold'>
|
||||||
|
{currentDate.toLocaleDateString()}
|
||||||
|
</Text>
|
||||||
|
<Button onClick={onNextDate}>
|
||||||
|
<ArrowForwardIcon />
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DateNavigator;
|
||||||
1
src/components/DateNavigator/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './DateNavigator';
|
||||||
119
src/components/Editable/Editable.tsx
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import {
|
||||||
|
Editable,
|
||||||
|
EditableInput,
|
||||||
|
EditablePreview,
|
||||||
|
Flex,
|
||||||
|
IconButton,
|
||||||
|
Input,
|
||||||
|
useEditableControls,
|
||||||
|
ButtonGroup,
|
||||||
|
Stack,
|
||||||
|
useToast,
|
||||||
|
} from '@chakra-ui/react';
|
||||||
|
import { CheckIcon, CloseIcon, EditIcon } from '@chakra-ui/icons';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
interface EditableWrapperProps {
|
||||||
|
value: string;
|
||||||
|
onSubmit: ({
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
phone,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
phone?: string;
|
||||||
|
}) => Promise<unknown>;
|
||||||
|
as: 'phone' | 'name';
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EditableWrapper = ({ value, onSubmit, as, id }: EditableWrapperProps) => {
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.arm.master.editable',
|
||||||
|
});
|
||||||
|
|
||||||
|
const toast = useToast();
|
||||||
|
const [currentValue, setCurrentValue] = useState<string>(value);
|
||||||
|
|
||||||
|
const handleSubmit = async (newValue: string) => {
|
||||||
|
if (currentValue === newValue) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await onSubmit({ id, [as]: newValue });
|
||||||
|
|
||||||
|
setCurrentValue(newValue);
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: 'Успешно!',
|
||||||
|
description: 'Данные обновлены.',
|
||||||
|
status: 'success',
|
||||||
|
duration: 2000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: 'Ошибка!',
|
||||||
|
description: 'Не удалось обновить данные.',
|
||||||
|
status: 'error',
|
||||||
|
duration: 2000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
console.error('Ошибка при обновлении данных:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function EditableControls() {
|
||||||
|
const {
|
||||||
|
isEditing,
|
||||||
|
getSubmitButtonProps,
|
||||||
|
getCancelButtonProps,
|
||||||
|
getEditButtonProps,
|
||||||
|
} = useEditableControls();
|
||||||
|
|
||||||
|
return isEditing ? (
|
||||||
|
<ButtonGroup justifyContent='center' size='sm'>
|
||||||
|
<IconButton
|
||||||
|
aria-label={t('aria.save')}
|
||||||
|
icon={<CheckIcon />}
|
||||||
|
{...getSubmitButtonProps()}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
aria-label={t('aria.cancel')}
|
||||||
|
icon={<CloseIcon />}
|
||||||
|
{...getCancelButtonProps()}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
|
) : (
|
||||||
|
<Flex justifyContent='center'>
|
||||||
|
<IconButton
|
||||||
|
aria-label={t('aria.edit')}
|
||||||
|
size='sm'
|
||||||
|
icon={<EditIcon />}
|
||||||
|
{...getEditButtonProps()}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Editable
|
||||||
|
textAlign='center'
|
||||||
|
defaultValue={currentValue}
|
||||||
|
fontSize='2xl'
|
||||||
|
isPreviewFocusable={false}
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
>
|
||||||
|
<Stack direction={['column', 'row']} spacing='15px'>
|
||||||
|
<EditablePreview />
|
||||||
|
<Input as={EditableInput} />
|
||||||
|
<EditableControls />
|
||||||
|
</Stack>
|
||||||
|
</Editable>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EditableWrapper;
|
||||||
@@ -5,20 +5,54 @@ import {
|
|||||||
MenuList,
|
MenuList,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
useToast,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { EditIcon } from '@chakra-ui/icons';
|
import { EditIcon } from '@chakra-ui/icons';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const MasterActionsMenu = () => {
|
import { armService } from '../../api/arm';
|
||||||
|
|
||||||
|
interface MasterActionsMenu {
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MasterActionsMenu = ({ id }: MasterActionsMenu) => {
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.arm.master.table.actionsMenu',
|
keyPrefix: 'dry-wash.arm.master.table.actionsMenu',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { deleteMaster } = armService();
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
|
const handleClickDelete = async () => {
|
||||||
|
try {
|
||||||
|
await deleteMaster({ id });
|
||||||
|
toast({
|
||||||
|
title: 'Мастер удалён.',
|
||||||
|
description: `Мастер с ID "${id}" успешно удалён.`,
|
||||||
|
status: 'success',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: 'Ошибка удаления мастера.',
|
||||||
|
description: 'Не удалось удалить мастера. Попробуйте ещё раз.',
|
||||||
|
status: 'error',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuButton icon={<EditIcon />} as={IconButton} variant='outline' />
|
<MenuButton icon={<EditIcon />} as={IconButton} variant='outline' />
|
||||||
<MenuList>
|
<MenuList>
|
||||||
<MenuItem>{t('delete')}</MenuItem>
|
<MenuItem onClick={handleClickDelete}>{t('delete')}</MenuItem>
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,15 +11,48 @@ import {
|
|||||||
DrawerFooter,
|
DrawerFooter,
|
||||||
DrawerHeader,
|
DrawerHeader,
|
||||||
DrawerOverlay,
|
DrawerOverlay,
|
||||||
|
useToast,
|
||||||
|
InputGroup,
|
||||||
|
InputLeftElement,
|
||||||
} 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 { armService } from '../../api/arm';
|
||||||
|
|
||||||
const MasterDrawer = ({ isOpen, onClose }) => {
|
const MasterDrawer = ({ isOpen, onClose }) => {
|
||||||
|
const { addMaster } = armService();
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
const [newMaster, setNewMaster] = useState({ name: '', phone: '' });
|
const [newMaster, setNewMaster] = useState({ name: '', phone: '' });
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = async () => {
|
||||||
console.log(`Сохранение мастера: ${newMaster}`);
|
if (newMaster.name.trim() === '' || newMaster.phone.trim() === '') {
|
||||||
onClose();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await addMaster(newMaster);
|
||||||
|
toast({
|
||||||
|
title: 'Мастер создан.',
|
||||||
|
description: `Мастер "${newMaster.name}" успешно добавлен.`,
|
||||||
|
status: 'success',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
onClose();
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: 'Ошибка при создании мастера.',
|
||||||
|
description: 'Не удалось добавить мастера. Попробуйте еще раз.',
|
||||||
|
status: 'error',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
@@ -36,6 +69,7 @@ const MasterDrawer = ({ isOpen, onClose }) => {
|
|||||||
<FormControl mb='4'>
|
<FormControl mb='4'>
|
||||||
<FormLabel>{t('inputName.label')}</FormLabel>
|
<FormLabel>{t('inputName.label')}</FormLabel>
|
||||||
<Input
|
<Input
|
||||||
|
// isInvalid
|
||||||
value={newMaster.name}
|
value={newMaster.name}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setNewMaster({ ...newMaster, name: e.target.value })
|
setNewMaster({ ...newMaster, name: e.target.value })
|
||||||
@@ -44,14 +78,21 @@ const MasterDrawer = ({ isOpen, onClose }) => {
|
|||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<FormLabel> {t('inputPhone.label')}</FormLabel>
|
<FormLabel>{t('inputPhone.label')}</FormLabel>
|
||||||
<Input
|
|
||||||
value={newMaster.phone}
|
<InputGroup>
|
||||||
onChange={(e) =>
|
<InputLeftElement pointerEvents='none'>
|
||||||
setNewMaster({ ...newMaster, phone: e.target.value })
|
<PhoneIcon color='gray.300' />
|
||||||
}
|
</InputLeftElement>
|
||||||
placeholder={t('inputPhone.placeholder')}
|
<Input
|
||||||
/>
|
// isInvalid
|
||||||
|
value={newMaster.phone}
|
||||||
|
onChange={(e) =>
|
||||||
|
setNewMaster({ ...newMaster, phone: e.target.value })
|
||||||
|
}
|
||||||
|
placeholder={t('inputPhone.placeholder')}
|
||||||
|
/>
|
||||||
|
</InputGroup>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</DrawerBody>
|
</DrawerBody>
|
||||||
<DrawerFooter>
|
<DrawerFooter>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Badge, Link, Stack, Td, Tr } from '@chakra-ui/react';
|
import { Badge, Stack, Td, Tr, Text } from '@chakra-ui/react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import MasterActionsMenu from '../MasterActionsMenu';
|
import MasterActionsMenu from '../MasterActionsMenu';
|
||||||
import { getTimeSlot } from '../../lib/date-helpers';
|
import { getTimeSlot } from '../../lib';
|
||||||
|
import EditableWrapper from '../Editable/Editable';
|
||||||
|
import { armService } from '../../api/arm';
|
||||||
|
|
||||||
export interface Schedule {
|
export interface Schedule {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -13,28 +16,49 @@ export interface Schedule {
|
|||||||
export type MasterProps = {
|
export type MasterProps = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
schedule: Schedule[];
|
|
||||||
phone: string;
|
phone: string;
|
||||||
|
schedule: Schedule[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const MasterItem = ({ name, schedule, phone }) => {
|
const MasterItem = ({ name, phone, id, schedule }) => {
|
||||||
|
const { updateMaster } = armService();
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.arm.master',
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tr>
|
<Tr>
|
||||||
<Td>{name}</Td>
|
|
||||||
<Td>
|
<Td>
|
||||||
<Stack direction='row'>
|
<EditableWrapper
|
||||||
{schedule.map(({ startWashTime, endWashTime }, index) => (
|
id={id}
|
||||||
<Badge colorScheme={'green'} key={index}>
|
as={'name'}
|
||||||
{getTimeSlot(startWashTime, endWashTime)}
|
value={name}
|
||||||
</Badge>
|
onSubmit={updateMaster}
|
||||||
))}
|
/>
|
||||||
</Stack>
|
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<Link href='tel:'>{phone}</Link>
|
{schedule?.length > 0 ? (
|
||||||
|
<Stack direction='row'>
|
||||||
|
{schedule?.map(({ startWashTime, endWashTime }, index: number) => (
|
||||||
|
<Badge colorScheme={'green'} key={index}>
|
||||||
|
{getTimeSlot(startWashTime, endWashTime)}
|
||||||
|
</Badge>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
) : (
|
||||||
|
<Text color='gray.500'>{t('schedule.empty')}</Text>
|
||||||
|
)}
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<MasterActionsMenu />
|
<EditableWrapper
|
||||||
|
id={id}
|
||||||
|
as={'phone'}
|
||||||
|
value={phone}
|
||||||
|
onSubmit={updateMaster}
|
||||||
|
/>
|
||||||
|
</Td>
|
||||||
|
<Td>
|
||||||
|
<MasterActionsMenu id={id} />
|
||||||
</Td>
|
</Td>
|
||||||
</Tr>
|
</Tr>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import { Td, Tr, Link, Select } from '@chakra-ui/react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { getTimeSlot } from '../../lib/date-helpers';
|
import { MasterProps } from '../MasterItem/MasterItem';
|
||||||
|
import { getTimeSlot } from '../../lib';
|
||||||
|
|
||||||
const statuses = [
|
const statuses = [
|
||||||
'pending' as const,
|
'pending' as const,
|
||||||
@@ -24,6 +25,19 @@ export type OrderProps = {
|
|||||||
status?: GetArrItemType<typeof statuses>;
|
status?: GetArrItemType<typeof statuses>;
|
||||||
phone?: string;
|
phone?: string;
|
||||||
location?: string;
|
location?: string;
|
||||||
|
master: MasterProps;
|
||||||
|
notes: '';
|
||||||
|
allMasters: MasterProps[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type Status = (typeof statuses)[number];
|
||||||
|
|
||||||
|
const statusColors: Record<Status, string> = {
|
||||||
|
pending: 'yellow.100',
|
||||||
|
progress: 'blue.100',
|
||||||
|
working: 'orange.100',
|
||||||
|
canceled: 'red.100',
|
||||||
|
complete: 'green.100',
|
||||||
};
|
};
|
||||||
|
|
||||||
const OrderItem = ({
|
const OrderItem = ({
|
||||||
@@ -34,12 +48,16 @@ const OrderItem = ({
|
|||||||
status,
|
status,
|
||||||
phone,
|
phone,
|
||||||
location,
|
location,
|
||||||
|
master,
|
||||||
|
allMasters,
|
||||||
}: OrderProps) => {
|
}: OrderProps) => {
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.arm.order',
|
keyPrefix: 'dry-wash.arm.order',
|
||||||
});
|
});
|
||||||
|
|
||||||
const [statusSelect, setStatus] = useState(status);
|
const [statusSelect, setStatus] = useState(status);
|
||||||
|
const bgColor = statusColors[statusSelect];
|
||||||
|
const [masterSelect, setMaster] = useState(master?.name);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tr>
|
<Tr>
|
||||||
@@ -51,6 +69,7 @@ const OrderItem = ({
|
|||||||
value={statusSelect}
|
value={statusSelect}
|
||||||
onChange={(e) => setStatus(e.target.value as OrderProps['status'])}
|
onChange={(e) => setStatus(e.target.value as OrderProps['status'])}
|
||||||
placeholder={t(`status.placeholder`)}
|
placeholder={t(`status.placeholder`)}
|
||||||
|
bg={bgColor}
|
||||||
>
|
>
|
||||||
{statuses.map((status) => (
|
{statuses.map((status) => (
|
||||||
<option key={status} value={status}>
|
<option key={status} value={status}>
|
||||||
@@ -59,6 +78,19 @@ const OrderItem = ({
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Td>
|
</Td>
|
||||||
|
<Td>
|
||||||
|
<Select
|
||||||
|
value={masterSelect}
|
||||||
|
onChange={(e) => setMaster(e.target.value as OrderProps['status'])}
|
||||||
|
placeholder={t(`status.placeholder`)}
|
||||||
|
>
|
||||||
|
{allMasters.map((item) => (
|
||||||
|
<option key={item.id} value={item.name}>
|
||||||
|
{item.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<Link href='tel:'>{phone}</Link>
|
<Link href='tel:'>{phone}</Link>
|
||||||
</Td>
|
</Td>
|
||||||
|
|||||||
@@ -13,16 +13,20 @@ import {
|
|||||||
useToast,
|
useToast,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
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 { armService } from '../../api/arm';
|
||||||
|
import DateNavigator from '../DateNavigator';
|
||||||
|
import { MasterProps } from '../MasterItem/MasterItem';
|
||||||
|
|
||||||
const TABLE_HEADERS = [
|
const TABLE_HEADERS = [
|
||||||
'carNumber' as const,
|
'carNumber' as const,
|
||||||
'washingTime' as const,
|
'washingTime' as const,
|
||||||
'orderDate' as const,
|
'orderDate' as const,
|
||||||
'status' as const,
|
'status' as const,
|
||||||
|
'masters' as const,
|
||||||
'telephone' as const,
|
'telephone' as const,
|
||||||
'location' as const,
|
'location' as const,
|
||||||
];
|
];
|
||||||
@@ -33,20 +37,29 @@ const Orders = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { fetchOrders } = armService();
|
const { fetchOrders } = armService();
|
||||||
|
const { fetchMasters } = armService();
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
const [orders, setOrders] = useState<OrderProps[]>([]);
|
const [orders, setOrders] = useState<OrderProps[]>([]);
|
||||||
|
const [allMasters, setAllMasters] = useState<MasterProps[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [currentDate, setCurrentDate] = useState(new Date());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadOrders = async () => {
|
const loadData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await fetchOrders();
|
const [ordersData, mastersData] = await Promise.all([
|
||||||
setOrders(data.body);
|
fetchOrders({ date: currentDate }),
|
||||||
|
fetchMasters(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
setOrders(ordersData.body);
|
||||||
|
setAllMasters(mastersData.body);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err.message);
|
setError(err.message);
|
||||||
toast({
|
toast({
|
||||||
@@ -61,14 +74,27 @@ const Orders = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loadOrders();
|
loadData();
|
||||||
}, [toast, t]);
|
}, [currentDate, toast, t]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box p='8'>
|
<Box p='8'>
|
||||||
<Heading size='lg' mb='5'>
|
<Heading size='lg' mb='5'>
|
||||||
{t('title')}
|
{t('title')}
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|
||||||
|
<DateNavigator
|
||||||
|
currentDate={currentDate}
|
||||||
|
onPreviousDate={() =>
|
||||||
|
setCurrentDate((prevDate) =>
|
||||||
|
dayjs(prevDate).subtract(1, 'day').toDate(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onNextDate={() =>
|
||||||
|
setCurrentDate((prevDate) => dayjs(prevDate).add(1, 'day').toDate())
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<Table variant='simple' colorScheme='blackAlpha'>
|
<Table variant='simple' colorScheme='blackAlpha'>
|
||||||
<Thead>
|
<Thead>
|
||||||
<Tr>
|
<Tr>
|
||||||
@@ -96,6 +122,7 @@ const Orders = () => {
|
|||||||
!error &&
|
!error &&
|
||||||
orders.map((order, index) => (
|
orders.map((order, index) => (
|
||||||
<OrderItem
|
<OrderItem
|
||||||
|
allMasters={allMasters}
|
||||||
key={index}
|
key={index}
|
||||||
{...order}
|
{...order}
|
||||||
status={order.status as OrderProps['status']}
|
status={order.status as OrderProps['status']}
|
||||||
|
|||||||
@@ -1,23 +1,92 @@
|
|||||||
import React, { forwardRef } from 'react';
|
import React, { forwardRef, useState } from 'react';
|
||||||
import { Select, SelectProps } from '@chakra-ui/react';
|
import {
|
||||||
|
Input,
|
||||||
|
Image,
|
||||||
|
InputProps,
|
||||||
|
Box,
|
||||||
|
Popover,
|
||||||
|
PopoverAnchor,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverBody,
|
||||||
|
List,
|
||||||
|
ListItem,
|
||||||
|
} from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { carBodySelectOptions } from './helper';
|
import { carBodySelectOptions } from './helper';
|
||||||
|
import { CarBodySelectOption } from './types';
|
||||||
|
|
||||||
export const CarBodySelect = forwardRef<HTMLSelectElement, SelectProps>(
|
export const CarBodySelect = forwardRef<HTMLInputElement, InputProps>(
|
||||||
function CarBodySelect(props, ref) {
|
function CarBodySelect(props, ref) {
|
||||||
|
const [selected, setSelected] = useState<Partial<CarBodySelectOption>>({});
|
||||||
|
const handleOptionClick = (option: CarBodySelectOption) => {
|
||||||
|
setSelected(option);
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
props.onChange(option.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const [isDropdownOpen, setIsDropdownOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.order-create.car-body-select',
|
keyPrefix: 'dry-wash.order-create.car-body-select',
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select ref={ref} placeholder={t('placeholder')} {...props}>
|
<Box width='100%'>
|
||||||
{carBodySelectOptions.map(({ value, labelTKey }, i) => (
|
<Popover
|
||||||
<option key={i} value={value}>
|
isOpen={isDropdownOpen}
|
||||||
{t(`options.${labelTKey}`)}
|
autoFocus={false}
|
||||||
</option>
|
placement='bottom-start'
|
||||||
))}
|
matchWidth
|
||||||
</Select>
|
>
|
||||||
|
<PopoverAnchor>
|
||||||
|
<Input
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
value={
|
||||||
|
selected?.labelTKey
|
||||||
|
? t(`options.${selected.labelTKey}`)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
readOnly
|
||||||
|
onClick={() => setIsDropdownOpen(true)}
|
||||||
|
onBlur={() => setIsDropdownOpen(false)}
|
||||||
|
placeholder={t('placeholder')}
|
||||||
|
/>
|
||||||
|
</PopoverAnchor>
|
||||||
|
<PopoverContent width='100%' maxWidth='100%'>
|
||||||
|
<PopoverBody border='1px' borderColor='gray.300' p={0}>
|
||||||
|
<List
|
||||||
|
display='grid'
|
||||||
|
gridTemplateColumns='repeat(auto-fit, minmax(150px, 1fr))'
|
||||||
|
>
|
||||||
|
{carBodySelectOptions.map((option) => (
|
||||||
|
<ListItem
|
||||||
|
key={option.value}
|
||||||
|
display='flex'
|
||||||
|
flexDirection='column'
|
||||||
|
justifyContent='flex-end'
|
||||||
|
alignItems='center'
|
||||||
|
p={2}
|
||||||
|
cursor='pointer'
|
||||||
|
_hover={{
|
||||||
|
bgColor: 'primary.50',
|
||||||
|
}}
|
||||||
|
_active={{
|
||||||
|
bgColor: 'primary.100',
|
||||||
|
}}
|
||||||
|
onClick={() => handleOptionClick(option)}
|
||||||
|
>
|
||||||
|
<Image src={option.img} />
|
||||||
|
{t(`options.${option.labelTKey}`)}
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
</PopoverBody>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
import {
|
||||||
|
CoupeImg,
|
||||||
|
CrossoverImg,
|
||||||
|
HatchbackImg,
|
||||||
|
LiftbackImg,
|
||||||
|
MinivanImg,
|
||||||
|
PickupImg,
|
||||||
|
SedanImg,
|
||||||
|
SportsCarImg,
|
||||||
|
StationWagonImg,
|
||||||
|
SuvImg
|
||||||
|
} from "../../../../assets/images";
|
||||||
import { Car } from "../../../../models/landing";
|
import { Car } from "../../../../models/landing";
|
||||||
|
|
||||||
import { CarBodySelectOption } from "./types";
|
import { CarBodySelectOption } from "./types";
|
||||||
@@ -5,43 +17,53 @@ import { CarBodySelectOption } from "./types";
|
|||||||
export const carBodySelectOptions: CarBodySelectOption[] = [
|
export const carBodySelectOptions: CarBodySelectOption[] = [
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.SEDAN,
|
value: Car.BodyStyle.SEDAN,
|
||||||
labelTKey: 'sedan'
|
labelTKey: 'sedan',
|
||||||
|
img: SedanImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.HATCHBACK,
|
value: Car.BodyStyle.HATCHBACK,
|
||||||
labelTKey: 'hatchback'
|
labelTKey: 'hatchback',
|
||||||
|
img: HatchbackImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.CROSSOVER,
|
value: Car.BodyStyle.CROSSOVER,
|
||||||
labelTKey: 'crossover'
|
labelTKey: 'crossover',
|
||||||
|
img: CrossoverImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.SUV,
|
value: Car.BodyStyle.SUV,
|
||||||
labelTKey: 'suv'
|
labelTKey: 'suv',
|
||||||
|
img: SuvImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.STATION_WAGON,
|
value: Car.BodyStyle.STATION_WAGON,
|
||||||
labelTKey: 'station-wagon'
|
labelTKey: 'station-wagon',
|
||||||
|
img: StationWagonImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.COUPE,
|
value: Car.BodyStyle.COUPE,
|
||||||
labelTKey: 'coupe'
|
labelTKey: 'coupe',
|
||||||
|
img: CoupeImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.MINIVAN,
|
value: Car.BodyStyle.MINIVAN,
|
||||||
labelTKey: 'minivan'
|
labelTKey: 'minivan',
|
||||||
|
img: MinivanImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.PICKUP,
|
value: Car.BodyStyle.PICKUP,
|
||||||
labelTKey: 'pickup'
|
labelTKey: 'pickup',
|
||||||
|
img: PickupImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.LIFTBACK,
|
value: Car.BodyStyle.LIFTBACK,
|
||||||
labelTKey: 'liftback'
|
labelTKey: 'liftback',
|
||||||
|
img: LiftbackImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.SPORTS_CAR,
|
value: Car.BodyStyle.SPORTS_CAR,
|
||||||
labelTKey: 'sports-car'
|
labelTKey: 'sports-car',
|
||||||
|
img: SportsCarImg
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: Car.BodyStyle.OTHER,
|
value: Car.BodyStyle.OTHER,
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ export type CarBodySelectOption = {
|
|||||||
'liftback' |
|
'liftback' |
|
||||||
'sports-car' |
|
'sports-car' |
|
||||||
'other';
|
'other';
|
||||||
|
img?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const CarNumberInput = forwardRef<HTMLInputElement, InputProps>(
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
onChange?.(formattedValue);
|
onChange?.(formattedValue);
|
||||||
}}
|
}}
|
||||||
maxLength={8}
|
maxLength={12}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ const VALID_LETTER = 'а|в|е|к|м|н|о|р|с|т|у|х';
|
|||||||
const invalidCharsRe = new RegExp(`[^(${VALID_LETTER})0-9]`, 'gi');
|
const invalidCharsRe = new RegExp(`[^(${VALID_LETTER})0-9]`, 'gi');
|
||||||
const cleanValue = (value: string) => value.replace(invalidCharsRe, '');
|
const cleanValue = (value: string) => value.replace(invalidCharsRe, '');
|
||||||
|
|
||||||
const validCarNumberInputRe = new RegExp(`^([${VALID_LETTER}]{1}|$)((?:[0-9]|$)(?:[0-9]|$)(?:[0-9]|$))([${VALID_LETTER}]{1,2}|$)$`, 'gi');
|
const validCarNumberInputRe = new RegExp(`^([${VALID_LETTER}]{1}|$)((?:[0-9]|$)(?:[0-9]|$)(?:[0-9]|$))([${VALID_LETTER}]{1,2}|$)((?:[0-9]|$)(?:[0-9]|$)(?:[0-9]|$))$`, 'gi');
|
||||||
const isValidInput = (cleanedValue: string) => validCarNumberInputRe.test(cleanedValue);
|
const isValidInput = (cleanedValue: string) => validCarNumberInputRe.test(cleanedValue);
|
||||||
|
|
||||||
const formatAsCarNumber = (cleanedValue: string) => {
|
const formatAsCarNumber = (cleanedValue: string) => {
|
||||||
return cleanedValue.replace(validCarNumberInputRe, (_, p1, p2, p3) => [p1, p2, p3].join(' ')).toUpperCase();
|
return cleanedValue.replace(validCarNumberInputRe, (_, p1, p2, p3, p4) => [p1, p2, p3, p4].join(' ')).toUpperCase();
|
||||||
};
|
};
|
||||||
const getWithoutLastChar = (value: string) => value.substring(0, value.length - 1);
|
const getWithoutLastChar = (value: string) => value.substring(0, value.length - 1);
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ export const handleInputChange = (value: string | undefined | null) => {
|
|||||||
return getWithoutLastChar(value).trim();
|
return getWithoutLastChar(value).trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
const validCarNumberRe = new RegExp(`^[${VALID_LETTER}][0-9]{3}[${VALID_LETTER}]{2}$`, 'i');
|
const validCarNumberRe = new RegExp(`^[${VALID_LETTER}][0-9]{3}[${VALID_LETTER}]{2}[0-9]{2,3}$`, 'i');
|
||||||
|
|
||||||
export const isValidCarNumber = (value: string) => {
|
export const isValidCarNumber = (value: string) => {
|
||||||
const cleanedValue = cleanValue(value);
|
const cleanedValue = cleanValue(value);
|
||||||
|
|||||||
15
src/components/order-form/form/location/helper.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Location, StringCoordinates, StringLocation } from "./types";
|
||||||
|
|
||||||
|
export const splitLocation = (stringifiedLocation: StringLocation) => {
|
||||||
|
return stringifiedLocation.replace(' ', '~').split('~');
|
||||||
|
};
|
||||||
|
|
||||||
|
export const stringifyLocation = (location: Location): StringLocation => {
|
||||||
|
const { coordinates, address } = location;
|
||||||
|
const [latitude, longitude] = coordinates;
|
||||||
|
const coordinatesString = `${latitude},${longitude}` satisfies StringCoordinates;
|
||||||
|
return `${coordinatesString} ${address}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const locationRe = new RegExp(/^[-0-9]+.[0-9]+,[-0-9]+.[0-9]+ .*/);
|
||||||
|
export const isValidLocation = (value: string): value is StringLocation => locationRe.test(value);
|
||||||
4
src/components/order-form/form/location/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export type { StringLocation } from './types';
|
||||||
|
export * from './location-input';
|
||||||
|
export * from './map';
|
||||||
|
export * from './ymaps';
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { YMapsApi } from "@pbe/react-yandex-maps/typings/util/typing";
|
||||||
|
|
||||||
|
import { Address, Location, StringLocation } from "../types";
|
||||||
|
import { splitLocation, stringifyLocation } from "../helper";
|
||||||
|
|
||||||
|
export const formatLocation = (location: Location | undefined): StringLocation | '' => {
|
||||||
|
if (!location) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return stringifyLocation(location);
|
||||||
|
};
|
||||||
|
|
||||||
|
const coordinatesRe = new RegExp(/^[-0-9]+.[0-9]+,[-0-9]+.[0-9]+/);
|
||||||
|
export const extractAddress = (value: string) => value.replace(coordinatesRe, '').trim();
|
||||||
|
|
||||||
|
export const getLocationByAddress = async (ymaps: YMapsApi, address: Address): Promise<Location> => {
|
||||||
|
try {
|
||||||
|
const result = await ymaps.geocode(address);
|
||||||
|
const firstGeoObject = result.geoObjects.get(
|
||||||
|
0,
|
||||||
|
) as unknown as ymaps.IGeoObject<ymaps.IBasePointGeometry>;
|
||||||
|
const [latitude, longitude] = firstGeoObject.geometry.getCoordinates();
|
||||||
|
return { coordinates: [latitude, longitude], address };
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const isRealLocation = async (ymaps: YMapsApi, stringifiedLocation: StringLocation) => {
|
||||||
|
const [coordinates, address] = splitLocation(stringifiedLocation);
|
||||||
|
try {
|
||||||
|
const result = await ymaps.geocode(coordinates);
|
||||||
|
const firstGeoObject = result.geoObjects.get(0) as ymaps.GeocodeResult;
|
||||||
|
const addressByCoordinates = firstGeoObject.getAddressLine();
|
||||||
|
|
||||||
|
return address === addressByCoordinates;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { LocationInput } from './location-input';
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
import React, { forwardRef, memo, useEffect, useState } from 'react';
|
||||||
|
import {
|
||||||
|
Input,
|
||||||
|
Box,
|
||||||
|
InputProps,
|
||||||
|
PopoverAnchor,
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverBody,
|
||||||
|
List,
|
||||||
|
ListItem,
|
||||||
|
} from '@chakra-ui/react';
|
||||||
|
import { withYMaps } from '@pbe/react-yandex-maps';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { Suggestion } from '../types';
|
||||||
|
import { isValidLocation } from '../helper';
|
||||||
|
|
||||||
|
import {
|
||||||
|
formatLocation,
|
||||||
|
getLocationByAddress,
|
||||||
|
isRealLocation,
|
||||||
|
extractAddress,
|
||||||
|
} from './helper';
|
||||||
|
import { LocationInputProps } from './types';
|
||||||
|
|
||||||
|
export const LocationInput = memo(
|
||||||
|
withYMaps(
|
||||||
|
forwardRef<HTMLInputElement, LocationInputProps>(function LocationInput(
|
||||||
|
{ ymaps, value, onChange, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
const [inputValue, setInputValue] = useState<string>('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setInputValue(value);
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
|
const [suggestions, setSuggestions] = useState<Suggestion[]>([]);
|
||||||
|
const [isSuggestionsPanelOpen, setIsSuggestionsPanelOpen] =
|
||||||
|
useState<boolean>(false);
|
||||||
|
|
||||||
|
const onInputChange: InputProps['onChange'] = async (e) => {
|
||||||
|
const newInputValue = e.target.value;
|
||||||
|
setInputValue(newInputValue);
|
||||||
|
|
||||||
|
if (newInputValue.trim().length > 3) {
|
||||||
|
try {
|
||||||
|
const address = extractAddress(newInputValue);
|
||||||
|
const results = await ymaps.suggest(address);
|
||||||
|
setSuggestions(results);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setSuggestions([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onFocus: InputProps['onFocus'] = () => {
|
||||||
|
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onBlur: InputProps['onBlur'] = async (e) => {
|
||||||
|
const inputValue = e.target.value;
|
||||||
|
if (
|
||||||
|
isValidLocation(inputValue) &&
|
||||||
|
(await isRealLocation(ymaps, inputValue))
|
||||||
|
) {
|
||||||
|
onChange(inputValue);
|
||||||
|
} else {
|
||||||
|
setInputValue(value);
|
||||||
|
}
|
||||||
|
setIsSuggestionsPanelOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSuggestionClick = async ({ value: address }: Suggestion) => {
|
||||||
|
try {
|
||||||
|
const location = await getLocationByAddress(ymaps, address);
|
||||||
|
const newValue = formatLocation(location);
|
||||||
|
setInputValue(newValue);
|
||||||
|
onChange(newValue);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.order-create.form.washing-location-field',
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box width='100%'>
|
||||||
|
<Popover
|
||||||
|
isOpen={isSuggestionsPanelOpen}
|
||||||
|
autoFocus={false}
|
||||||
|
placement='bottom-start'
|
||||||
|
>
|
||||||
|
<PopoverAnchor>
|
||||||
|
<Input
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
onBlur={onBlur}
|
||||||
|
value={inputValue}
|
||||||
|
onChange={onInputChange}
|
||||||
|
onFocus={onFocus}
|
||||||
|
placeholder={t('placeholder')}
|
||||||
|
/>
|
||||||
|
</PopoverAnchor>
|
||||||
|
<PopoverContent width='100%' maxWidth='100%'>
|
||||||
|
<PopoverBody border='1px' borderColor='gray.300' p={0}>
|
||||||
|
<List>
|
||||||
|
{suggestions.map((suggestion, index) => (
|
||||||
|
<ListItem
|
||||||
|
key={index}
|
||||||
|
p={2}
|
||||||
|
cursor='pointer'
|
||||||
|
_hover={{
|
||||||
|
bgColor: 'primary.50',
|
||||||
|
}}
|
||||||
|
_active={{
|
||||||
|
bgColor: 'primary.100',
|
||||||
|
}}
|
||||||
|
onClick={() => handleSuggestionClick(suggestion)}
|
||||||
|
>
|
||||||
|
{suggestion.displayName}
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
</PopoverBody>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
true,
|
||||||
|
['suggest', 'geocode'],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// todo: i18n
|
||||||
|
// todo: replace console.error with toast
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { YMapsApi } from "@pbe/react-yandex-maps/typings/util/typing";
|
||||||
|
import { InputProps } from "@chakra-ui/react";
|
||||||
|
|
||||||
|
export type LocationInputProps = InputProps & {
|
||||||
|
ymaps?: YMapsApi;
|
||||||
|
value?: string;
|
||||||
|
onChange?: (value: string) => void;
|
||||||
|
};
|
||||||
10
src/components/order-form/form/location/map/helper.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { splitLocation } from "../helper";
|
||||||
|
import { Coordinate, Location, StringLocation } from "../types";
|
||||||
|
|
||||||
|
export const KAZAN_CITY_CENTER: Coordinate[] = [55.797557, 49.107295];
|
||||||
|
|
||||||
|
export const parseLocation = (stringifiedLocation: StringLocation): Location => {
|
||||||
|
const [coordinatesStr, address] = splitLocation(stringifiedLocation);
|
||||||
|
const [latitude, longitude] = coordinatesStr.split(',').map(Number);
|
||||||
|
return { coordinates: [latitude, longitude], address };
|
||||||
|
};
|
||||||
1
src/components/order-form/form/location/map/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { MapComponent } from './map';
|
||||||
70
src/components/order-form/form/location/map/map.tsx
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import React, { FC, memo, useEffect, useState } from 'react';
|
||||||
|
import {
|
||||||
|
Map,
|
||||||
|
Placemark,
|
||||||
|
GeolocationControl,
|
||||||
|
ZoomControl,
|
||||||
|
withYMaps,
|
||||||
|
} from '@pbe/react-yandex-maps';
|
||||||
|
import { YMapsApi } from '@pbe/react-yandex-maps/typings/util/typing';
|
||||||
|
|
||||||
|
import { Coordinate, StringLocation } from '../types';
|
||||||
|
import { isValidLocation, stringifyLocation } from '../helper';
|
||||||
|
|
||||||
|
import { KAZAN_CITY_CENTER, parseLocation } from './helper';
|
||||||
|
|
||||||
|
export const MapComponent: FC<{
|
||||||
|
ymaps?: YMapsApi;
|
||||||
|
selectedLocation: StringLocation | null;
|
||||||
|
onMapClick: (props: StringLocation) => void;
|
||||||
|
}> = memo(
|
||||||
|
withYMaps(
|
||||||
|
({ ymaps, selectedLocation, onMapClick }) => {
|
||||||
|
const [mapCenter, setMapCenter] =
|
||||||
|
useState<Coordinate[]>(KAZAN_CITY_CENTER);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isValidLocation(selectedLocation)) {
|
||||||
|
const location = parseLocation(selectedLocation);
|
||||||
|
const { coordinates } = location;
|
||||||
|
setMapCenter(coordinates);
|
||||||
|
}
|
||||||
|
}, [selectedLocation]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Map
|
||||||
|
state={{
|
||||||
|
center: mapCenter,
|
||||||
|
zoom:
|
||||||
|
isValidLocation(selectedLocation) &&
|
||||||
|
parseLocation(selectedLocation)?.coordinates
|
||||||
|
? 17
|
||||||
|
: 10,
|
||||||
|
}}
|
||||||
|
width='100%'
|
||||||
|
onClick={async (e: ymaps.MapEvent) => {
|
||||||
|
try {
|
||||||
|
const coordinates = e.get('coords');
|
||||||
|
const address = await ymaps.geocode(coordinates).then((res) => {
|
||||||
|
const firstGeoObject = res.geoObjects.get(
|
||||||
|
0,
|
||||||
|
) as ymaps.GeocodeResult;
|
||||||
|
return firstGeoObject.getAddressLine();
|
||||||
|
});
|
||||||
|
onMapClick(stringifyLocation({ coordinates, address }));
|
||||||
|
setMapCenter(coordinates);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GeolocationControl options={{ float: 'left' }} />
|
||||||
|
<ZoomControl />
|
||||||
|
{selectedLocation && <Placemark geometry={mapCenter} />}
|
||||||
|
</Map>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
['geocode'],
|
||||||
|
),
|
||||||
|
);
|
||||||
17
src/components/order-form/form/location/types.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export type Address = string;
|
||||||
|
|
||||||
|
export type Suggestion = {
|
||||||
|
value: Address;
|
||||||
|
displayName: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Coordinate = number;
|
||||||
|
|
||||||
|
export type Location = {
|
||||||
|
address: Address;
|
||||||
|
coordinates: [Coordinate, Coordinate];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StringCoordinates = `${Coordinate},${Coordinate}`;
|
||||||
|
|
||||||
|
export type StringLocation = `${StringCoordinates} ${Address}`;
|
||||||
1
src/components/order-form/form/location/ymaps/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { YMapsProvider } from './ymaps-provider';
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { YMaps } from '@pbe/react-yandex-maps';
|
||||||
|
import React, { PropsWithChildren } from 'react';
|
||||||
|
|
||||||
|
export const YMapsProvider = ({ children }: PropsWithChildren) => {
|
||||||
|
return (
|
||||||
|
<YMaps
|
||||||
|
query={{
|
||||||
|
lang: 'ru_RU',
|
||||||
|
apikey: '19cbc387-db9a-4807-a620-5205215db40f',
|
||||||
|
suggest_apikey: '3576e65e-5e75-4ea2-b21c-7f9db112682e',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</YMaps>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,14 +1,7 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import { Box, Flex, FormControl, FormLabel, VStack } from '@chakra-ui/react';
|
||||||
Box,
|
|
||||||
Flex,
|
|
||||||
FormControl,
|
|
||||||
FormLabel,
|
|
||||||
Input,
|
|
||||||
VStack,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
|
|
||||||
import { CarBodySelect } from './car-body';
|
import { CarBodySelect } from './car-body';
|
||||||
import { CarColorInput } from './car-color';
|
import { CarColorInput } from './car-color';
|
||||||
@@ -19,6 +12,7 @@ import { PhoneInput } from './phone';
|
|||||||
import { SubmitButton } from './submit';
|
import { SubmitButton } from './submit';
|
||||||
import { defaultValues, onSubmit, useGetValidationRules } from './helper';
|
import { defaultValues, onSubmit, useGetValidationRules } from './helper';
|
||||||
import { DateTimeInput } from './date-time';
|
import { DateTimeInput } from './date-time';
|
||||||
|
import { LocationInput, MapComponent, StringLocation, YMapsProvider } from './location';
|
||||||
|
|
||||||
export const OrderForm: FC = () => {
|
export const OrderForm: FC = () => {
|
||||||
const {
|
const {
|
||||||
@@ -26,6 +20,7 @@ export const OrderForm: FC = () => {
|
|||||||
control,
|
control,
|
||||||
formState: { errors, isSubmitting },
|
formState: { errors, isSubmitting },
|
||||||
watch,
|
watch,
|
||||||
|
setValue,
|
||||||
} = useForm<OrderFormValues>({ defaultValues, shouldFocusError: true });
|
} = useForm<OrderFormValues>({ defaultValues, shouldFocusError: true });
|
||||||
|
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
@@ -34,9 +29,10 @@ export const OrderForm: FC = () => {
|
|||||||
|
|
||||||
const RULES = useGetValidationRules();
|
const RULES = useGetValidationRules();
|
||||||
|
|
||||||
const [availableDatetimeBegin, availableDatetimeEnd] = watch([
|
const [availableDatetimeBegin, availableDatetimeEnd, carLocation] = watch([
|
||||||
'availableDatetimeBegin',
|
'availableDatetimeBegin',
|
||||||
'availableDatetimeEnd',
|
'availableDatetimeEnd',
|
||||||
|
'carLocation',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -81,15 +77,6 @@ export const OrderForm: FC = () => {
|
|||||||
errors={errors}
|
errors={errors}
|
||||||
Input={CarBodySelect}
|
Input={CarBodySelect}
|
||||||
/>
|
/>
|
||||||
<FormInputField
|
|
||||||
control={control}
|
|
||||||
name='carLocation'
|
|
||||||
label={t('washing-location-field.label')}
|
|
||||||
isRequired
|
|
||||||
errors={errors}
|
|
||||||
Input={Input}
|
|
||||||
help={t('washing-location-field.help')}
|
|
||||||
/>
|
|
||||||
<FormControl isRequired>
|
<FormControl isRequired>
|
||||||
<FormLabel>{t('washing-datetime-field.label')}</FormLabel>
|
<FormLabel>{t('washing-datetime-field.label')}</FormLabel>
|
||||||
<Flex flexWrap='wrap' gap={4}>
|
<Flex flexWrap='wrap' gap={4}>
|
||||||
@@ -119,6 +106,23 @@ export const OrderForm: FC = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
<YMapsProvider>
|
||||||
|
<FormInputField
|
||||||
|
control={control}
|
||||||
|
name='carLocation'
|
||||||
|
label={t('washing-location-field.label')}
|
||||||
|
help={t('washing-location-field.help')}
|
||||||
|
isRequired
|
||||||
|
errors={errors}
|
||||||
|
Input={LocationInput}
|
||||||
|
/>
|
||||||
|
<MapComponent
|
||||||
|
selectedLocation={carLocation as StringLocation}
|
||||||
|
onMapClick={(location) => {
|
||||||
|
setValue('carLocation', location);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</YMapsProvider>
|
||||||
<SubmitButton isLoading={isSubmitting} mt={4} />
|
<SubmitButton isLoading={isSubmitting} mt={4} />
|
||||||
</VStack>
|
</VStack>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -126,5 +130,4 @@ export const OrderForm: FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// todo: remove layout shift, when a validation message is displayed
|
// todo: remove layout shift, when a validation message is displayed
|
||||||
// todo: select location using an interactive map
|
// todo: fix time range available values
|
||||||
// todo: fix time range available values
|
|
||||||
|
|||||||
1
src/components/order-view/details/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { OrderDetails } from './order-details';
|
||||||
99
src/components/order-view/details/order-details.tsx
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
import React, { FC } from 'react';
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
AlertIcon,
|
||||||
|
Heading,
|
||||||
|
HStack,
|
||||||
|
UnorderedList,
|
||||||
|
VStack,
|
||||||
|
ListItem,
|
||||||
|
Text,
|
||||||
|
} from '@chakra-ui/react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { Order } from '../../../models/landing';
|
||||||
|
import { formatDatetime } from '../../../lib';
|
||||||
|
import { carBodySelectOptions } from '../../order-form/form/car-body/helper';
|
||||||
|
|
||||||
|
import { OrderStatus } from './status';
|
||||||
|
|
||||||
|
type OrderDetailsProps = Order.View;
|
||||||
|
|
||||||
|
export const OrderDetails: FC<OrderDetailsProps> = ({
|
||||||
|
id,
|
||||||
|
status,
|
||||||
|
phone,
|
||||||
|
carNumber,
|
||||||
|
carBody,
|
||||||
|
carColor,
|
||||||
|
location,
|
||||||
|
datetimeBegin,
|
||||||
|
datetimeEnd,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.order-view.details',
|
||||||
|
});
|
||||||
|
const { t: tCarBody } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.order-create.car-body-select.options',
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<VStack p={4} alignItems='flex-start' gap={4}>
|
||||||
|
<HStack
|
||||||
|
width='full'
|
||||||
|
flexWrap='wrap'
|
||||||
|
justifyContent='space-between'
|
||||||
|
gap={2}
|
||||||
|
>
|
||||||
|
<Heading as='h2' size='lg'>
|
||||||
|
{t('title', { number: id })}
|
||||||
|
</Heading>
|
||||||
|
<OrderStatus value={status} />
|
||||||
|
</HStack>
|
||||||
|
<UnorderedList styleType='none'>
|
||||||
|
{[
|
||||||
|
{
|
||||||
|
label: t('owner'),
|
||||||
|
value: phone,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('car'),
|
||||||
|
value: [
|
||||||
|
carNumber,
|
||||||
|
tCarBody(
|
||||||
|
`${carBodySelectOptions.find(({ value }) => value === carBody)?.labelTKey}`,
|
||||||
|
),
|
||||||
|
carColor,
|
||||||
|
]
|
||||||
|
.filter((v) => v)
|
||||||
|
.join(', '),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('location'),
|
||||||
|
value: location,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('datetime-range'),
|
||||||
|
value: [
|
||||||
|
formatDatetime(datetimeBegin),
|
||||||
|
formatDatetime(datetimeEnd),
|
||||||
|
].join(' - '),
|
||||||
|
},
|
||||||
|
].map(({ label, value }, i) => (
|
||||||
|
<ListItem key={i}>
|
||||||
|
{label}:{' '}
|
||||||
|
<Text as='span' color='primary.500' fontWeight='bold'>
|
||||||
|
{value}
|
||||||
|
</Text>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</UnorderedList>
|
||||||
|
<Alert status='info' alignItems='flex-start'>
|
||||||
|
<AlertIcon />
|
||||||
|
{t('alert')}
|
||||||
|
</Alert>
|
||||||
|
</VStack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// todo: add i18n for date & time
|
||||||
1
src/components/order-view/details/status/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { OrderStatus } from './order-status';
|
||||||
49
src/components/order-view/details/status/order-status.tsx
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { Tag, TagProps } from '@chakra-ui/react';
|
||||||
|
import React, { FC } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
|
||||||
|
import { Order } from '../../../../models/landing';
|
||||||
|
|
||||||
|
const getPropsByStatus = (
|
||||||
|
status: Order.Status,
|
||||||
|
t: TFunction<'~', 'dry-wash.arm.order.status'>,
|
||||||
|
): TagProps => {
|
||||||
|
switch (status) {
|
||||||
|
case 'canceled':
|
||||||
|
return {
|
||||||
|
colorScheme: 'red',
|
||||||
|
children: t('canceled'),
|
||||||
|
};
|
||||||
|
case 'progress':
|
||||||
|
return {
|
||||||
|
colorScheme: 'yellow',
|
||||||
|
children: t('progress'),
|
||||||
|
};
|
||||||
|
case 'pending':
|
||||||
|
return {
|
||||||
|
colorScheme: 'yellow',
|
||||||
|
children: t('pending'),
|
||||||
|
};
|
||||||
|
case 'working':
|
||||||
|
return {
|
||||||
|
colorScheme: 'yellow',
|
||||||
|
children: t('working'),
|
||||||
|
};
|
||||||
|
case 'complete':
|
||||||
|
return {
|
||||||
|
colorScheme: 'green',
|
||||||
|
children: t('complete'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const OrderStatus: FC<{ value: Order.Status }> = ({ value }) => {
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.arm.order.status',
|
||||||
|
});
|
||||||
|
|
||||||
|
const props = getPropsByStatus(value, t);
|
||||||
|
|
||||||
|
return <Tag variant='solid' {...props} />;
|
||||||
|
};
|
||||||
1
src/components/order-view/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './details';
|
||||||
34
src/keycloak.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import Keycloak from 'keycloak-js';
|
||||||
|
|
||||||
|
const keycloak = new Keycloak({
|
||||||
|
url: 'https://kc.bro-js.ru',
|
||||||
|
realm: 'open',
|
||||||
|
clientId: 'dry-wash',
|
||||||
|
});
|
||||||
|
|
||||||
|
const authLogin = async ({ redirect }) => {
|
||||||
|
let user = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const authenticated = await keycloak.init({ onLoad: 'login-required' });
|
||||||
|
if (authenticated) {
|
||||||
|
user = { ...(await keycloak.loadUserInfo()), ...keycloak.tokenParsed };
|
||||||
|
|
||||||
|
const isOperator =
|
||||||
|
user?.resource_access?.['dry-wash']?.roles.includes('operator');
|
||||||
|
|
||||||
|
if (!isOperator) {
|
||||||
|
redirect();
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
|
} else {
|
||||||
|
console.log('User is not authenticated');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
keycloak.login();
|
||||||
|
console.error('Failed to initialize adapter:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default authLogin;
|
||||||
@@ -10,3 +10,7 @@ export const getTimeSlot = (start: string, end: string) => {
|
|||||||
end: endDay,
|
end: endDay,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const formatDatetime = (datetime: string) => {
|
||||||
|
return dayjs(datetime).format('HH:mm DD.MM.YYYY');
|
||||||
|
};
|
||||||
@@ -1 +1,2 @@
|
|||||||
|
export * from './date-helpers';
|
||||||
export * from './types';
|
export * from './types';
|
||||||
@@ -1,2 +1 @@
|
|||||||
export * as mockOrder from './order';
|
|
||||||
export * as mockReview from './review';
|
export * as mockReview from './review';
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { Order } from "../../models";
|
|
||||||
|
|
||||||
export const orders: Order.View[] = [
|
|
||||||
{ id: 'id1' },
|
|
||||||
{ id: 'id2' },
|
|
||||||
{ id: 'id3' },
|
|
||||||
];
|
|
||||||
1
src/models/api/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './order-view';
|
||||||
14
src/models/api/order-view.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { Order } from "../landing";
|
||||||
|
|
||||||
|
export type FetchOrderQueryResponse = {
|
||||||
|
id: string;
|
||||||
|
orderDate: string;
|
||||||
|
carNumber: string;
|
||||||
|
carBody: number;
|
||||||
|
carColor?: string;
|
||||||
|
startWashTime: string;
|
||||||
|
endWashTime: string;
|
||||||
|
status: Order.Status;
|
||||||
|
phone: string;
|
||||||
|
location: string;
|
||||||
|
};
|
||||||
@@ -2,6 +2,12 @@ import { Car, Customer, Washing } from ".";
|
|||||||
|
|
||||||
export type Id = string;
|
export type Id = string;
|
||||||
|
|
||||||
|
export type Status = 'pending' |
|
||||||
|
'progress' |
|
||||||
|
'working' |
|
||||||
|
'canceled' |
|
||||||
|
'complete';
|
||||||
|
|
||||||
export type Create = {
|
export type Create = {
|
||||||
customer: {
|
customer: {
|
||||||
phone: Customer.PhoneNumber,
|
phone: Customer.PhoneNumber,
|
||||||
@@ -20,4 +26,13 @@ export type Create = {
|
|||||||
|
|
||||||
export type View = {
|
export type View = {
|
||||||
id: Id;
|
id: Id;
|
||||||
|
orderDate: string,
|
||||||
|
status: Status,
|
||||||
|
phone: Customer.PhoneNumber;
|
||||||
|
carNumber: Car.RegistrationNumber;
|
||||||
|
carBody: Car.BodyStyle;
|
||||||
|
carColor?: Car.Color;
|
||||||
|
location: Washing.Location;
|
||||||
|
datetimeBegin: Washing.AvailableBeginDateTime;
|
||||||
|
datetimeEnd: Washing.AvailableEndDateTime;
|
||||||
};
|
};
|
||||||
@@ -1,8 +1,31 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { AbsoluteCenter, Box, Spinner } from '@chakra-ui/react';
|
||||||
|
|
||||||
import LayoutArm from '../../components/LayoutArm';
|
import LayoutArm from '../../components/LayoutArm';
|
||||||
|
import authLogin from '../../keycloak';
|
||||||
|
import { URLs } from '../../__data__/urls';
|
||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
|
const [user, setUser] = useState(null);
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
authLogin({ redirect: () => navigate(URLs.landing.url) }).then((user) =>
|
||||||
|
setUser(user),
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!user)
|
||||||
|
return (
|
||||||
|
<Box position='relative' height='100vh'>
|
||||||
|
<AbsoluteCenter>
|
||||||
|
<Spinner />
|
||||||
|
</AbsoluteCenter>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
|
||||||
return <LayoutArm />;
|
return <LayoutArm />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,15 @@ import React from 'react';
|
|||||||
import { Text, Button, Center, VStack, Heading } from '@chakra-ui/react';
|
import { Text, Button, Center, VStack, Heading } from '@chakra-ui/react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { Player } from '@lottiefiles/react-lottie-player';
|
import { Player } from '@lottiefiles/react-lottie-player';
|
||||||
import i18next from 'i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import animate from '../../assets/animation/notFound.json';
|
import animate from '../../assets/animation/notFound.json';
|
||||||
|
|
||||||
const NotFound = () => {
|
const NotFound = () => {
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash',
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Center minH='100vh'>
|
<Center minH='100vh'>
|
||||||
<VStack spacing={4} textAlign='center'>
|
<VStack spacing={4} textAlign='center'>
|
||||||
@@ -21,12 +25,8 @@ const NotFound = () => {
|
|||||||
maxWidth: '450px',
|
maxWidth: '450px',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Heading fontSize='xl'>
|
<Heading fontSize='xl'>{t(`notFound.title`)}</Heading>
|
||||||
{i18next.t(`dry-wash.arm.notFound.title`)}
|
<Text fontSize='lg'>{t(`notFound.description`)}</Text>
|
||||||
</Heading>
|
|
||||||
<Text fontSize='lg'>
|
|
||||||
{i18next.t(`dry-wash.arm.notFound.description`)}
|
|
||||||
</Text>
|
|
||||||
<Button
|
<Button
|
||||||
as={Link}
|
as={Link}
|
||||||
to='/dry-wash'
|
to='/dry-wash'
|
||||||
@@ -34,7 +34,7 @@ const NotFound = () => {
|
|||||||
size='lg'
|
size='lg'
|
||||||
variant='outline'
|
variant='outline'
|
||||||
>
|
>
|
||||||
{i18next.t(`dry-wash.arm.notFound.button.back`)}
|
{t(`notFound.button.back`)}
|
||||||
</Button>
|
</Button>
|
||||||
</VStack>
|
</VStack>
|
||||||
</Center>
|
</Center>
|
||||||
|
|||||||
40
src/pages/order-view/helper.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
import { LandingService } from '../../api/landing';
|
||||||
|
import { Order } from '../../models/landing';
|
||||||
|
import { FetchOrderQueryResponse } from '../../models/api';
|
||||||
|
|
||||||
|
export const useFetchOrderDetails = ({
|
||||||
|
orderId,
|
||||||
|
}: {
|
||||||
|
orderId: Order.View['id'];
|
||||||
|
}) => {
|
||||||
|
const { fetchOrder } = LandingService();
|
||||||
|
|
||||||
|
const [data, setData] = useState<FetchOrderQueryResponse>();
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchData = async () => {
|
||||||
|
setIsLoading(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await fetchOrder(orderId);
|
||||||
|
setData(data.body);
|
||||||
|
} catch (error) {
|
||||||
|
setError(error.message);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
isLoading,
|
||||||
|
data,
|
||||||
|
error,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,7 +1,75 @@
|
|||||||
import React from "react";
|
import React, { FC, useEffect } from 'react';
|
||||||
|
import { HStack, Spinner, useToast } from '@chakra-ui/react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Container, Heading, VStack } from '@chakra-ui/react';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
const Page = () => {
|
import { LandingThemeProvider } from '../../containers';
|
||||||
return <h1>Order view</h1>;
|
import { OrderDetails } from '../../components/order-view';
|
||||||
|
|
||||||
|
import { useFetchOrderDetails } from './helper';
|
||||||
|
|
||||||
|
const Page: FC = () => {
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.order-view',
|
||||||
|
});
|
||||||
|
|
||||||
|
const { orderId } = useParams();
|
||||||
|
|
||||||
|
const { isLoading, data, error } = useFetchOrderDetails({ orderId });
|
||||||
|
|
||||||
|
const toast = useToast();
|
||||||
|
useEffect(() => {
|
||||||
|
if (error) {
|
||||||
|
toast({
|
||||||
|
title: t('error.title'),
|
||||||
|
description: t('fetch.error'),
|
||||||
|
status: 'error',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'bottom-right',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [error]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<LandingThemeProvider>
|
||||||
|
<Container
|
||||||
|
w='full'
|
||||||
|
maxWidth='container.xl'
|
||||||
|
minH='100vh'
|
||||||
|
padding={0}
|
||||||
|
bg='white'
|
||||||
|
centerContent
|
||||||
|
>
|
||||||
|
<VStack w='full' h='full' alignItems='stretch' flexGrow={1}>
|
||||||
|
<Heading textAlign='center' mt={4}>
|
||||||
|
{t('title')}
|
||||||
|
</Heading>
|
||||||
|
{isLoading ? (
|
||||||
|
<HStack width='full' justifyContent='center'>
|
||||||
|
<Spinner size='lg' />
|
||||||
|
</HStack>
|
||||||
|
) : (
|
||||||
|
data && (
|
||||||
|
<OrderDetails
|
||||||
|
id={data.id}
|
||||||
|
orderDate={data.orderDate}
|
||||||
|
status={data.status}
|
||||||
|
phone={data.phone}
|
||||||
|
carNumber={data.carNumber}
|
||||||
|
carBody={data.carBody}
|
||||||
|
carColor={data.carColor}
|
||||||
|
location={data.location}
|
||||||
|
datetimeBegin={data.startWashTime}
|
||||||
|
datetimeEnd={data.endWashTime}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</VStack>
|
||||||
|
</Container>
|
||||||
|
</LandingThemeProvider>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
|
|
||||||
const STUBS = { masters: 'success', orders: 'success' };
|
const STUBS = { masters: 'success', orders: 'success', orderView: 'success' };
|
||||||
|
|
||||||
router.get('/set/:name/:value', (req, res) => {
|
router.get('/set/:name/:value', (req, res) => {
|
||||||
const { name, value } = req.params;
|
const { name, value } = req.params;
|
||||||
@@ -24,6 +24,11 @@ router.get('/', (req, res) => {
|
|||||||
${generateRadioInput('orders', 'success')}
|
${generateRadioInput('orders', 'success')}
|
||||||
${generateRadioInput('orders', 'error')}
|
${generateRadioInput('orders', 'error')}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Лендинг - Детали заказа</legend>
|
||||||
|
${generateRadioInput('orderView', 'success')}
|
||||||
|
${generateRadioInput('orderView', 'error')}
|
||||||
|
</fieldset>
|
||||||
</div>`);
|
</div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,37 @@ router.get('/arm/masters', (req, res) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/arm/orders', (req, res) => {
|
router.post('/arm/masters', (req, res) => {
|
||||||
|
res
|
||||||
|
.status(/error/.test(STUBS.masters) ? 500 : 200)
|
||||||
|
.send(
|
||||||
|
/^error$/.test(STUBS.masters)
|
||||||
|
? commonError
|
||||||
|
: require(`../json/arm-masters/${STUBS.masters}.json`),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
router.patch('/arm/masters/:id', (req, res) => {
|
||||||
|
res
|
||||||
|
.status(/error/.test(STUBS.masters) ? 500 : 200)
|
||||||
|
.send(
|
||||||
|
/^error$/.test(STUBS.masters)
|
||||||
|
? commonError
|
||||||
|
: require(`../json/arm-masters/${STUBS.masters}.json`),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
router.delete('/arm/masters/:id', (req, res) => {
|
||||||
|
res
|
||||||
|
.status(/error/.test(STUBS.masters) ? 500 : 200)
|
||||||
|
.send(
|
||||||
|
/^error$/.test(STUBS.masters)
|
||||||
|
? commonError
|
||||||
|
: require(`../json/arm-masters/${STUBS.masters}.json`),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post('/arm/orders', (req, res) => {
|
||||||
res
|
res
|
||||||
.status(/error/.test(STUBS.orders) ? 500 : 200)
|
.status(/error/.test(STUBS.orders) ? 500 : 200)
|
||||||
.send(
|
.send(
|
||||||
@@ -33,6 +63,19 @@ router.get('/arm/orders', (req, res) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get('/order/:orderId', ({ params }, res) => {
|
||||||
|
const { orderId } = params;
|
||||||
|
const stubName = `${orderId}-${STUBS.orderView}`;
|
||||||
|
|
||||||
|
res
|
||||||
|
.status(/error/.test(stubName) ? 500 : 200)
|
||||||
|
.send(
|
||||||
|
/^error$/.test(stubName)
|
||||||
|
? commonError
|
||||||
|
: require(`../json/landing-order-view/${stubName}.json`),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
router.use('/admin', require('./admin'));
|
router.use('/admin', require('./admin'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -2,22 +2,12 @@
|
|||||||
"success": true,
|
"success": true,
|
||||||
"body": [
|
"body": [
|
||||||
{
|
{
|
||||||
"id": "masters1",
|
"id": "4545423234",
|
||||||
"name": "Иван Иванов",
|
"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"
|
"phone": "+7 900 123 45 67"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "masters12",
|
"id": "345354234",
|
||||||
"name": "Иван Иванов",
|
"name": "Иван Иванов",
|
||||||
"schedule": [ {
|
"schedule": [ {
|
||||||
"id": "order1",
|
"id": "order1",
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
"orderDate": "2024-11-24T08:41:46.366Z",
|
"orderDate": "2024-11-24T08:41:46.366Z",
|
||||||
"status": "progress",
|
"status": "progress",
|
||||||
"phone": "79001234563",
|
"phone": "79001234563",
|
||||||
"location": "Казань, ул. Баумана, 1"
|
"location": "Казань, ул. Баумана, 1",
|
||||||
|
"master": [],
|
||||||
|
"notes": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "order2",
|
"id": "order2",
|
||||||
@@ -19,7 +21,9 @@
|
|||||||
"orderDate": "2024-11-24T07:40:46.366Z",
|
"orderDate": "2024-11-24T07:40:46.366Z",
|
||||||
"status": "progress",
|
"status": "progress",
|
||||||
"phone": "79001234567",
|
"phone": "79001234567",
|
||||||
"location": "Казань, ул. Баумана, 43"
|
"location": "Казань, ул. Баумана, 43",
|
||||||
|
"master": [],
|
||||||
|
"notes": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
14
stubs/json/landing-order-view/1-success.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"body": {
|
||||||
|
"id": "order1",
|
||||||
|
"orderDate": "2024-11-24T08:41:46.366Z",
|
||||||
|
"status": "progress",
|
||||||
|
"carNumber": "A123BC",
|
||||||
|
"carBody": 1,
|
||||||
|
"startWashTime": "2024-11-24T10:30:00.000Z",
|
||||||
|
"endWashTime": "2024-11-24T16:30:00.000Z",
|
||||||
|
"phone": "79001234563",
|
||||||
|
"location": "55.754364, 48.743295 Университетская улица, 1, Иннополис, Верхнеуслонский район, Республика Татарстан (Татарстан), 420500"
|
||||||
|
}
|
||||||
|
}
|
||||||