fix: useEffect anti-patterns, attendance permissions, and received-invoices schema mismatch
- Remove ref-mirror useEffect in AuthContext (cachedUserRef already written at mutation sites) - Replace useEffect slide direction in ReceivedInvoices with render-time computation - Fix Login.tsx useEffect dependency array (mount-only alert should have [] deps) - Move "project created" alert to navigation source in ProjectCreate, remove useEffect in ProjectDetail - Move companySettings defaults into fetch callbacks in InvoiceDetail and OfferDetail - Replace due_date useEffect with useMemo in InvoiceDetail - Capture initial snapshots from API data instead of useEffect in InvoiceDetail, OfferDetail, OrderDetail - Replace localStorage draft useEffect with lazy useState initializer in OfferDetail - Fix attendance dropdown to filter by attendance.record permission only - Fix clock-out 404 on update-address (remove departure_time filter for departure action) - Fix received-invoices stats endpoint referencing non-existent is_deleted and amount_czk columns Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -121,7 +121,6 @@ export default function OrderDetail() {
|
||||
const [showConfirmationModal, setShowConfirmationModal] = useState(false);
|
||||
const [confirmationLoading, setConfirmationLoading] = useState(false);
|
||||
const initialNotesRef = useRef<string | null>(null);
|
||||
const hasSetInitialSnapshot = useRef(false);
|
||||
const blobTimeoutsRef = useRef<ReturnType<typeof setTimeout>[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -138,6 +137,7 @@ export default function OrderDetail() {
|
||||
if (result.success) {
|
||||
setOrder(result.data);
|
||||
setNotes(result.data.notes || "");
|
||||
initialNotesRef.current = result.data.notes || "";
|
||||
} else {
|
||||
alert.error(result.error || "Nepodařilo se načíst objednávku");
|
||||
navigate("/orders");
|
||||
@@ -154,17 +154,6 @@ export default function OrderDetail() {
|
||||
fetchDetail();
|
||||
}, [fetchDetail]);
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) {
|
||||
hasSetInitialSnapshot.current = false;
|
||||
return;
|
||||
}
|
||||
if (!hasSetInitialSnapshot.current) {
|
||||
initialNotesRef.current = notes;
|
||||
hasSetInitialSnapshot.current = true;
|
||||
}
|
||||
}, [loading, notes]);
|
||||
|
||||
const isDirty = useMemo(() => {
|
||||
if (!initialNotesRef.current) return false;
|
||||
return notes !== initialNotesRef.current;
|
||||
|
||||
Reference in New Issue
Block a user