chore: improve toast and show once

This commit is contained in:
Rodolfo Ruiz
2025-07-03 21:25:42 -06:00
parent eb49416000
commit 7757334c7b
3 changed files with 12 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
import SectionContainer from '../../components/SectionContainer';
import { useEffect, useState } from 'react';
import { useEffect, useState, useRef } from 'react';
import { DataGrid } from '@mui/x-data-grid';
import { Typography, Button, Dialog, DialogTitle, DialogContent, IconButton, Box } from '@mui/material';
import EditRoundedIcon from '@mui/icons-material/EditRounded';
@@ -42,11 +42,14 @@ export default function Admin() {
const [rowToDelete, setRowToDelete] = useState(null);
const { handleError } = useApiToast();
useEffect(() => {
let isMounted = true;
loadData();
return () => { isMounted = false };
}, []);
const hasLoaded = useRef(false);
useEffect(() => {
if (!hasLoaded.current) {
loadData();
hasLoaded.current = true;
}
}, []);
const handleEditClick = (params) => {
setEditingData(params.row);