feat(frontend): add remove button to pending and submitted file cards
Lets users drop an uploaded file from the UI list before or after conversion, without cancelling anything server-side. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,7 +52,7 @@ export function HomePage() {
|
||||
};
|
||||
})
|
||||
);
|
||||
setPendingFiles(withTargets);
|
||||
setPendingFiles((current) => [...current, ...withTargets]);
|
||||
}
|
||||
|
||||
function updateTargetFormat(index, targetFormat) {
|
||||
@@ -78,6 +78,14 @@ export function HomePage() {
|
||||
setPendingFiles((current) => current.map((item, i) => (i === index ? { ...item, iconSize } : item)));
|
||||
}
|
||||
|
||||
function removePendingFile(index) {
|
||||
setPendingFiles((current) => current.filter((_, i) => i !== index));
|
||||
}
|
||||
|
||||
function removeSubmittedJob(index) {
|
||||
setSubmittedJobs((current) => current.filter((_, i) => i !== index));
|
||||
}
|
||||
|
||||
async function handleConvert() {
|
||||
const validItems = pendingFiles.filter((item) => item.targetFormat);
|
||||
const jobs = await uploadFiles(validItems);
|
||||
@@ -114,6 +122,7 @@ export function HomePage() {
|
||||
onTargetFormatChange={updateTargetFormat}
|
||||
onQualityChange={updateQuality}
|
||||
onIconSizeChange={updateIconSize}
|
||||
onRemove={removePendingFile}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
@@ -132,6 +141,7 @@ export function HomePage() {
|
||||
fileSize={job.size}
|
||||
targetFormat={job.targetFormat}
|
||||
jobId={job.id}
|
||||
onRemove={() => removeSubmittedJob(index)}
|
||||
/>
|
||||
) : (
|
||||
<FileCard
|
||||
@@ -140,6 +150,7 @@ export function HomePage() {
|
||||
fileSize={job.size}
|
||||
targetFormat={job.targetFormat}
|
||||
initialError={job.error}
|
||||
onRemove={() => removeSubmittedJob(index)}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user