Skip to content

Commit

Permalink
Merge pull request #99 from fac30/style/loading
Browse files Browse the repository at this point in the history
Style/loading
  • Loading branch information
jackcasstlesjones authored Dec 17, 2024
2 parents cba4018 + a7b800e commit 894d7f9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
16 changes: 12 additions & 4 deletions src/app/insights/components/InsightsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ export default function InsightsDisplay() {
selectedButton={selectedButton}
/>
) : (
<div>Loading Line Graph...</div>
<div className="flex h-40 w-full justify-center items-center">
<p className="text-xl">Loading Line Graph...</p>
</div>
)}

{insights ? ( // Area Chart
Expand All @@ -214,7 +216,9 @@ export default function InsightsDisplay() {
/>
</>
) : (
<div>Loading Area Chart...</div>
<div className="flex h-40 w-full justify-center items-center">
<p className="text-xl">Loading Area Chart...</p>
</div>
)}

{insights ? ( // Stream Graph
Expand All @@ -227,12 +231,16 @@ export default function InsightsDisplay() {
/>
</>
) : (
<div>Loading Stream Graph...</div>
<div className="flex h-40 w-full justify-center items-center">
<p className="text-xl">Loading Stream Graph...</p>
</div>
)}

{/* unmet needs graph */}
{needsData === null ? (
<div>Loading Needs Data...</div>
<div className="flex h-40 w-full justify-center items-center">
<p className="text-xl">Loading Bar Chart...</p>
</div>
) : needsData.some((item) => item.value > 0) ? (
<BarGraph data={needsData} />
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/app/moods/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function Loading() {
return (
<div className="h-screen w-screen flex justify-center items-center">
<div className="text-3xl">Loading...</div>
<p className="text-3xl">Loading...</p>
</div>
);
}
25 changes: 15 additions & 10 deletions src/lib/db/DatabaseManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DatabaseManager {
"needs",
"next_actions",
];

const existingCollections = Object.keys(dbInstance.collections);

for (const collection of requiredCollections) {
Expand Down Expand Up @@ -76,15 +76,20 @@ class DatabaseManager {
}

private async seedDatabase() {
try {
await this.seed("mood_records", generateMoodRecords("dev"));
await this.seed("categories", categories);
await this.seed("toolkit_items", toolkit);
await this.seed("needs_categories", needsCategories);
await this.seed("needs", needs);
await this.seed("next_actions", nextActions);
} catch (error) {
console.error("Error during database seeding:", error);
if (
dbInstance &&
(await dbInstance.collections["needs"].find().exec()).length === 0
) {
try {
await this.seed("mood_records", generateMoodRecords("dev"));
await this.seed("categories", categories);
await this.seed("toolkit_items", toolkit);
await this.seed("needs_categories", needsCategories);
await this.seed("needs", needs);
await this.seed("next_actions", nextActions);
} catch (error) {
console.error("Error during database seeding:", error);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/ui/shared/PlotlyChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { useEffect, useState } from "react";

const Plot = dynamic(() => import("react-plotly.js"), {
ssr: false,
loading: () => <div>Loading...</div>,
loading: () => (
<div className="flex h-full w-full justify-center items-center">
<p className="text-xl">Loading...</p>
</div>
),
});

interface PlotlyChartProps {
Expand Down

0 comments on commit 894d7f9

Please sign in to comment.