Compare commits
7 Commits
feature/up
...
v0.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3382ae3ada | ||
|
|
5ed023866e | ||
|
|
e73773f359 | ||
|
|
a9a9b3cadd | ||
| 06abc15c9a | |||
| 6ca7de9467 | |||
| 939f107d1c |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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",
|
||||||
|
|||||||
@@ -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": {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { getConfigValue } from '@brojs/cli';
|
import { getConfigValue } from '@brojs/cli';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
enum ArmEndpoints {
|
enum ArmEndpoints {
|
||||||
ORDERS = '/arm/orders',
|
ORDERS = '/arm/orders',
|
||||||
@@ -9,12 +10,15 @@ const armService = () => {
|
|||||||
const endpoint = getConfigValue('dry-wash.api');
|
const endpoint = getConfigValue('dry-wash.api');
|
||||||
|
|
||||||
const fetchOrders = async ({ date }: { date: Date }) => {
|
const fetchOrders = async ({ date }: { date: Date }) => {
|
||||||
|
const startDate = dayjs(date).startOf('day').toISOString();
|
||||||
|
const endDate = dayjs(date).endOf('day').toISOString();
|
||||||
|
|
||||||
const response = await fetch(`${endpoint}${ArmEndpoints.ORDERS}`, {
|
const response = await fetch(`${endpoint}${ArmEndpoints.ORDERS}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ date }),
|
body: JSON.stringify({ startDate, endDate }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -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> = {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user