flyer upload (anon) issues
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 11m52s

This commit is contained in:
2025-12-30 22:11:21 -08:00
parent 92ad82a012
commit 6740b35f8a

View File

@@ -106,7 +106,10 @@ export const useFlyerUploader = () => {
// Consolidate state derivation for the UI from the react-query hooks using useMemo.
// This improves performance by memoizing the derived state and makes the logic easier to follow.
const { processingState, errorMessage, duplicateFlyerId, flyerId, statusMessage } = useMemo(() => {
// The order of these checks is critical. Errors must be checked first to override
// any stale `jobStatus` from a previous successful poll.
const state: ProcessingState = (() => {
if (uploadMutation.isError || pollError) return 'error';
if (uploadMutation.isPending) return 'uploading';
if (jobStatus && (jobStatus.state === 'active' || jobStatus.state === 'waiting'))
return 'polling';
@@ -114,7 +117,6 @@ export const useFlyerUploader = () => {
if (!jobStatus.returnValue?.flyerId) return 'error';
return 'completed';
}
if (uploadMutation.isError || jobStatus?.state === 'failed' || pollError) return 'error';
return 'idle';
})();