39 lines
843 B
React
39 lines
843 B
React
![]() |
import React from "react";
|
||
|
import { Form, Input, Button } from "antd";
|
||
|
import axios from "axios";
|
||
|
|
||
|
export const FormCreateRoom = () => {
|
||
|
const [form] = Form.useForm();
|
||
|
|
||
|
const onFinish = async (values) => {
|
||
|
try {
|
||
|
const response = await axios.post(
|
||
|
`${import.meta.env.VITE_API_URL}/room`,
|
||
|
values,
|
||
|
);
|
||
|
console.log(response.data);
|
||
|
} catch (error) {
|
||
|
console.error(error);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<Form form={form} onFinish={onFinish}>
|
||
|
<Form.Item
|
||
|
label="Room Name"
|
||
|
name="name"
|
||
|
rules={[{ required: true, message: "Please input the room name!" }]}
|
||
|
>
|
||
|
<Input />
|
||
|
</Form.Item>
|
||
|
<Form.Item>
|
||
|
<Button type="primary" htmlType="submit">
|
||
|
Submit
|
||
|
</Button>
|
||
|
</Form.Item>
|
||
|
</Form>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default FormCreateRoom;
|