feat(admin-ui): refresh products when a BatchJob is completed (#4840)

This commit is contained in:
Frane Polić
2023-08-25 09:34:48 +02:00
committed by GitHub
parent f07dc0384f
commit 0c7c2eeeab
12 changed files with 121 additions and 31 deletions
@@ -48,7 +48,13 @@ function useBatchJob(initialData: BatchJob): BatchJob {
setBatchJob(batch_job)
}, [batch_job])
return useMemo(() => batchJob!, [batchJob?.status, batchJob?.result])
return useMemo(
() =>
new Date(initialData.updated_at) > new Date(batch_job.updated_at)
? initialData
: batchJob,
[initialData.updated_at, batchJob?.updated_at]
)
}
const BatchJobActivityList = ({ batchJobs }: { batchJobs?: BatchJob[] }) => {
@@ -171,7 +171,7 @@ type UploadModalProps = {
description1Text: string
description2Title: string
description2Text: string
templateLink: string
onDownloadTemplate: () => any
canImport?: boolean
progress?: number
onClose: () => void
@@ -195,7 +195,7 @@ function UploadModal(props: UploadModalProps) {
onClose,
onSubmit,
onFileRemove,
templateLink,
onDownloadTemplate,
summary,
hasError,
errorMessage,
@@ -216,8 +216,6 @@ function UploadModal(props: UploadModalProps) {
onFileRemove()
}
const download = useHref(templateLink)
return (
<Modal open handleClose={onClose}>
<Modal.Body>
@@ -275,7 +273,10 @@ function UploadModal(props: UploadModalProps) {
name="medusa-template.csv"
size={2967}
action={
<a className="h-6 w-6 cursor-pointer" href={download} download>
<a
className="h-6 w-6 cursor-pointer"
onClick={onDownloadTemplate}
>
<DownloadIcon stroke="#9CA3AF" />
</a>
}