From 6ad81a04ad36e0db171acda578885f4d8ca7ebc1 Mon Sep 17 00:00:00 2001 From: Lucas Tan Date: Tue, 19 Aug 2025 12:18:58 +0800 Subject: [PATCH] latest changes --- README.md | 5 ++--- src/components/Namecard.tsx | 10 ++++++---- src/config/employees.ts | 34 +++++++++++++++++++--------------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index dff9531..d338656 100644 --- a/README.md +++ b/README.md @@ -61,13 +61,12 @@ To add a new employee, add an entry to the `employees` array: whatsapp: "60123456789", // WhatsApp number (digits only) email: "john.doe@rooftop.my", // Email address linkedin: "https://linkedin.com/in/johndoe", // LinkedIn profile URL - address: "Level 15, Menara 1 Sentral\nKuala Lumpur Sentral\n50470 Kuala Lumpur\nMalaysia", // Address with \n for line breaks - website: "https://rooftop.my", // Company website - logoPath: "/logo.png", // Path to company logo profilePic: "/profilepic.png" // Path to profile picture } ``` +**Note:** Company-wide settings (address, website, logo) are automatically applied from `companySettings` and don't need to be repeated for each employee. + #### URL Structure Each employee gets their own URL: diff --git a/src/components/Namecard.tsx b/src/components/Namecard.tsx index e225ea0..dbce7c2 100644 --- a/src/components/Namecard.tsx +++ b/src/components/Namecard.tsx @@ -2,22 +2,23 @@ import { useState, useEffect } from 'react'; import { Phone, Mail, Globe, Copy, Download, Check } from 'lucide-react'; +import { Employee, getCompleteEmployeeProfile } from '@/config/employees'; import { StaffProfile } from '@/config/staff'; interface NamecardProps { - profile: StaffProfile; + profile: Employee; } export default function Namecard({ profile }: NamecardProps) { const [copySuccess, setCopySuccess] = useState(false); const [showFullAddress, setShowFullAddress] = useState(false); - const [currentProfile, setCurrentProfile] = useState(profile); + const [currentProfile, setCurrentProfile] = useState(getCompleteEmployeeProfile(profile)); // Handle URL query parameters on client side useEffect(() => { if (typeof window !== 'undefined') { const urlParams = new URLSearchParams(window.location.search); - const overrides: Partial = {}; + const overrides: Partial> = {}; if (urlParams.get('name')) overrides.name = urlParams.get('name')!; if (urlParams.get('title')) overrides.title = urlParams.get('title')!; @@ -30,7 +31,8 @@ export default function Namecard({ profile }: NamecardProps) { if (urlParams.get('logo')) overrides.logoPath = urlParams.get('logo')!; if (Object.keys(overrides).length > 0) { - setCurrentProfile({ ...profile, ...overrides }); + const completeProfile = getCompleteEmployeeProfile(profile); + setCurrentProfile({ ...completeProfile, ...overrides }); } } }, [profile]); diff --git a/src/config/employees.ts b/src/config/employees.ts index 7a6cf11..e609419 100644 --- a/src/config/employees.ts +++ b/src/config/employees.ts @@ -1,12 +1,18 @@ import { StaffProfile } from './staff'; -export interface Employee extends StaffProfile { +export interface Employee extends Omit { id: string; profilePic: string; } -// Import the YAML data (you'll need to install js-yaml if you want to parse YAML files) -// For now, we'll define the data directly in TypeScript +// Company-wide settings +export const companySettings = { + address: "3-2, Block D2, Jalan PJU 1A/39\nDataran Prima\n47301 Petaling Jaya\nMalaysia", + logoPath: "/logo.png", + website: "https://rooftop.my" +}; + +// Employee-specific data only export const employees: Employee[] = [ { id: "john-doe", @@ -16,9 +22,6 @@ export const employees: Employee[] = [ whatsapp: "60123456789", email: "john.doe@rooftop.my", linkedin: "https://linkedin.com/in/johndoe", - address: "Level 15, Menara 1 Sentral\nKuala Lumpur Sentral\n50470 Kuala Lumpur\nMalaysia", - website: "https://rooftop.my", - logoPath: "/logo.png", profilePic: "/profilepic.png" }, { @@ -29,9 +32,6 @@ export const employees: Employee[] = [ whatsapp: "60123456790", email: "jane.smith@rooftop.my", linkedin: "https://linkedin.com/in/janesmith", - address: "Level 15, Menara 1 Sentral\nKuala Lumpur Sentral\n50470 Kuala Lumpur\nMalaysia", - website: "https://rooftop.my", - logoPath: "/logo.png", profilePic: "/profilepic.png" }, { @@ -42,9 +42,6 @@ export const employees: Employee[] = [ whatsapp: "60123456791", email: "ahmad.ali@rooftop.my", linkedin: "https://linkedin.com/in/ahmadali", - address: "Level 15, Menara 1 Sentral\nKuala Lumpur Sentral\n50470 Kuala Lumpur\nMalaysia", - website: "https://rooftop.my", - logoPath: "/logo.png", profilePic: "/profilepic.png" }, { @@ -55,9 +52,6 @@ export const employees: Employee[] = [ whatsapp: "60123456792", email: "sarah.wong@rooftop.my", linkedin: "https://linkedin.com/in/sarahwong", - address: "Level 15, Menara 1 Sentral\nKuala Lumpur Sentral\n50470 Kuala Lumpur\nMalaysia", - website: "https://rooftop.my", - logoPath: "/logo.png", profilePic: "/profilepic.png" } ]; @@ -70,4 +64,14 @@ export function getAllEmployees(): Employee[] { return employees; } +// Helper function to get complete employee profile with company settings +export function getCompleteEmployeeProfile(employee: Employee): StaffProfile { + return { + ...employee, + address: companySettings.address, + logoPath: companySettings.logoPath, + website: companySettings.website + }; +} + export default employees;