feat: Add admin calendar and improve availability management

- Add admin calendar component with booking overview and status management
- Implement treatment-specific availability slots with automatic duration
- Enhance availability management with better UI and error handling
- Move admin credentials to .env configuration
- Add .env.example with all required environment variables
- Update README.md with comprehensive setup guide including PowerShell password hash generation
- Improve slot deletion with proper error handling and user feedback
- Add toast notifications for better UX
This commit is contained in:
2025-09-30 10:58:33 +02:00
parent 2e5bfdd879
commit 072c7985c7
8 changed files with 841 additions and 136 deletions

View File

@@ -34,20 +34,31 @@ const verifyPassword = (password: string, hash: string): boolean => {
return hashPassword(password) === hash;
};
// Export hashPassword for external use (e.g., generating hashes for .env)
export const generatePasswordHash = hashPassword;
// Initialize default owner account
const initializeOwner = async () => {
const existingUsers = await usersKV.getAllItems();
if (existingUsers.length === 0) {
const ownerId = randomUUID();
// Get admin credentials from environment variables
const adminUsername = process.env.ADMIN_USERNAME || "owner";
const adminPasswordHash = process.env.ADMIN_PASSWORD_HASH || hashPassword("admin123");
const adminEmail = process.env.ADMIN_EMAIL || "owner@stargirlnails.de";
const owner: User = {
id: ownerId,
username: "owner",
email: "owner@stargirlnails.de",
passwordHash: hashPassword("admin123"), // Default password
username: adminUsername,
email: adminEmail,
passwordHash: adminPasswordHash,
role: "owner",
createdAt: new Date().toISOString(),
};
await usersKV.setItem(ownerId, owner);
console.log(`✅ Admin account created: username="${adminUsername}", email="${adminEmail}"`);
}
};