register + deletions + image request changes
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Form, Input, InputNumber, Button, Select, DatePicker } from "antd";
|
||||
import axios from "axios";
|
||||
import { createItem } from '../../api/item'
|
||||
|
||||
|
||||
|
||||
const { TextArea } = Input;
|
||||
const { Option } = Select;
|
||||
@@ -26,16 +29,10 @@ export const FormCreateItem = ({ onClose }) => {
|
||||
}, []);
|
||||
|
||||
const onFinish = async (values) => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`${import.meta.env.VITE_API_URL}/item`,
|
||||
values,
|
||||
);
|
||||
console.log(response.data);
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
let response = await createItem(values);
|
||||
if (response?.status >= 200 && response?.status < 300) {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
@@ -1,20 +1,16 @@
|
||||
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);
|
||||
}
|
||||
let response = await createRoom(values);
|
||||
if (response?.status >= 200 && response?.status < 300) {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
|
||||
import { Form, Input, InputNumber, Button, Select, DatePicker } from "antd";
|
||||
import axios from "axios";
|
||||
import { getRooms } from "../../api/room";
|
||||
import { getItem } from "../../api/item";
|
||||
import { getItem, updateItem } from "../../api/item";
|
||||
import moment from "moment";
|
||||
|
||||
const { Option } = Select;
|
||||
@@ -69,16 +69,10 @@ export const FormUpdateItem = ({ itemId, onClose }) => {
|
||||
}, [item, form]);
|
||||
|
||||
const onFinish = async (values) => {
|
||||
try {
|
||||
const response = await axios.put(
|
||||
`${import.meta.env.VITE_API_URL}/item/${item._id}`,
|
||||
values,
|
||||
);
|
||||
console.log(response.data);
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
let response = await updateItem(item._id, values);
|
||||
if (response?.status >= 200 && response?.status < 300) {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
const dateFormat = "YYYY-MM-DD";
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {getRoom } from '../../api/room'
|
||||
import {getRoom, updateRoom, deleteRoom } from '../../api/room'
|
||||
import { Form, Input, Button } from "antd";
|
||||
import axios from "axios";
|
||||
|
||||
@@ -26,20 +26,23 @@ export const FormUpdateRoom = ({_id}) => {
|
||||
}
|
||||
}, [room, form]);
|
||||
|
||||
const onFinish = async (values) => {
|
||||
try {
|
||||
const response = await axios.put(
|
||||
`${import.meta.env.VITE_API_URL}/room/${_id}`,
|
||||
values,
|
||||
);
|
||||
console.log(response.data);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const onFinish = async (values) => {
|
||||
let response = await updateRoom(_id, values);
|
||||
if (response?.status >= 200 && response?.status < 300) {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
const onDelete = async () => {
|
||||
let response = await deleteRoom(_id);
|
||||
if (response?.status >= 200 && response?.status < 300) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Form form={form} onFinish={onFinish}>
|
||||
<button onClick={onDelete}> Supprimer </button>
|
||||
<Form.Item
|
||||
label="Room Name"
|
||||
name="name"
|
||||
|
Reference in New Issue
Block a user