-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
131 lines (116 loc) · 3.27 KB
/
types.ts
File metadata and controls
131 lines (116 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* Represents the two main sections of the Boys' Brigade.
*/
export type Section = 'company' | 'junior';
/**
* Represents the squad numbers for the Company Section.
*/
export type Squad = 1 | 2 | 3;
/**
* Represents the school year for members of the Company Section.
*/
export type SchoolYear = 8 | 9 | 10 | 11 | 12 | 13 | 14;
/**
* Represents the squad numbers for the Junior Section.
*/
export type JuniorSquad = 1 | 2 | 3 | 4;
/**
* Represents the school year (Primary school levels) for members of the Junior Section.
*/
export type JuniorYear = 'P4' | 'P5' | 'P6' | 'P7';
/**
* Represents a single weekly mark entry for a member.
* A score of -1 indicates absence.
*/
export interface Mark {
/** The date of the meeting in 'YYYY-MM-DD' format. */
date: string;
/** The total score for the night. -1 if absent. */
score: number;
/** (Junior Section only) The score for uniform inspection. */
uniformScore?: number;
/** (Junior Section only) The score for behaviour. */
behaviourScore?: number;
}
/**
* Represents the weekly snapshot payload used for section-wide mark saves.
*/
export interface WeeklyMarksSnapshotEntry {
memberId: string;
mark: Mark | null;
}
/**
* Represents a single member of the Boys' Brigade.
*/
export interface Boy {
/** A unique identifier generated by Supabase. */
id?: string;
/** The full name of the member. */
name: string;
/** The squad number the member belongs to. */
squad: Squad | JuniorSquad;
/** The school year of the member. */
year: SchoolYear | JuniorYear;
/** An array of all recorded marks for the member. */
marks: Mark[];
/** A flag indicating if the member is a designated squad leader. */
isSquadLeader?: boolean;
}
/**
* Represents the main pages available in the application's navigation.
*/
export type Page = 'home' | 'weeklyMarks' | 'dashboard' | 'settings' | 'accountSettings';
/**
* A specific view type for displaying an individual boy's marks page.
* Includes the boy's ID to fetch the correct data.
*/
export interface BoyMarksPageView {
page: 'boyMarks';
boyId: string;
}
/**
* A union type representing the current view of the application,
* which can be a standard page or a more specific view like BoyMarksPageView.
*/
export type View = { page: Page } | BoyMarksPageView;
/**
* Represents the settings specific to a section (Company or Junior).
*/
export interface SectionSettings {
/** The day of the week the section meets (0 = Sunday, 1 = Monday, ..., 6 = Saturday). */
meetingDay: number;
}
/**
* Defines the types of toast notifications.
*/
export type ToastType = 'success' | 'error' | 'info';
/**
* Represents a single toast notification message.
*/
export interface ToastMessage {
id: string;
message: string;
type: ToastType;
}
/**
* Defines the available sorting options for the member roster.
*/
export type SortByType = 'name' | 'marks' | 'attendance';
/**
* Defines the possible roles a user can have in the application.
*/
export type UserRole = 'admin' | 'captain' | 'officer';
/**
* Minimal authenticated user shape for Supabase auth.
*/
export interface AppUser {
id: string;
email: string;
}
/**
* Combines an authenticated user with their assigned application role.
*/
export interface UserWithRole {
user: AppUser;
role: UserRole;
}