Skip to content

Commit 9431069

Browse files
committed
fix excel sheet issue
1 parent b19dd05 commit 9431069

9 files changed

Lines changed: 35 additions & 23 deletions

File tree

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"next": "15.3.0",
1313
"react": "^19.0.0",
1414
"react-dom": "^19.0.0",
15+
"react-icons": "^5.5.0",
1516
"xlsx": "^0.18.5"
1617
},
1718
"devDependencies": {

public/.~lock.tools.xlsx#

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/file.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/globe.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/next.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/tools.xlsx

2.96 KB
Binary file not shown.

public/window.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/app/page.tsx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { useEffect, useState } from "react";
44
import * as XLSX from "xlsx";
5-
import Image from "next/image";
65

76
type OS = "windows" | "macos" | "linux";
87
type WindowsPkg = "choco" | "winget" | "scoop";
@@ -46,12 +45,21 @@ export default function ScriptGenerator() {
4645
// Assuming sheet 1 contains your data in a suitable format.
4746
const sheetName = workbook.SheetNames[0];
4847
const worksheet = workbook.Sheets[sheetName];
48+
// Define the expected row structure from the Excel sheet
49+
interface ExcelRow {
50+
category?: string;
51+
name: string;
52+
iconsrc: string;z
53+
choco?: string;
54+
winget?: string;
55+
scoop?: string;
56+
apt?: string;
57+
dnf?: string;
58+
pacman?: string;
59+
homebrew?: string;
60+
}
4961
// Parse sheet to JSON
50-
const jsonData: any[] = XLSX.utils.sheet_to_json(worksheet, { defval: "" });
51-
52-
// Transform flat rows into structured ToolCategory[]
53-
// Adjust this logic according to your Excel structure.
54-
// Here is an example assuming columns: category, name, iconsrc, install_choco, install_apt, etc.
62+
const jsonData: ExcelRow[] = XLSX.utils.sheet_to_json<ExcelRow>(worksheet, { defval: "" });
5563

5664
const categoriesMap: Record<string, ToolCategory> = {};
5765

@@ -64,14 +72,14 @@ export default function ScriptGenerator() {
6472

6573
const install: Partial<Record<PkgManager, string>> = {};
6674

67-
// Check all known package manager columns, adjust to your Excel headers
68-
const pkgCols = ["choco", "winget", "scoop", "homebrew", "apt", "dnf", "pacman"];
69-
pkgCols.forEach((pkg) => {
70-
const colName = `install_${pkg}`;
71-
if (row[colName]) {
72-
install[pkg as PkgManager] = row[colName];
73-
}
74-
});
75+
// Explicitly check each package manager column
76+
if (row.choco) install["choco"] = row.choco;
77+
if (row.winget) install["winget"] = row.winget;
78+
if (row.scoop) install["scoop"] = row.scoop;
79+
if (row.apt) install["apt"] = row.apt;
80+
if (row.dnf) install["dnf"] = row.dnf;
81+
if (row.pacman) install["pacman"] = row.pacman;
82+
if (row.homebrew) install["homebrew"] = row.homebrew;
7583

7684
categoriesMap[category].tools.push({
7785
name: row.name,
@@ -196,7 +204,7 @@ export default function ScriptGenerator() {
196204
return (
197205
<label
198206
key={index}
199-
className={`flex flex-col items-center bg-[#161b22] rounded-2xl p-4 transition cursor-pointer border border-transparent ${
207+
className={`relative flex flex-col items-center justify-center bg-[#161b22] rounded-2xl p-4 transition cursor-pointer border border-transparent ${
200208
isAvailable
201209
? "hover:shadow-xl hover:border-indigo-500"
202210
: "opacity-40 cursor-not-allowed"
@@ -207,10 +215,8 @@ export default function ScriptGenerator() {
207215
disabled={!isAvailable}
208216
checked={selectedTools.includes(tool.name)}
209217
onChange={() => handleToolSelect(tool.name)}
210-
className="mb-3 w-5 h-5 accent-indigo-500"
218+
className="absolute top-2 right-2 w-5 h-5 accent-indigo-500"
211219
/>
212-
<img src={tool.iconsrc} alt={tool.name} width={40} height={40} />
213-
214220
<span className="text-sm text-center">{tool.name}</span>
215221
</label>
216222
);

0 commit comments

Comments
 (0)