All checks were successful
Chore App Build and Push Docker Images / build-and-push (push) Successful in 1m4s
- Added `requireDirty` prop to `EntityEditForm` for dirty state management. - Updated `ChildEditView` to handle initial data loading and image selection more robustly. - Refactored `ChildView` to remove unused reward dialog logic and prevent API calls in child mode. - Improved type definitions for form fields and initial data in `ChildEditView`. - Enhanced error handling in form submissions across components. - Implemented cross-tab logout synchronization on password reset in the auth store. - Added tests for login and entity edit form functionalities to ensure proper behavior. - Introduced global fetch interceptor for handling unauthorized responses. - Documented password reset flow and its implications on session management.
216 lines
4.6 KiB
TypeScript
216 lines
4.6 KiB
TypeScript
export interface Task {
|
|
id: string
|
|
name: string
|
|
points: number
|
|
is_good: boolean
|
|
image_id: string | null
|
|
image_url?: string | null // optional, for resolved URLs
|
|
}
|
|
export const TASK_FIELDS = ['id', 'name', 'points', 'is_good', 'image_id'] as const
|
|
|
|
export interface User {
|
|
id: string
|
|
first_name: string
|
|
last_name: string
|
|
email: string
|
|
token_version: number
|
|
image_id: string | null
|
|
marked_for_deletion: boolean
|
|
marked_for_deletion_at: string | null
|
|
deletion_in_progress: boolean
|
|
deletion_attempted_at: string | null
|
|
role: string
|
|
}
|
|
|
|
export interface Child {
|
|
id: string
|
|
name: string
|
|
age: number
|
|
tasks: string[]
|
|
rewards: string[]
|
|
points: number
|
|
image_id: string | null
|
|
image_url?: string | null // optional, for resolved URLs
|
|
}
|
|
export const CHILD_FIELDS = ['id', 'name', 'age', 'tasks', 'rewards', 'points', 'image_id'] as const
|
|
|
|
export interface Reward {
|
|
id: string
|
|
name: string
|
|
cost: number
|
|
points_needed: number
|
|
image_id: string | null
|
|
image_url?: string | null // optional, for resolved URLs
|
|
}
|
|
export const REWARD_FIELDS = ['id', 'name', 'cost', 'points_needed', 'image_id'] as const
|
|
|
|
export interface RewardStatus {
|
|
id: string
|
|
name: string
|
|
points_needed: number
|
|
cost: number
|
|
redeeming: boolean
|
|
image_id: string | null
|
|
image_url?: string | null // optional, for resolved URLs
|
|
}
|
|
export const REWARD_STATUS_FIELDS = [
|
|
'id',
|
|
'name',
|
|
'points_needed',
|
|
'cost',
|
|
'redeeming',
|
|
'image_id',
|
|
] as const
|
|
|
|
export interface PendingReward {
|
|
id: string
|
|
child_id: string
|
|
child_name: string
|
|
child_image_id: string | null
|
|
child_image_url?: string | null // optional, for resolved URLs
|
|
reward_id: string
|
|
reward_name: string
|
|
reward_image_id: string | null
|
|
reward_image_url?: string | null // optional, for resolved URLs
|
|
}
|
|
export const PENDING_REWARD_FIELDS = [
|
|
'id',
|
|
'child_id',
|
|
'child_name',
|
|
'child_image_id',
|
|
'reward_id',
|
|
'reward_name',
|
|
'reward_image_id',
|
|
] as const
|
|
|
|
export interface Event {
|
|
type: string
|
|
payload:
|
|
| ChildModifiedEventPayload
|
|
| ChildTaskTriggeredEventPayload
|
|
| ChildRewardTriggeredEventPayload
|
|
| ChildRewardRequestEventPayload
|
|
| ChildTasksSetEventPayload
|
|
| ChildRewardsSetEventPayload
|
|
| TaskModifiedEventPayload
|
|
| RewardModifiedEventPayload
|
|
| TrackingEventCreatedPayload
|
|
| ChildOverrideSetPayload
|
|
| ChildOverrideDeletedPayload
|
|
}
|
|
|
|
export interface ChildModifiedEventPayload {
|
|
child_id: string
|
|
operation: 'ADD' | 'DELETE' | 'EDIT'
|
|
}
|
|
|
|
export interface ChildTaskTriggeredEventPayload {
|
|
task_id: string
|
|
child_id: string
|
|
points: number
|
|
}
|
|
|
|
export interface ChildRewardTriggeredEventPayload {
|
|
task_id: string
|
|
child_id: string
|
|
points: number
|
|
}
|
|
|
|
export interface ChildRewardRequestEventPayload {
|
|
child_id: string
|
|
reward_id: string
|
|
operation: 'GRANTED' | 'CREATED' | 'CANCELLED'
|
|
}
|
|
|
|
export interface ChildTasksSetEventPayload {
|
|
child_id: string
|
|
task_ids: string[]
|
|
}
|
|
|
|
export interface ChildRewardsSetEventPayload {
|
|
child_id: string
|
|
reward_ids: string[]
|
|
}
|
|
export interface TaskModifiedEventPayload {
|
|
task_id: string
|
|
operation: 'ADD' | 'DELETE' | 'EDIT'
|
|
}
|
|
export interface RewardModifiedEventPayload {
|
|
reward_id: string
|
|
operation: 'ADD' | 'DELETE' | 'EDIT'
|
|
}
|
|
|
|
export interface TrackingEventCreatedPayload {
|
|
tracking_event_id: string
|
|
child_id: string
|
|
entity_type: EntityType
|
|
action: ActionType
|
|
}
|
|
|
|
export interface ChildOverrideSetPayload {
|
|
override: ChildOverride
|
|
}
|
|
|
|
export interface ChildOverrideDeletedPayload {
|
|
child_id: string
|
|
entity_id: string
|
|
entity_type: string
|
|
}
|
|
|
|
export type EntityType = 'task' | 'reward' | 'penalty'
|
|
export type ActionType = 'activated' | 'requested' | 'redeemed' | 'cancelled'
|
|
|
|
export interface TrackingEvent {
|
|
id: string
|
|
user_id: string | null
|
|
child_id: string
|
|
entity_type: EntityType
|
|
entity_id: string
|
|
action: ActionType
|
|
points_before: number
|
|
points_after: number
|
|
delta: number
|
|
occurred_at: string
|
|
created_at: number
|
|
updated_at: number
|
|
metadata?: Record<string, any> | null
|
|
}
|
|
|
|
export const TRACKING_EVENT_FIELDS = [
|
|
'id',
|
|
'user_id',
|
|
'child_id',
|
|
'entity_type',
|
|
'entity_id',
|
|
'action',
|
|
'points_before',
|
|
'points_after',
|
|
'delta',
|
|
'occurred_at',
|
|
'created_at',
|
|
'updated_at',
|
|
'metadata',
|
|
] as const
|
|
|
|
export type OverrideEntityType = 'task' | 'reward'
|
|
|
|
export interface ChildOverride {
|
|
id: string
|
|
child_id: string
|
|
entity_id: string
|
|
entity_type: OverrideEntityType
|
|
custom_value: number
|
|
created_at: number
|
|
updated_at: number
|
|
}
|
|
|
|
export const CHILD_OVERRIDE_FIELDS = [
|
|
'id',
|
|
'child_id',
|
|
'entity_id',
|
|
'entity_type',
|
|
'custom_value',
|
|
'created_at',
|
|
'updated_at',
|
|
] as const
|