latest changes

This commit is contained in:
Lucas Tan 2025-08-19 12:18:58 +08:00
parent 27c78e2ac4
commit 6ad81a04ad
3 changed files with 27 additions and 22 deletions

View File

@ -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:

View File

@ -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<StaffProfile>(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<StaffProfile> = {};
const overrides: Partial<ReturnType<typeof getCompleteEmployeeProfile>> = {};
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]);

View File

@ -1,12 +1,18 @@
import { StaffProfile } from './staff';
export interface Employee extends StaffProfile {
export interface Employee extends Omit<StaffProfile, 'address' | 'logoPath' | 'website'> {
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;