Compare commits

...

4 Commits

Author SHA1 Message Date
RustamRu
3382ae3ada 0.5.0
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
2025-01-19 11:06:34 +03:00
RustamRu
5ed023866e fix: washing dates format
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
2025-01-19 11:04:44 +03:00
RustamRu
e73773f359 Merge branch 'main' of ssh://85.143.175.152:222/dry_wash_inc/dry-wash-pl
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
2025-01-19 10:55:56 +03:00
RustamRu
a9a9b3cadd feat: create order api 2025-01-19 10:55:44 +03:00
4 changed files with 28 additions and 9 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "dry-wash", "name": "dry-wash",
"version": "0.4.0", "version": "0.5.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "dry-wash", "name": "dry-wash",
"version": "0.4.0", "version": "0.5.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@brojs/cli": "^1.6.3", "@brojs/cli": "^1.6.3",

View File

@@ -1,6 +1,6 @@
{ {
"name": "dry-wash", "name": "dry-wash",
"version": "0.4.0", "version": "0.5.0",
"description": "<a id=\"readme-top\"></a>", "description": "<a id=\"readme-top\"></a>",
"main": "./src/index.tsx", "main": "./src/index.tsx",
"scripts": { "scripts": {

View File

@@ -1,5 +1,7 @@
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { getConfigValue } from '@brojs/cli';
import { InputProps, SelectProps } from "@chakra-ui/react"; import { InputProps, SelectProps } from "@chakra-ui/react";
import dayjs from "dayjs";
import { Order } from "../../../models/landing"; import { Order } from "../../../models/landing";
@@ -50,17 +52,28 @@ export const formatFormValues = ({ phone, carNumber, carBody, carColor, carLocat
}, },
washing: { washing: {
location: carLocation, location: carLocation,
begin: availableDatetimeBegin, begin: dayjs(availableDatetimeBegin).toISOString(),
end: availableDatetimeEnd, end: dayjs(availableDatetimeEnd).toISOString(),
} }
}; };
}; };
export const onSubmit = (values: OrderFormValues) => { const endpoint = getConfigValue('dry-wash.api');
return new Promise((resolve) => {
console.log(formatFormValues(values)); export const onSubmit = async (values: OrderFormValues) => {
resolve(formatFormValues(values)); const response = await fetch(`${endpoint}/order/create`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formatFormValues(values)),
}); });
if (!response.ok) {
throw new Error(`Failed to create order: ${response.status}`);
}
return await response.json();
}; };
export const inputCommonStyles: Partial<InputProps & SelectProps> = { export const inputCommonStyles: Partial<InputProps & SelectProps> = {

View File

@@ -76,6 +76,12 @@ router.get('/order/:orderId', ({ params }, res) => {
); );
}); });
router.post('/order/create', (req, res) => {
res
.status(200)
.send({ success: true, body: { ok: true } });
});
router.use('/admin', require('./admin')); router.use('/admin', require('./admin'));
module.exports = router; module.exports = router;