Skip to content

Commit c9cb9f4

Browse files
add yaml as storage for tools
1 parent d52f726 commit c9cb9f4

20 files changed

+1362
-238
lines changed

app/components/Home.tsx

Lines changed: 50 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"use client"
2-
import React, { useState, useMemo } from "react"
1+
import React, { useState, useMemo, useEffect } from "react"
2+
import yaml from "js-yaml"
33
import { Input, Card, Typography, Menu, Collapse, Empty, Button } from "antd"
44
import ToolMapButton from "./Button"
55

@@ -34,76 +34,65 @@ const categories = {
3434
],
3535
"End Of Life": ["Repossession & Reverse logistics", "E-Waste Management"],
3636
}
37-
38-
const tools = [
39-
{
40-
name: "PayGee",
41-
summary: "A payment processing tool.",
42-
logo: "/path/to/paygee-logo.png",
43-
link: "https://paygee.com",
44-
categories: ["Bookkeeping & Accounting"],
45-
},
46-
{
47-
name: "Odoo",
48-
summary: "An all-in-one management software.",
49-
logo: "/path/to/odoo-logo.png",
50-
link: "https://odoo.com",
51-
categories: ["Bookkeeping & Accounting"],
52-
},
53-
{
54-
name: "Quickbooks",
55-
summary: "Accounting software for small businesses.",
56-
logo: "/path/to/quickbooks-logo.png",
57-
link: "https://quickbooks.intuit.com",
58-
categories: ["Bookkeeping & Accounting"],
59-
},
60-
{
61-
name: "Upya",
62-
summary: "A financial management tool.",
63-
logo: "/path/to/upya-logo.png",
64-
link: "https://upya.com",
65-
categories: [
66-
"Bookkeeping & Accounting",
67-
"Impact Measurements & Performance",
68-
],
69-
},
70-
{
71-
name: "Xero",
72-
summary: "Online accounting software.",
73-
logo: "/path/to/xero-logo.png",
74-
link: "https://xero.com",
75-
categories: ["Bookkeeping & Accounting"],
76-
},
77-
{
78-
name: "Odyssey",
79-
summary: "A project management tool.",
80-
logo: "/path/to/odyssey-logo.png",
81-
link: "https://odyssey.com",
82-
categories: ["Product Procurement", "Impact Measurements & Performance"],
83-
},
84-
{
85-
name: "Unleashed",
86-
summary: "Inventory management software.",
87-
logo: "/path/to/unleashed-logo.png",
88-
link: "https://unleashedsoftware.com",
89-
categories: ["Product Procurement", "Impact Measurements & Performance"],
90-
},
91-
]
92-
9337
interface EnAccessToolMapProps {
9438
setIsModalOpen: (value: boolean) => void
9539
}
96-
40+
interface Tool {
41+
name: string
42+
summary: string
43+
logo: string
44+
link: string
45+
categories: string[]
46+
}
9747
const EnAccessToolMap = ({ setIsModalOpen }: EnAccessToolMapProps) => {
9848
const [activeTool, setActiveTool] = useState<string | null>(null)
9949
const [searchTerm, setSearchTerm] = useState<string>("")
10050
const [selectedCategories, setSelectedCategories] = useState<string[]>([])
51+
const [tools, setTools] = useState<Tool[]>([])
52+
53+
useEffect(() => {
54+
// Load all YAML files
55+
const loadTools = async () => {
56+
try {
57+
const toolFiles = [
58+
"/tools/paygee.yaml",
59+
"/tools/odoo.yaml",
60+
"/tools/quickbooks.yaml",
61+
"/tools/upya.yaml",
62+
"/tools/xero.yaml",
63+
"/tools/odyssey.yaml",
64+
"/tools/unleashed.yaml",
65+
"/tools/3cx.yaml",
66+
"/tools/d-rec.yaml",
67+
"/tools/ixo.yaml",
68+
"/tools/p-rec.yaml",
69+
"/tools/sendy.yaml",
70+
"/tools/challenges.yaml",
71+
"/tools/carbon-clear.yaml",
72+
"/tools/cavex.yaml",
73+
]
74+
75+
const loadedTools = await Promise.all(
76+
toolFiles.map(async (file) => {
77+
const response = await fetch(file)
78+
const text = await response.text()
79+
return yaml.load(text) as Tool
80+
})
81+
)
82+
83+
setTools(loadedTools)
84+
} catch (error) {
85+
console.error("Error loading YAML files:", error)
86+
}
87+
}
88+
89+
loadTools()
90+
}, [])
10191

10292
const handleToolClick = (toolName: string) => {
10393
setActiveTool(activeTool === toolName ? null : toolName)
10494
}
10595

106-
// Handle menu item selection
10796
const handleMenuClick = ({ key }: { key: string }) => {
10897
// Check if the category is already selected
10998
if (selectedCategories.includes(key)) {
@@ -113,9 +102,7 @@ const EnAccessToolMap = ({ setIsModalOpen }: EnAccessToolMapProps) => {
113102
}
114103
}
115104

116-
// Filter tools based on search term and selected categories
117105
const filteredTools = useMemo(() => {
118-
// Only show tools when categories are selected
119106
if (selectedCategories.length === 0) {
120107
return []
121108
}
@@ -132,7 +119,7 @@ const EnAccessToolMap = ({ setIsModalOpen }: EnAccessToolMapProps) => {
132119

133120
return matchesSearch && matchesCategories
134121
})
135-
}, [searchTerm, selectedCategories])
122+
}, [searchTerm, selectedCategories, tools])
136123

137124
return (
138125
<div className="bg-white text-gray-800">

0 commit comments

Comments
 (0)