Skip to content

Commit a14b5af

Browse files
committed
add checks to enable Publish button
1 parent a7cbc73 commit a14b5af

File tree

1 file changed

+18
-2
lines changed
  • app/[locale]/dashboard/[entityType]/[entitySlug]/usecases/edit/[id]/publish

1 file changed

+18
-2
lines changed

app/[locale]/dashboard/[entityType]/[entitySlug]/usecases/edit/[id]/publish/page.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ const Publish = () => {
140140
}
141141
);
142142

143-
144143
const Summary = [
145144
{
146145
name: 'Details',
@@ -242,6 +241,23 @@ const Publish = () => {
242241
});
243242
};
244243

244+
const isPublishDisabled = (useCase: any) => {
245+
if (!useCase) return true;
246+
247+
const hasDatasets = useCase?.datasets.length > 0;
248+
const hasRequiredMetadata =
249+
useCase.sectors.length > 0 &&
250+
useCase?.summary.length > 0 &&
251+
useCase?.metadata.length > 0 &&
252+
useCase?.logo !== null;
253+
254+
// No datasets assigned
255+
if (!hasDatasets) return true;
256+
257+
// Required metadata check
258+
if (!hasRequiredMetadata) return true;
259+
};
260+
245261
return (
246262
<>
247263
<div className=" w-full py-6">
@@ -428,7 +444,7 @@ const Publish = () => {
428444
<Button
429445
className="m-auto w-fit"
430446
onClick={() => mutate()}
431-
disabled={UseCaseData?.data?.useCases[0]?.datasets.length <= 0}
447+
disabled={isPublishDisabled(UseCaseData?.data?.useCases[0])}
432448
>
433449
Publish
434450
</Button>

0 commit comments

Comments
 (0)