- Add .gitignore, .yarnrc.yml, and initial project metadata (AGENTS.md, DESIGN.md, package.json, Yarn lock, Tailwind, PostCSS, Next.js config, TypeScript config) - Add CSV data files (users, employees, contracts, attendances) - Implement API routes for auth, employees, contracts, attendances, analytics, and file upload - Add core pages (dashboard, employees, attendances, profile, login, main layout) - Add UI components (avatar, avatar picker, badge, button, card, input, modal, select, sidebar, navigation shell, top header) - Add attendance features (table, clock widget, unified permit modal with file upload, upload API) - Add employee management (contract timeline with file upload, employee form modal, employee table) - Add dashboard widgets (leaderboard, early bird, latecomer, night owl, day status feed, date filter bar) - Add utilities (avatar generator, analytics calculations, CSV DB layer, auth context) - Add type definitions for auth, employee, contract, attendance, dashboard All changes are synchronized with documentation (AGENTS.md, DESIGN.md, walkthrough).
32 lines
972 B
TypeScript
32 lines
972 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { cookies } from 'next/headers';
|
|
import { getUserById, getEmployeeById } from '@/lib/csv-db';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const cookieStore = cookies();
|
|
const sessionCookie = cookieStore.get('eigen_session');
|
|
|
|
if (!sessionCookie?.value) {
|
|
// Default demo superadmin session if no cookie yet
|
|
const adminUser = await getUserById('USR-001');
|
|
const adminEmployee = adminUser?.employee_id ? await getEmployeeById(adminUser.employee_id) : null;
|
|
return NextResponse.json({
|
|
authenticated: true,
|
|
session: {
|
|
user: adminUser,
|
|
employee: adminEmployee,
|
|
},
|
|
});
|
|
}
|
|
|
|
const sessionData = JSON.parse(sessionCookie.value);
|
|
return NextResponse.json({
|
|
authenticated: true,
|
|
session: sessionData,
|
|
});
|
|
} catch (error: any) {
|
|
return NextResponse.json({ authenticated: false, session: null }, { status: 200 });
|
|
}
|
|
}
|