fixed item update

This commit is contained in:
Simon CATANESE 2024-05-12 12:46:12 +02:00
parent 85cba8b1dc
commit 8b01b19365
13 changed files with 212 additions and 654 deletions

Binary file not shown.

View File

@ -2,45 +2,57 @@
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\rooms-stats.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\pages\\rooms-stats.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\image-request.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\api\\image-request.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\home.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\pages\\home.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\inspirobot.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\api\\inspirobot.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\App.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\App.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\main.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\main.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\item.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\api\\item.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\README.md||{EFC0BB08-EA7D-40C6-A696-C870411A895B}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:README.md||{EFC0BB08-EA7D-40C6-A696-C870411A895B}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\app-layout.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\app-layout.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\item\\ItemBox.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\item\\ItemBox.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\form\\formUpdateItem.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\form\\formUpdateItem.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\__tests__\\api\\image-request.test.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:__tests__\\api\\image-request.test.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\router.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\router.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\app-layout.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\app-layout.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\inspirobot.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\api\\inspirobot.js||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\__tests__\\api\\inspirobot.test.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:__tests__\\api\\inspirobot.test.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\item\\ItemBox.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\item\\ItemBox.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\form\\formCreateItem.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\form\\formCreateItem.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\form\\formUpdateItem.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:src\\components\\form\\formUpdateItem.jsx||{14D17961-FE51-464D-9111-C4AF11D7D99A}"
}
],
"DocumentGroupContainers": [
@ -50,32 +62,36 @@
"DocumentGroups": [
{
"DockedWidth": 109,
"SelectedChildIndex": 6,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:1:0:{d212f56b-c48a-434c-a121-1c5d80b59b9f}"
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "item.js",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\item.js",
"RelativeDocumentMoniker": "src\\api\\item.js",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\item.js",
"RelativeToolTip": "src\\api\\item.js",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAgAAAAdAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001646|",
"WhenOpened": "2024-05-09T22:23:19.906Z",
"DocumentIndex": 0,
"Title": "rooms-stats.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\rooms-stats.jsx",
"RelativeDocumentMoniker": "src\\pages\\rooms-stats.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\rooms-stats.jsx",
"RelativeToolTip": "src\\pages\\rooms-stats.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABUAAAAGAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-11T21:19:23.557Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "App.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\App.jsx",
"RelativeDocumentMoniker": "src\\App.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\App.jsx",
"RelativeToolTip": "src\\App.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABoAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-09T22:10:26.286Z",
"DocumentIndex": 1,
"Title": "image-request.js",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\image-request.js",
"RelativeDocumentMoniker": "src\\api\\image-request.js",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\image-request.js",
"RelativeToolTip": "src\\api\\image-request.js",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABUAAAASAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001646|",
"WhenOpened": "2024-05-11T21:09:59.501Z",
"EditorCaption": ""
},
{
@ -86,27 +102,66 @@
"RelativeDocumentMoniker": "src\\main.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\main.jsx",
"RelativeToolTip": "src\\main.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAANAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAIAAAAUAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-09T22:08:08.294Z",
"WhenOpened": "2024-05-11T20:57:39.552Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"DocumentIndex": 4,
"Title": "README.md",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\README.md",
"RelativeDocumentMoniker": "README.md",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\README.md",
"RelativeToolTip": "README.md",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAUAAAAPAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001818|",
"WhenOpened": "2024-05-11T20:44:05.36Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "image-request.test.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\__tests__\\api\\image-request.test.jsx",
"RelativeDocumentMoniker": "__tests__\\api\\image-request.test.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\__tests__\\api\\image-request.test.jsx",
"RelativeToolTip": "__tests__\\api\\image-request.test.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAMAAAB1AAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-11T20:36:31.883Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 9,
"Title": "inspirobot.test.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\__tests__\\api\\inspirobot.test.jsx",
"RelativeDocumentMoniker": "__tests__\\api\\inspirobot.test.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\__tests__\\api\\inspirobot.test.jsx",
"RelativeToolTip": "__tests__\\api\\inspirobot.test.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-11T20:28:50.358Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 8,
"Title": "inspirobot.js",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\inspirobot.js",
"RelativeDocumentMoniker": "src\\api\\inspirobot.js",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\api\\inspirobot.js",
"RelativeToolTip": "src\\api\\inspirobot.js",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAIAAAAAAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAEAAAAcAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001646|",
"WhenOpened": "2024-05-09T21:22:04.631Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 5,
"DocumentIndex": 7,
"Title": "app-layout.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\app-layout.jsx",
"RelativeDocumentMoniker": "src\\components\\app-layout.jsx",
@ -119,7 +174,7 @@
},
{
"$type": "Document",
"DocumentIndex": 8,
"DocumentIndex": 6,
"Title": "router.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\router.jsx",
"RelativeDocumentMoniker": "src\\router.jsx",
@ -132,24 +187,20 @@
},
{
"$type": "Document",
"DocumentIndex": 0,
"DocumentIndex": 2,
"Title": "home.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\home.jsx",
"RelativeDocumentMoniker": "src\\pages\\home.jsx",
"ToolTip": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\pages\\home.jsx",
"RelativeToolTip": "src\\pages\\home.jsx",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAB0AAABSAAAA",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAB0AAACFAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003663|",
"WhenOpened": "2024-05-09T21:06:29.035Z",
"EditorCaption": ""
},
{
"$type": "Bookmark",
"Name": "ST:1:0:{d212f56b-c48a-434c-a121-1c5d80b59b9f}"
},
{
"$type": "Document",
"DocumentIndex": 7,
"DocumentIndex": 12,
"Title": "formUpdateItem.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\form\\formUpdateItem.jsx",
"RelativeDocumentMoniker": "src\\components\\form\\formUpdateItem.jsx",
@ -162,7 +213,7 @@
},
{
"$type": "Document",
"DocumentIndex": 9,
"DocumentIndex": 11,
"Title": "formCreateItem.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\form\\formCreateItem.jsx",
"RelativeDocumentMoniker": "src\\components\\form\\formCreateItem.jsx",
@ -175,7 +226,7 @@
},
{
"$type": "Document",
"DocumentIndex": 6,
"DocumentIndex": 10,
"Title": "ItemBox.jsx",
"DocumentMoniker": "C:\\Users\\Admin\\source\\repos\\2024-DEV-BUT3\\src\\components\\item\\ItemBox.jsx",
"RelativeDocumentMoniker": "src\\components\\item\\ItemBox.jsx",

View File

@ -2,15 +2,15 @@
"ExpandedNodes": [
"",
"\\src",
"\\src\\assets",
"\\src\\assets\\styles",
"\\src\\components",
"\\src\\components\\form",
"\\src\\components\\item",
"\\src\\components\\nav",
"\\src\\api",
"\\src\\hooks",
"\\src\\pages"
"\\src\\pages",
"\\tests-examples",
"\\__tests__",
"\\__tests__\\api",
"\\__tests__\\pages",
"\\__tests__\\pages\\authenticated"
],
"SelectedNode": "\\src\\api\\item.js",
"SelectedNode": "\\src\\pages\\rooms-stats.jsx",
"PreviewInSolutionExplorer": false
}

Binary file not shown.

608
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
"@ant-design/icons": "^5.3.7",
"axios": "^1.6.7",
"bootstrap": "^5.3.3",
"moment": "^2.30.1",
"react": "^18.2.0",
"react-cookie": "^7.0.2",
"react-dom": "^18.2.0",

View File

@ -1,4 +1,5 @@
const API_KEY = 'AIzaSyA_w7wmOAibpiDF5H3mXuL9AhcN-KVkFg4';
//const API_KEY = 'AIzaSyA_w7wmOAibpiDF5H3mXuL9AhcN-KVkFg4';
const API_KEY = 'AIzaSyCWPG-WbraYVEk6wVEZX8dJQAABTibvGNM';
const CSE_ID = '611cd62b5f315445c';
export async function searchAndResizeImage(query) {
@ -11,12 +12,17 @@ export async function searchAndResizeImage(query) {
console.log('Image URL:', imageUrl);
return imageUrl;
}
else {
console.error('No image found.');
return "";
}
} catch (error) {
console.error('Error fetching image:', error);
}
console.error('No image found.');
return "";
}
}

