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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,6 @@ export default function Room() {
setIsLoading(true);
getRoom(id).then((res) => {
console.log(res);
document.title = `Piece - ${res.name}`;
setData(res);
setIsLoading(false);
@ -81,12 +80,11 @@ export default function Room() {
// TODO: Je ferai une modification unitaire plus tard
getRoom(id).then((res) => {
handleFormUpdate();
console.log(res);
setData(res);
});
});
} catch (err) {
console.log(err);
console.error(err);
handleFormUpdate();
}
};
@ -113,7 +111,7 @@ export default function Room() {
handleForm();
} catch (err) {
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 { getRoomsLength } from "../../api";
import StylizedBtn from "../../components/StylizedBtn/StylizedBtn";
import refresh from "../../services/pageManagement";
export default function Rooms() {
const { _user } = useAuth();
@ -18,6 +19,7 @@ export default function Rooms() {
const { pageIndex } = useParams();
const [virtualIndex, setVirtualIndex] = useState(0);
const [roomsLen, setRoomLen] = useState(null);
const [specialSearch, setSpecialSearch] = useState(false);
const onClickCreate = () => {
const name = prompt("Nom de la piece ?");
@ -33,22 +35,23 @@ export default function Rooms() {
values.push(res);
setRooms(values);
alert(`Creation de la piece ${name} reussite !`);
refresh();
});
};
const splicer = (rms, datasPerPage) => {
const partitions = [];
let index = 0;
while (index < rms.length) {
partitions.push(rms.slice(index, index + datasPerPage));
index += datasPerPage;
}
return partitions;
};
const configureRooms = (data) => {
const splicer = (rms, datasPerPage) => {
const partitions = [];
let index = 0;
while (index < rms.length) {
partitions.push(rms.slice(index, index + datasPerPage));
index += datasPerPage;
}
return partitions;
};
const newData = splicer(data, 8);
const blabla = newData[pageIndex ? pageIndex : 0];
@ -58,7 +61,6 @@ export default function Rooms() {
setRooms(newData);
console.log(newData[pageIndex ? pageIndex : 0]);
setDisplayRooms(newData[pageIndex ? pageIndex : 0]);
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 = () => {
if (virtualIndex === 0) {
return;
}
const index = virtualIndex - 1;
console.log(rooms[index]);
setDisplayRooms(rooms[index]);
setVirtualIndex(index);
};
@ -84,7 +109,6 @@ export default function Rooms() {
}
const index = virtualIndex + 1;
console.log(rooms[index]);
setDisplayRooms(rooms[index]);
setVirtualIndex(index);
};
@ -106,7 +130,6 @@ export default function Rooms() {
setRooms(values);
setDisplayRooms(values[virtualIndex]);
console.log(res);
setRoomLen(roomsLen - 1);
@ -143,6 +166,15 @@ export default function Rooms() {
</h3>
</div>
<div id="rooms-searcher-container">
<input
id="rooms-searcher"
type="search"
onChange={handleSearch}
placeholder="Rechercher une piece"
/>
</div>
{displayRooms ? (
<div id="rooms-list-container">
{displayRooms.map((i, j) => (
@ -174,7 +206,7 @@ export default function Rooms() {
<LoaderSpace isVisible={isLoad} isCenterLoader={true} />
)}
{rooms ? (
{rooms && !specialSearch ? (
<div id="pagination-container">
{virtualIndex > 0 ? (
<StylizedBtn

View File

@ -9,6 +9,15 @@
align-items: center;
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 {
margin-top: 30px;
#rooms-title {