From b50e5415658c42c7102510a01dc66f5080febb9f Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Fri, 25 Apr 2025 21:04:32 -0400 Subject: New country; New page; Update packages --- app/components/Navbar.js | 4 +- app/components/PSA.js | 2 +- app/components/psa.json | 6 +- app/countries.json | 25 ++++--- app/enterprises/page.js | 133 +++++++++++++++++++++++++++++++++++ app/travel-advisory/ListCountries.js | 2 +- app/updates/[slug]/page.js | 8 +-- app/visas/ListCountries.js | 2 +- 8 files changed, 162 insertions(+), 20 deletions(-) create mode 100644 app/enterprises/page.js (limited to 'app') diff --git a/app/components/Navbar.js b/app/components/Navbar.js index 4c172da..3b42990 100644 --- a/app/components/Navbar.js +++ b/app/components/Navbar.js @@ -27,12 +27,12 @@ const Navbar = () => { {[ ['Home', '/'], ['Updates', '/updates'], - // ['Services', '/services'], + ['Enterprises', '/enterprises'], ['Travel Advisory', '/travel-advisory'], ['Visas', '/visas'], ['Immigration', '/immigration'], ].map(([title, url]) => ( -
  • +
  • setNavbar(!navbar)}> {title} diff --git a/app/components/PSA.js b/app/components/PSA.js index f5193a8..da5f35b 100644 --- a/app/components/PSA.js +++ b/app/components/PSA.js @@ -1,4 +1,4 @@ -import psaMessage from './psa.json' assert { type: 'json' }; +import psaMessage from './psa.json' with { type: 'json' }; import Link from "next/link"; const PSA = () => { diff --git a/app/components/psa.json b/app/components/psa.json index 08fac73..691070b 100644 --- a/app/components/psa.json +++ b/app/components/psa.json @@ -1,5 +1,5 @@ { - "important": 0, - "announcement": "Want to become an Alure Regions resident? Check out this post for more information.", - "link": "/updates/announcing-immigration" + "important": 1, + "announcement": "Internal businesses now require to register with the government.", + "link": "/updates/enterprises-registering" } diff --git a/app/countries.json b/app/countries.json index 588a1e6..d783394 100644 --- a/app/countries.json +++ b/app/countries.json @@ -44,6 +44,19 @@ "settlements": [], "history": [] }, + { + "name": "Basuran Federal Union", + "short": "BFU", + "url": "basuran", + "visa": true, + "visaInfo": [], + "image": "/countries/basuran.webp", + "danger": 3, + "settlements": [], + "history": [ + "April 2025: Internal civil war between states." + ] + }, { "name": "The Republic of Bohemia", "short": "BHM", @@ -73,11 +86,9 @@ "visa": true, "visaInfo": [], "image": "/countries/doodadsandgizmos.webp", - "danger": 3, + "danger": 0, "settlements": [], - "history": [ - "March 2025: Gizmo City announced that they will nuke Sorena. Their citizens responded with a revolution." - ] + "history": [] }, { "name": "Eagle City", @@ -262,11 +273,9 @@ "visa": true, "visaInfo": [], "image": "/countries/sorena.webp", - "danger": 3, + "danger": 0, "settlements": [], - "history": [ - "March 2025: Internal turnoil in Sorena." - ] + "history": [] }, { "name": "Sulópolis", diff --git a/app/enterprises/page.js b/app/enterprises/page.js new file mode 100644 index 0000000..7d8ce02 --- /dev/null +++ b/app/enterprises/page.js @@ -0,0 +1,133 @@ +import Header from "../components/Header"; +import { google } from "googleapis"; + +const auth = new google.auth.GoogleAuth({ + credentials: { + client_email: process.env.GOOGLE_CLIENT_EMAIL, + private_key: process.env.GOOGLE_PRIVATE_KEY.replace(/\\n/g, '\n'), + project_id: process.env.GOOGLE_PROJECT_ID, + }, + scopes: ['https://www.googleapis.com/auth/spreadsheets.readonly'], +}); + + +async function fetchSheetData(spreadsheetId, range) { + const client = await auth.getClient(); + const sheets = google.sheets('v4'); + const response = await sheets.spreadsheets.values.get({ + auth: client, + spreadsheetId, + range, + }); + + const rows = response.data.values; + + // Define the headers + const headers = [ + 'CompanyID', + 'Businesses', + 'ParentCompany', + 'Type', + 'Owner', + 'Status', + 'Notes' + ]; + + // Map rows to objects + const formattedData = rows.slice(1).map(row => { + const obj = {}; + headers.forEach((header, index) => { + let value = row[index] || ''; // Assign empty string if value is missing + if (header === 'Businesses') { + value = value.includes('\n') ? value.split('\n') : [value]; // Split into array if multiple businesses + } + obj[header] = value; + }); + return obj; + }); + + return Object.values( + formattedData.reduce((acc, company) => { + const parent = company.ParentCompany; + if (!acc[parent]) { + acc[parent] = {...company, Businesses: [...company.Businesses]}; + } else { + acc[parent].Businesses = [...acc[parent].Businesses, ...company.Businesses]; + } + return acc; + }, {}) + ); +} + + +export const metadata = { + title: 'Enterprises', + description: 'Registered enterprises in the Alure Regions', +} + +export default async function Services() { + const response = await fetchSheetData('1VWt21lvbqBRmpZPeC87ZXJphibMEATFp48PPW457q38', 'A1:G32'); + + return ( +
    +
    +
    +
    +

    Want to start a business?

    +

    Register with the Alure Regions government in order to operate a company.

    +
    + {/*
    + +
    +
    + +
    + +
    +
    */} + +
    + { + response.map((company) => { + return ( +
    +

    {company.ParentCompany}

    +

    Business ID: {company.CompanyID} • Owner: {company.Owner}

    +

    Type: {company.Type}

    +

    Status: Operational

    +

    Businesses

    +
      + { + company.Businesses.map((business) => { + return ( +
    • + {business} +
    • + ) + }) + } +
    + { + company.Notes && ( + <> +

    Notes:

    +

    {company.Notes}

    + + ) + } +
    + ) + }) + } +
    +
    +
    + ) +} diff --git a/app/travel-advisory/ListCountries.js b/app/travel-advisory/ListCountries.js index 7e59216..4248cd1 100644 --- a/app/travel-advisory/ListCountries.js +++ b/app/travel-advisory/ListCountries.js @@ -1,5 +1,5 @@ "use client" -import countriesData from '@/app/countries.json' assert { type: 'json' }; +import countriesData from '@/app/countries.json' with { type: 'json' }; import HistoryModal from "@/app/travel-advisory/HistoryModal"; import { useState } from "react"; diff --git a/app/updates/[slug]/page.js b/app/updates/[slug]/page.js index 555caa7..e5feabd 100644 --- a/app/updates/[slug]/page.js +++ b/app/updates/[slug]/page.js @@ -11,8 +11,8 @@ const getPostContent = (slug) => { return matter(content); } -export function generateMetadata(props) { - const slug = props.params.slug; +export async function generateMetadata(props) { + const slug = (await props.params).slug; const post = getPostContent(slug); return { @@ -28,8 +28,8 @@ export const generateStaticParams = async () => { })) } -export default function PostPage(props) { - const slug = props.params.slug; +export default async function PostPage(props) { + const slug = (await props.params).slug; const post = getPostContent(slug); return (
    diff --git a/app/visas/ListCountries.js b/app/visas/ListCountries.js index 1e926cf..bd15b9a 100644 --- a/app/visas/ListCountries.js +++ b/app/visas/ListCountries.js @@ -1,5 +1,5 @@ "use client" -import countriesData from '@/app/countries.json' assert { type: 'json' }; +import countriesData from '@/app/countries.json' with { type: 'json' }; import HistoryModal from "@/app/visas/HistoryModal"; import { useState } from "react"; -- cgit v1.2.3