View File

@ -2,10 +2,11 @@ import axios from "axios";
export const getItem = async (_id) => {
export const getItem = async (id) => {
try {
const response = await axios.get("/item", {_id});
console.log(response.data)
console.log("GET ITEM ID : ", id)
const response = await axios.get("/item/"+id);
console.log("GET ITEM : ", response.data)
return response.data;
} catch (error) {
console.log("ERROR", error.response.data)

View File

@ -79,6 +79,7 @@
.item-list {
width: 100%;
max-width:50vw;
}
.pagination {

View File

@ -1,14 +1,26 @@
import React, { useState, useEffect } from "react";
import { Form, Input, InputNumber, Button, Select } from "antd";
import { Form, Input, InputNumber, Button, Select, DatePicker } from "antd";
import axios from "axios";
import { getRooms } from "../../api/room";
import { getItem } from "../../api/item";
import moment from 'moment';
const { TextArea } = Input;
const { Option } = Select;
function formatItem(_id, brand, model, room, price, purchaseDate, description, categories, createdAt, updatedAt, __v) {
function formatItem(itemObj) {//_id, brand, model, room, price, purchaseDate, description, categories, createdAt, updatedAt, __v, link) {
let _id = itemObj._id
let brand = itemObj.brand
let model = itemObj.model
let room = itemObj.room
let price = itemObj.price
let purchaseDate = new Date(itemObj.purchaseDate)
let description = itemObj.description
let categories = itemObj.categories
let createdAt = itemObj.createdAt
let updatedAt = itemObj.updatedAt
let __v = itemObj.__v
let link = itemObj.link
let item = {
_id,
brand,
@ -20,7 +32,8 @@ function formatItem(_id, brand, model, room, price, purchaseDate, description, c
categories,
createdAt,
updatedAt,
__v
__v,
link
}
return item;
}
@ -28,15 +41,29 @@ function formatItem(_id, brand, model, room, price, purchaseDate, description, c
export const FormUpdateItem = ({ itemId }) => {
const [form] = Form.useForm();
const [rooms, setRooms] = useState([]);
const [item, setItem] = useState(formatItem({ _id: itemId }))
const [item, setItem] = useState(null)
useEffect(() => {
const fetchData = async () => {
const roomsResponse = await getRooms();
setRooms(roomsResponse);
setRooms(getRooms())
const itemResponse = await getItem(itemId);
console.log(itemResponse)
setItem(formatItem(itemResponse));
};
setItem(getItem(item._id))
fetchData();
}, [itemId]);
}, []);
useEffect(() => {
if (item) {
form.setFieldsValue({
...item,
purchaseDate: item.purchaseDate ? moment(item.purchaseDate) : null,
});
}
}, [item, form]);
const onFinish = async (values) => {
try {
@ -50,6 +77,7 @@ export const FormUpdateItem = ({ itemId }) => {
}
};
const dateFormat = 'YYYY-MM-DD';
return (
<Form
form={form}
@ -65,7 +93,9 @@ export const FormUpdateItem = ({ itemId }) => {
</Form.Item>
<Form.Item label="Room" name="room">
<Select placeholder="Select a room">
{rooms.map((room) => (
{console.log(rooms)}
{
rooms.map((room) => (
<Option key={room._id} value={room._id}>
{room.name}
</Option>
@ -76,7 +106,9 @@ export const FormUpdateItem = ({ itemId }) => {
<InputNumber />
</Form.Item>
<Form.Item label="Purchase Date" name="purchaseDate">
<Input />
<DatePicker
dateFormat={dateFormat}
/>
</Form.Item>
<Form.Item label="Description" name="description">
<Input.TextArea rows={4} />

View File

@ -98,7 +98,7 @@ export const ItemBox = ({ model, brand, purchaseDate, price, _id }) => {
<div className="modal">
<div className="modal-content">
<span className="close" onClick={closeModal}>&times;</span>
<FormUpdateItem itemId={_id}></FormUpdateItem>
<FormUpdateItem itemId={_id}>{console.log("item ID :" + _id)}</FormUpdateItem>
</div>
</div>
)}

View File

@ -26,8 +26,8 @@ export const Home = () => {
return (
<div style={{ display: 'block', margin: '5%, 50%, 0' }}>
{user && <h2>BONJOUR {user.user.username}</h2>}
<p>C'est un plaisir de te voir aujourd'hui.</p>
<p>Nous allons te générer un message inspirationnel rien que pour toi :)</p>
<p>C'est un plaisir de te voir aujourd'hui. Il n'y a pas grand chose à afficher sur cette page. Voici donc de quoi t'inspirer :</p>
<p style={{ textAlign: 'center' }}> Importation d'une image inspirante de <a href="https://inspirobot.me/">Inspirobot</a> :</p>
{inspirationUrl && <img src={inspirationUrl + '?' + new Date().getTime()} alt="inspirobot" style={{ display: 'block', margin: 'auto' }} width='auto' />}
<p>Credits : https://inspirobot.me/</p>
</div>

View File

@ -18,8 +18,8 @@ export const RoomsStats = () => {
setPageTitle("Toutes les rooms :");
}, [setPageTitle]);
return (
<div>
<div className="gridContainer">
<div className="StatsContainer"></div>
</div>
);
};