// Mock data for admin panel
const mockContacts = [
{
id: 1,
name: "John Doe",
email: "john@example.com",
phone: "555-1234",
city: "New York",
attachments: [
{ name: "project-brief.pdf", url: "http://static.photos/document/640x360/1" },
{ name: "reference.jpg", url: "http://static.photos/nature/640x360/1" }
]
},
{
id: 2,
name: "Jane Smith",
email: "jane@example.com",
phone: "555-5678",
city: "Los Angeles",
attachments: []
}
];
const mockSubscribers = [
{ id: 1, email: "user1@example.com", date: "2023-01-15" },
{ id: 2, email: "user2@example.com", date: "2023-02-20" }
];
// DOM elements
const adminContent = document.getElementById('admin-content');
// Navigation functions
function loadProjectsManagement() {
adminContent.innerHTML = `
Projects Management
Add Project
Image
Name
Description
Actions
${mockProjects.map(project => `
${project.name}
${project.description.substring(0, 50)}...
`).join('')}
`;
feather.replace();
// Form toggle
document.getElementById('add-project-btn').addEventListener('click', () => {
document.getElementById('add-project-form').classList.toggle('hidden');
});
document.getElementById('cancel-project-btn').addEventListener('click', () => {
document.getElementById('add-project-form').classList.add('hidden');
});
// Form submission
document.getElementById('project-form').addEventListener('submit', (e) => {
e.preventDefault();
alert('Project saved successfully!');
document.getElementById('add-project-form').classList.add('hidden');
document.getElementById('project-form').reset();
});
}
function loadClientsManagement() {
adminContent.innerHTML = `
Clients Management
Add Client
Image
Name
Designation
Testimonial
Actions
${mockClients.map(client => `
${client.name}
${client.designation}
"${client.description.substring(0, 50)}..."
`).join('')}
`;
feather.replace();
// Form toggle
document.getElementById('add-client-btn').addEventListener('click', () => {
document.getElementById('add-client-form').classList.toggle('hidden');
});
document.getElementById('cancel-client-btn').addEventListener('click', () => {
document.getElementById('add-client-form').classList.add('hidden');
});
// Form submission
document.getElementById('client-form').addEventListener('submit', (e) => {
e.preventDefault();
alert('Client saved successfully!');
document.getElementById('add-client-form').classList.add('hidden');
document.getElementById('client-form').reset();
});
}
function loadContactResponses() {
adminContent.innerHTML = `
Contact Form Responses
Name
Email
Phone
City
Actions
${mockContacts.map(contact => `
${contact.name}
${contact.email}
${contact.phone}
${contact.city}
${contact.attachments.length > 0 ? `
Attachments (${contact.attachments.length})
${contact.attachments.map(file => `
${file.name}
`).join('')}
` : ''}
`).join('')}
`;
feather.replace();
}
function loadSubscribers() {
adminContent.innerHTML = `
Newsletter Subscribers
Email
Subscription Date
Actions
${mockSubscribers.map(subscriber => `
${subscriber.email}
${subscriber.date}
`).join('')}
`;
feather.replace();
}
// Initialize admin panel
document.addEventListener('DOMContentLoaded', function() {
// This would be set based on navigation in the sidebar component
// For now, we'll default to projects management
loadProjectsManagement();
});