This commit is contained in:
pro.boooooo 2024-04-08 01:38:45 +02:00
parent c2c62fc140
commit b98c7d6d42
8 changed files with 60 additions and 33 deletions

View File

@ -2,8 +2,6 @@ import axios from "axios";
export const createItem = async (settings) => { export const createItem = async (settings) => {
try { try {
console.log(settings);
const formData = new FormData(); const formData = new FormData();
formData.append("room", settings.room); formData.append("room", settings.room);
formData.append("brand", settings.brand); formData.append("brand", settings.brand);
@ -26,8 +24,6 @@ export const createItem = async (settings) => {
export const updateItem = async (settings) => { export const updateItem = async (settings) => {
try { try {
console.log(settings);
const formData = new FormData(); const formData = new FormData();
formData.append("brand", settings.brand); formData.append("brand", settings.brand);
formData.append("model", settings.model); formData.append("model", settings.model);
@ -52,7 +48,6 @@ export const updateItem = async (settings) => {
export const deleteItem = async (id) => { export const deleteItem = async (id) => {
try { try {
console.log(id);
const response = await axios.delete(`/item/${id}`); const response = await axios.delete(`/item/${id}`);
return response.data; return response.data;
} catch (err) { } catch (err) {

View File

@ -26,7 +26,6 @@ export const createUser = async (username, password, confirmation) => {
export const updateUser = async (settings) => { export const updateUser = async (settings) => {
try { try {
console.log("try");
// const formData = new FormData(); // const formData = new FormData();
// formData.append("username", settings.username); // formData.append("username", settings.username);
// formData.append("password", settings.password); // formData.append("password", settings.password);

View File

@ -46,7 +46,6 @@ export const AuthenticationProvider = ({ children }) => {
const register = async (username, password, confirmation) => { const register = async (username, password, confirmation) => {
try { try {
const user = await registerApi(username, password, confirmation); const user = await registerApi(username, password, confirmation);
console.log(user);
setAuthState({ user }); setAuthState({ user });
redirect(); redirect();
} catch (error) { } catch (error) {

View File

@ -21,7 +21,6 @@ export const Home = () => {
getState().then((res) => { getState().then((res) => {
try { try {
setIsLoad(false); setIsLoad(false);
console.log(res);
setDataset(res); setDataset(res);
setupRoomsStats(res.rooms); setupRoomsStats(res.rooms);
setupGlobalStat({ years: res.years, global: res.global }); setupGlobalStat({ years: res.years, global: res.global });

View File

@ -30,7 +30,6 @@ export default function Profile() {
useEffect(() => { useEffect(() => {
document.title = `Profil de ${user.user.username}`; document.title = `Profil de ${user.user.username}`;
console.log(user);
}, [user]); }, [user]);
const handleHelpIE = () => { const handleHelpIE = () => {
@ -71,7 +70,6 @@ export default function Profile() {
setImportMsg("Vos depenses ont ete transfere avec sucess."); setImportMsg("Vos depenses ont ete transfere avec sucess.");
} }
setIsIELoad(false); setIsIELoad(false);
console.log(res);
}); });
}; };
@ -104,8 +102,6 @@ export default function Profile() {
logout().then((_) => { logout().then((_) => {
refresh(); refresh();
}); });
console.log(res);
console.log(oldPPassword, password, confirmPassword);
}); });
}; };

View File

@ -23,7 +23,6 @@ export default function Room() {
setIsLoading(true); setIsLoading(true);
getRoom(id).then((res) => { getRoom(id).then((res) => {
console.log(res);
document.title = `Piece - ${res.name}`; document.title = `Piece - ${res.name}`;
setData(res); setData(res);
setIsLoading(false); setIsLoading(false);
@ -81,12 +80,11 @@ export default function Room() {
// TODO: Je ferai une modification unitaire plus tard // TODO: Je ferai une modification unitaire plus tard
getRoom(id).then((res) => { getRoom(id).then((res) => {
handleFormUpdate(); handleFormUpdate();
console.log(res);
setData(res); setData(res);
}); });
}); });
} catch (err) { } catch (err) {
console.log(err); console.error(err);
handleFormUpdate(); handleFormUpdate();
} }
}; };
@ -113,7 +111,7 @@ export default function Room() {
handleForm(); handleForm();
} catch (err) { } catch (err) {
alert("Quelque chose cloche avec le formulaire ..."); alert("Quelque chose cloche avec le formulaire ...");
console.log(err); console.error(err);
} }
}; };

View File

@ -8,6 +8,7 @@ import { useAuth } from "../../hooks";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { getRoomsLength } from "../../api"; import { getRoomsLength } from "../../api";
import StylizedBtn from "../../components/StylizedBtn/StylizedBtn"; import StylizedBtn from "../../components/StylizedBtn/StylizedBtn";
import refresh from "../../services/pageManagement";
export default function Rooms() { export default function Rooms() {
const { _user } = useAuth(); const { _user } = useAuth();
@ -18,6 +19,7 @@ export default function Rooms() {
const { pageIndex } = useParams(); const { pageIndex } = useParams();
const [virtualIndex, setVirtualIndex] = useState(0); const [virtualIndex, setVirtualIndex] = useState(0);
const [roomsLen, setRoomLen] = useState(null); const [roomsLen, setRoomLen] = useState(null);
const [specialSearch, setSpecialSearch] = useState(false);
const onClickCreate = () => { const onClickCreate = () => {
const name = prompt("Nom de la piece ?"); const name = prompt("Nom de la piece ?");
@ -33,10 +35,10 @@ export default function Rooms() {
values.push(res); values.push(res);
setRooms(values); setRooms(values);
alert(`Creation de la piece ${name} reussite !`); alert(`Creation de la piece ${name} reussite !`);
refresh();
}); });
}; };
const configureRooms = (data) => {
const splicer = (rms, datasPerPage) => { const splicer = (rms, datasPerPage) => {
const partitions = []; const partitions = [];
let index = 0; let index = 0;
@ -49,6 +51,7 @@ export default function Rooms() {
return partitions; return partitions;
}; };
const configureRooms = (data) => {
const newData = splicer(data, 8); const newData = splicer(data, 8);
const blabla = newData[pageIndex ? pageIndex : 0]; const blabla = newData[pageIndex ? pageIndex : 0];
@ -58,7 +61,6 @@ export default function Rooms() {
setRooms(newData); setRooms(newData);
console.log(newData[pageIndex ? pageIndex : 0]);
setDisplayRooms(newData[pageIndex ? pageIndex : 0]); setDisplayRooms(newData[pageIndex ? pageIndex : 0]);
if (!blabla) { if (!blabla) {
@ -67,13 +69,36 @@ export default function Rooms() {
} }
}; };
const handleSearch = (e) => {
const word = e.target.value;
if (word.trim().length === 0) {
setSpecialSearch(false);
setDisplayRooms(rooms[virtualIndex]);
return;
}
setSpecialSearch(true);
const stock = [];
for (let room of rooms) {
for (let item of room) {
if (item.name.toLowerCase().includes(word.toLowerCase())) {
stock.push(item);
}
}
}
setVirtualIndex(0);
setDisplayRooms(stock);
};
const handleBefore = () => { const handleBefore = () => {
if (virtualIndex === 0) { if (virtualIndex === 0) {
return; return;
} }
const index = virtualIndex - 1; const index = virtualIndex - 1;
console.log(rooms[index]);
setDisplayRooms(rooms[index]); setDisplayRooms(rooms[index]);
setVirtualIndex(index); setVirtualIndex(index);
}; };
@ -84,7 +109,6 @@ export default function Rooms() {
} }
const index = virtualIndex + 1; const index = virtualIndex + 1;
console.log(rooms[index]);
setDisplayRooms(rooms[index]); setDisplayRooms(rooms[index]);
setVirtualIndex(index); setVirtualIndex(index);
}; };
@ -106,7 +130,6 @@ export default function Rooms() {
setRooms(values); setRooms(values);
setDisplayRooms(values[virtualIndex]); setDisplayRooms(values[virtualIndex]);
console.log(res);
setRoomLen(roomsLen - 1); setRoomLen(roomsLen - 1);
@ -143,6 +166,15 @@ export default function Rooms() {
</h3> </h3>
</div> </div>
<div id="rooms-searcher-container">
<input
id="rooms-searcher"
type="search"
onChange={handleSearch}
placeholder="Rechercher une piece"
/>
</div>
{displayRooms ? ( {displayRooms ? (
<div id="rooms-list-container"> <div id="rooms-list-container">
{displayRooms.map((i, j) => ( {displayRooms.map((i, j) => (
@ -174,7 +206,7 @@ export default function Rooms() {
<LoaderSpace isVisible={isLoad} isCenterLoader={true} /> <LoaderSpace isVisible={isLoad} isCenterLoader={true} />
)} )}
{rooms ? ( {rooms && !specialSearch ? (
<div id="pagination-container"> <div id="pagination-container">
{virtualIndex > 0 ? ( {virtualIndex > 0 ? (
<StylizedBtn <StylizedBtn

View File

@ -9,6 +9,15 @@
align-items: center; align-items: center;
gap: 30px; gap: 30px;
#rooms-searcher-container {
#rooms-searcher {
padding: 10px;
text-align: center;
border: 1.985px solid $good_black;
border-radius: $my_border_rad;
}
}
#rooms-headers { #rooms-headers {
margin-top: 30px; margin-top: 30px;
#rooms-title { #rooms-title {