cleanup: remove dead code, drop unused deps, refactor derived-state effects
Lint went from 84 problems to 0. Build passes. Dead code: - TeamInvoices: drop the orphaned Subcontractor PO block (updateSubcontractorPO plus send/ready-to-pay/paid/reopen/cancel/delete/download/CPA-export handlers and ~25 derived vars). That feature moved to the routed TeamCreateSubcontractorPO / TeamSubcontractorPODetail pages in the Layout2 redesign; these were leftovers. 2100 -> 1880 lines. - Tasks: drop unrendered project sort/tab/completion logic in TasksPageShell. - Remove 59 unused vars, imports, and handlers across 12 other files. Removed wasted queries: - TeamInvoices ran a nested subcontractor_payments join (profiles, projects, companies, PO items, tasks) on every page load into state nothing read. - TeamInvoices and ExternalMyInvoices each fetched a task-type map on invoice open and discarded it; the ExternalMyInvoices one blocked the detail popup. - RequestForm queried sign_families on mount into unread state. Dependencies: - Drop heic2any (zero imports). heic-to is the one in use and already lazy-loads. Effects and exports: - RequestForm: remove 4 effects. Sign-row sizing and company-change resets move into their change handlers; single-company selection is derived during render rather than written back into form state. - FilterDropdown: measure position on click instead of in an effect, which also removes a one-frame stale-position flicker. - BrandBook: latest-ref pattern so the 900ms address debounce is not reset by handler identity. - ClientMyInvoices: hoist MONTHS to module scope. - Split non-component exports: POPUP_FIELD_LABEL moves to lib/popupStyles.js; resolveProfileAvatar and useLiveClock are internal-only; getGreeting deleted as nothing referenced it. Companies.jsx keeps one scoped eslint-disable with a reason: load() only setStates after awaiting its queries, so set-state-in-effect is a false positive there, and load() is shared with the create/delete handlers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -159,7 +159,6 @@ export default function BrandBook() {
|
||||
const projectLogoRef = useRef();
|
||||
const clientLogoRef = useRef();
|
||||
const [filterCompany, setFilterCompany] = useState('');
|
||||
const [selectedBookIds, setSelectedBookIds] = useState([]);
|
||||
const { sortKey: bbSortKey, sortDir: bbSortDir, toggle: bbToggle, sort: bbSort } = useSortable('updated_at');
|
||||
|
||||
useEffect(() => {
|
||||
@@ -175,7 +174,8 @@ export default function BrandBook() {
|
||||
|
||||
const timeoutId = setTimeout(() => {
|
||||
if (address.includes(',') && address.length >= 12) {
|
||||
loadMapsFromAddress(address, { silent: true });
|
||||
// Called through a ref so the debounce isn't reset by the handler's identity.
|
||||
loadMapsFromAddressRef.current(address, { silent: true });
|
||||
}
|
||||
}, 900);
|
||||
|
||||
@@ -222,7 +222,6 @@ export default function BrandBook() {
|
||||
setLoadingBooks(true);
|
||||
const { data } = await supabase.from('brand_books').select('*').order('updated_at', { ascending: false });
|
||||
setSavedBooks(data || []);
|
||||
setSelectedBookIds(prev => prev.filter(id => (data || []).some(book => book.id === id)));
|
||||
setLoadingBooks(false);
|
||||
};
|
||||
|
||||
@@ -235,6 +234,8 @@ export default function BrandBook() {
|
||||
setBookInfo(b => ({ ...b, revision: normalizeRevision(b.revision) }));
|
||||
};
|
||||
|
||||
const loadMapsFromAddressRef = useRef(null);
|
||||
|
||||
const loadMapsFromAddress = async (address = bookInfo.customerAddress, { silent = false, feature = null } = {}) => {
|
||||
const trimmed = String(address || '').trim();
|
||||
if (!trimmed) {
|
||||
@@ -290,6 +291,10 @@ export default function BrandBook() {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadMapsFromAddressRef.current = loadMapsFromAddress;
|
||||
});
|
||||
|
||||
const handleCustomerAddressChange = (e) => {
|
||||
const value = e.target.value;
|
||||
setBookInfo(b => ({ ...b, customerAddress: value, siteAddress: value }));
|
||||
|
||||
Reference in New Issue
Block a user