feat: implement admin blocks management feature
- Added AdminBlocksManagement component for managing court blocks. - Implemented functionality to create, edit, and delete blocks. - Integrated fetching of courts and blocks from the API. - Added validation for block creation and editing forms. - Enhanced UI with responsive design for mobile and desktop views. - Created database migration for court_blocks table and updated users table with theme_preference.
This commit is contained in:
@@ -104,6 +104,20 @@ export const metrics = sqliteTable('metrics', {
|
||||
updatedAt: integer('updated_at', { mode: 'timestamp' }).notNull(),
|
||||
});
|
||||
|
||||
// Court blocks table for admin-managed closures (tournaments, maintenance, etc.)
|
||||
export const courtBlocks = sqliteTable('court_blocks', {
|
||||
id: text('id').primaryKey(),
|
||||
courtId: text('court_id').references(() => courts.id, { onDelete: 'cascade' }), // NULL means all courts
|
||||
date: text('date').notNull(), // Format: "YYYY-MM-DD"
|
||||
startTime: text('start_time').notNull(), // Format: "HH:MM"
|
||||
endTime: text('end_time').notNull(), // Format: "HH:MM"
|
||||
reason: text('reason').notNull(), // e.g., "Tournament", "AGM", "Maintenance"
|
||||
createdBy: text('created_by')
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: 'cascade' }),
|
||||
createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
|
||||
});
|
||||
|
||||
// Zod schemas for validation
|
||||
export const insertUserSchema = createInsertSchema(users);
|
||||
export const selectUserSchema = createSelectSchema(users);
|
||||
@@ -121,6 +135,8 @@ export const insertActivityLogSchema = createInsertSchema(activityLogs);
|
||||
export const selectActivityLogSchema = createSelectSchema(activityLogs);
|
||||
export const insertMetricSchema = createInsertSchema(metrics);
|
||||
export const selectMetricSchema = createSelectSchema(metrics);
|
||||
export const insertCourtBlockSchema = createInsertSchema(courtBlocks);
|
||||
export const selectCourtBlockSchema = createSelectSchema(courtBlocks);
|
||||
|
||||
// Types
|
||||
export type User = typeof users.$inferSelect;
|
||||
@@ -139,3 +155,5 @@ export type ActivityLog = typeof activityLogs.$inferSelect;
|
||||
export type NewActivityLog = typeof activityLogs.$inferInsert;
|
||||
export type Metric = typeof metrics.$inferSelect;
|
||||
export type NewMetric = typeof metrics.$inferInsert;
|
||||
export type CourtBlock = typeof courtBlocks.$inferSelect;
|
||||
export type NewCourtBlock = typeof courtBlocks.$inferInsert;
|
||||
|
||||
Reference in New Issue
Block a user