Skip to content

Commit 6689705

Browse files
committed
fix(githubpage):it is not laoding excle sheet first time need to refeash to see the excel sheet
1 parent 0aba73a commit 6689705

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/app/page.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,20 @@ export default function ScriptGenerator() {
3939
const fetchAndParse = async () => {
4040
try {
4141
const res = await fetch("./tools.xlsx");
42+
if (!res.ok) {
43+
throw new Error('Failed to fetch Excel file');
44+
}
45+
4246
const arrayBuffer = await res.arrayBuffer();
4347
const workbook = XLSX.read(arrayBuffer, { type: "array" });
4448

45-
// Assuming sheet 1 contains your data in a suitable format.
4649
const sheetName = workbook.SheetNames[0];
4750
const worksheet = workbook.Sheets[sheetName];
48-
// Define the expected row structure from the Excel sheet
51+
4952
interface ExcelRow {
5053
category?: string;
5154
name: string;
52-
iconsrc: string;z
55+
iconsrc: string;
5356
choco?: string;
5457
winget?: string;
5558
scoop?: string;
@@ -58,7 +61,7 @@ export default function ScriptGenerator() {
5861
pacman?: string;
5962
homebrew?: string;
6063
}
61-
// Parse sheet to JSON
64+
6265
const jsonData: ExcelRow[] = XLSX.utils.sheet_to_json<ExcelRow>(worksheet, { defval: "" });
6366

6467
const categoriesMap: Record<string, ToolCategory> = {};
@@ -72,7 +75,6 @@ export default function ScriptGenerator() {
7275

7376
const install: Partial<Record<PkgManager, string>> = {};
7477

75-
// Explicitly check each package manager column
7678
if (row.choco) install["choco"] = row.choco;
7779
if (row.winget) install["winget"] = row.winget;
7880
if (row.scoop) install["scoop"] = row.scoop;
@@ -89,9 +91,10 @@ export default function ScriptGenerator() {
8991
});
9092

9193
setToolsData(Object.values(categoriesMap));
92-
setLoading(false);
9394
} catch (error) {
9495
console.error("Failed to load Excel data", error);
96+
alert('Failed to load tool data. Please try again later.');
97+
} finally {
9598
setLoading(false);
9699
}
97100
};
@@ -136,10 +139,12 @@ export default function ScriptGenerator() {
136139
document.body.removeChild(link);
137140
};
138141

142+
// Loading UI
139143
if (loading) {
140144
return (
141145
<div className="text-white font-sans text-center mt-20">
142-
Loading tools data...
146+
<div>Loading tools data...</div>
147+
<div className="spinner"></div> {/* Optionally add a spinner here */}
143148
</div>
144149
);
145150
}

0 commit comments

Comments
 (0)