feat: create order api
This commit is contained in:
parent
3ea501161c
commit
a9a9b3cadd
@ -1,4 +1,5 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getConfigValue } from '@brojs/cli';
|
||||
import { InputProps, SelectProps } from "@chakra-ui/react";
|
||||
|
||||
import { Order } from "../../../models/landing";
|
||||
@ -56,11 +57,22 @@ export const formatFormValues = ({ phone, carNumber, carBody, carColor, carLocat
|
||||
};
|
||||
};
|
||||
|
||||
export const onSubmit = (values: OrderFormValues) => {
|
||||
return new Promise((resolve) => {
|
||||
console.log(formatFormValues(values));
|
||||
resolve(formatFormValues(values));
|
||||
const endpoint = getConfigValue('dry-wash.api');
|
||||
|
||||
export const onSubmit = async (values: OrderFormValues) => {
|
||||
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> = {
|
||||
|
@ -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'));
|
||||
|
||||
module.exports = router;
|
||||
|
Loading…
Reference in New Issue
Block a user