Refine upload status behavior

This commit is contained in:
Sam Becker 2025-03-22 17:37:03 -05:00
parent 76c04995e9
commit 1fadbda6d2
2 changed files with 23 additions and 13 deletions

View File

@ -20,13 +20,16 @@ export default function AdminUploadPanel({
uploadState: {
isUploading,
hideUploadPanel,
uploadError,
},
resetUploadState,
} = useAppState();
return (
<AppGrid
className={clsx((!isUploading || hideUploadPanel) && 'hidden')}
className={clsx(
((!isUploading || uploadError) || hideUploadPanel) && 'hidden',
)}
contentMain={
<Container
color="gray"

View File

@ -74,7 +74,9 @@ export default function PhotoUploadWithStatus({
}, [resetUploadState]);
const isFinishing = isPending && shouldResetUploadStateAfterPending.current;
const uploadNumberText = `${fileUploadIndex + 1} of ${filesLength}`;
const uploadStatusText = filesLength > 1
? `${fileUploadIndex + 1} of ${filesLength}`
: undefined;
return (
<div className={clsx(
@ -127,6 +129,7 @@ export default function PhotoUploadWithStatus({
}
})
.catch(error => {
console.error(error);
setUploadState?.({
isUploading: false,
uploadError: `Upload Error: ${error.message}`,
@ -155,17 +158,25 @@ export default function PhotoUploadWithStatus({
Finishing ...
</>
: <>
{!showButton && <>
<ResponsiveText shortText={uploadNumberText}>
Uploading {uploadNumberText}
</ResponsiveText>
{': '}
</>}
{fileUploadName}
{!showButton && uploadStatusText
? <>
<ResponsiveText shortText={uploadStatusText}>
Uploading {uploadStatusText}
</ResponsiveText>
{': '}
{fileUploadName}
</>
: <ResponsiveText shortText={fileUploadName}>
Uploading {fileUploadName}
</ResponsiveText>}
</>
: !showButton && <>Initializing</>}
</span>
</div>}
{uploadError &&
<div className="text-error">
{uploadError}
</div>}
{debug && debugDownload &&
<a
className="block"
@ -174,10 +185,6 @@ export default function PhotoUploadWithStatus({
>
Download
</a>}
{uploadError &&
<div className="text-error">
{uploadError}
</div>}
</div>
);
};