Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix isLoading for generate all, report button positions #23

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 27 additions & 30 deletions app/pages/sustainabilityreports/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ function Page() {
} catch (error) {
console.error('Error regenerating report:', error);
} finally {
setIsLoading(false);
updateStatus(reportId, GenerationStatus.GENERATED);
}
};
Expand All @@ -74,10 +73,6 @@ function Page() {
setIsLoading(false);
};

// const runGenerate = async (reportIndex: number) => {
// console.log('Generating new report:', reportIndex);
// };

const handleGenerateNewAll = async () => {
setIsLoading(true);
try {
Expand Down Expand Up @@ -218,31 +213,33 @@ function Page() {
))}
<td className={'p-4 w-auto sticky right-0 z-10 bg-white'}>
{attributes.length > 0 && reports.length > 0 && (
<div className="h-full flex gap-2">
<Button
className="bg-blue-900"
size="sm"
disabled={
isLoading || attributes.length === Object.keys(reports[index].reportResults).length
}
onClick={() => handleGenerateNew(index)}
loading={status === GenerationStatus.GENERATING}
>
<span className="flex gap-2">
{status !== GenerationStatus.GENERATING && 'New'} <Sparkle size={16} />
</span>
</Button>
<Button
className="bg-blue-900"
size="sm"
disabled={isLoading}
onClick={() => handleRegenerate(index)}
loading={status === GenerationStatus.GENERATING}
>
<span className="flex gap-2">
{status !== GenerationStatus.GENERATING && 'All'} <ArrowsCounterClockwise size={16} />
</span>
</Button>
<div className="h-full flex flex-row items-center justify-end">
<div className="h-full flex gap-2">
<Button
className="bg-blue-900"
size="sm"
disabled={
isLoading || attributes.length === Object.keys(reports[index].reportResults).length
}
onClick={() => handleGenerateNew(index)}
loading={status === GenerationStatus.GENERATING}
>
<span className="flex gap-2">
{status !== GenerationStatus.GENERATING && 'New'} <Sparkle size={16} />
</span>
</Button>
<Button
className="bg-blue-900"
size="sm"
disabled={isLoading}
onClick={() => handleRegenerate(index)}
loading={status === GenerationStatus.GENERATING}
>
<span className="flex gap-2">
{status !== GenerationStatus.GENERATING && 'All'} <ArrowsCounterClockwise size={16} />
</span>
</Button>
</div>
</div>
)}
</td>
Expand Down
Loading