first commit. working
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
export function exportToCsv(filename: string, rows: any[]) {
|
||||
if (!rows.length) return;
|
||||
const keys = Object.keys(rows[0]);
|
||||
const csv = keys.join(',') + '\\n' +
|
||||
rows.map(r => keys.map(k => JSON.stringify(r[k] || '')).join(',')).join('\\n');
|
||||
const blob = new Blob([csv], { type: 'text/csv' });
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import Dexie from 'dexie';
|
||||
|
||||
export interface Teacher { id: string; name: string }
|
||||
export interface AttendanceRecord {
|
||||
id: string;
|
||||
teacherId: string;
|
||||
timestamp: number;
|
||||
type: 'in' | 'out';
|
||||
}
|
||||
|
||||
export class AppDB extends Dexie {
|
||||
teachers!: Dexie.Table<Teacher, string>;
|
||||
records!: Dexie.Table<AttendanceRecord, string>;
|
||||
|
||||
constructor() {
|
||||
super('AttendanceDB');
|
||||
this.version(1).stores({
|
||||
teachers: 'id, name',
|
||||
records: 'id, teacherId, timestamp, type',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const db = new AppDB();
|
||||
Reference in New Issue
Block a user