-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding ability to generate ai comments from admin view
- Loading branch information
1 parent
f34bdc2
commit c07b461
Showing
4 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useToast } from "@/components/ui/use-toast"; | ||
|
||
export function wrapWithToast({ | ||
toast, | ||
callback, | ||
resourceText, | ||
}: { | ||
toast: ReturnType<typeof useToast>["toast"]; | ||
callback: () => Promise<void | null>; | ||
resourceText: string; | ||
}) { | ||
toast({ | ||
title: `Generating ${resourceText}`, | ||
description: `Please wait while your ${resourceText} is being created`, | ||
variant: "default", | ||
}); | ||
callback() | ||
.then(() => { | ||
toast({ | ||
title: `${resourceText} Created`, | ||
description: `The ${resourceText} has been generated`, | ||
variant: "default", | ||
}); | ||
}) | ||
.catch(() => { | ||
toast({ | ||
title: "Something happened", | ||
description: `We could not generate the ${resourceText}`, | ||
variant: "destructive", | ||
}); | ||
}); | ||
} |