latest changes
This commit is contained in:
parent
27c78e2ac4
commit
6ad81a04ad
@ -61,13 +61,12 @@ To add a new employee, add an entry to the `employees` array:
|
|||||||
whatsapp: "60123456789", // WhatsApp number (digits only)
|
whatsapp: "60123456789", // WhatsApp number (digits only)
|
||||||
email: "john.doe@rooftop.my", // Email address
|
email: "john.doe@rooftop.my", // Email address
|
||||||
linkedin: "https://linkedin.com/in/johndoe", // LinkedIn profile URL
|
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
|
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
|
#### URL Structure
|
||||||
|
|
||||||
Each employee gets their own URL:
|
Each employee gets their own URL:
|
||||||
|
|||||||
@ -2,22 +2,23 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { Phone, Mail, Globe, Copy, Download, Check } from 'lucide-react';
|
import { Phone, Mail, Globe, Copy, Download, Check } from 'lucide-react';
|
||||||
|
import { Employee, getCompleteEmployeeProfile } from '@/config/employees';
|
||||||
import { StaffProfile } from '@/config/staff';
|
import { StaffProfile } from '@/config/staff';
|
||||||
|
|
||||||
interface NamecardProps {
|
interface NamecardProps {
|
||||||
profile: StaffProfile;
|
profile: Employee;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Namecard({ profile }: NamecardProps) {
|
export default function Namecard({ profile }: NamecardProps) {
|
||||||
const [copySuccess, setCopySuccess] = useState(false);
|
const [copySuccess, setCopySuccess] = useState(false);
|
||||||
const [showFullAddress, setShowFullAddress] = 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
|
// Handle URL query parameters on client side
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
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('name')) overrides.name = urlParams.get('name')!;
|
||||||
if (urlParams.get('title')) overrides.title = urlParams.get('title')!;
|
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 (urlParams.get('logo')) overrides.logoPath = urlParams.get('logo')!;
|
||||||
|
|
||||||
if (Object.keys(overrides).length > 0) {
|
if (Object.keys(overrides).length > 0) {
|
||||||
setCurrentProfile({ ...profile, ...overrides });
|
const completeProfile = getCompleteEmployeeProfile(profile);
|
||||||
|
setCurrentProfile({ ...completeProfile, ...overrides });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [profile]);
|
}, [profile]);
|
||||||
|
|||||||
@ -1,12 +1,18 @@
|
|||||||
import { StaffProfile } from './staff';
|
import { StaffProfile } from './staff';
|
||||||
|
|
||||||
export interface Employee extends StaffProfile {
|
export interface Employee extends Omit<StaffProfile, 'address' | 'logoPath' | 'website'> {
|
||||||
id: string;
|
id: string;
|
||||||
profilePic: string;
|
profilePic: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import the YAML data (you'll need to install js-yaml if you want to parse YAML files)
|
// Company-wide settings
|
||||||
// For now, we'll define the data directly in TypeScript
|
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[] = [
|
export const employees: Employee[] = [
|
||||||
{
|
{
|
||||||
id: "john-doe",
|
id: "john-doe",
|
||||||
@ -16,9 +22,6 @@ export const employees: Employee[] = [
|
|||||||
whatsapp: "60123456789",
|
whatsapp: "60123456789",
|
||||||
email: "john.doe@rooftop.my",
|
email: "john.doe@rooftop.my",
|
||||||
linkedin: "https://linkedin.com/in/johndoe",
|
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"
|
profilePic: "/profilepic.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -29,9 +32,6 @@ export const employees: Employee[] = [
|
|||||||
whatsapp: "60123456790",
|
whatsapp: "60123456790",
|
||||||
email: "jane.smith@rooftop.my",
|
email: "jane.smith@rooftop.my",
|
||||||
linkedin: "https://linkedin.com/in/janesmith",
|
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"
|
profilePic: "/profilepic.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -42,9 +42,6 @@ export const employees: Employee[] = [
|
|||||||
whatsapp: "60123456791",
|
whatsapp: "60123456791",
|
||||||
email: "ahmad.ali@rooftop.my",
|
email: "ahmad.ali@rooftop.my",
|
||||||
linkedin: "https://linkedin.com/in/ahmadali",
|
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"
|
profilePic: "/profilepic.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -55,9 +52,6 @@ export const employees: Employee[] = [
|
|||||||
whatsapp: "60123456792",
|
whatsapp: "60123456792",
|
||||||
email: "sarah.wong@rooftop.my",
|
email: "sarah.wong@rooftop.my",
|
||||||
linkedin: "https://linkedin.com/in/sarahwong",
|
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"
|
profilePic: "/profilepic.png"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@ -70,4 +64,14 @@ export function getAllEmployees(): Employee[] {
|
|||||||
return employees;
|
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;
|
export default employees;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user