feat: create order api
This commit is contained in:
@@ -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> = {
|
||||
|
||||
Reference in New Issue
Block a user