@@ -7,6 +7,7 @@ import { CheckboxGroup } from '@/components/ui/checkbox-group';
77import { COLORS , VALIDATION } from '@/constants/form' ;
88import baseAPIClient from '@/APIClients/baseAPIClient' ;
99import { IntakeExperience , IntakeTreatment } from '@/types/intakeTypes' ;
10+ import { detectCanadianTimezone } from '@/utils/timezoneUtils' ;
1011
1112// Reusable Select component to replace inline styling
1213type StyledSelectProps = React . SelectHTMLAttributes < HTMLSelectElement > & {
@@ -48,23 +49,25 @@ interface DemographicCancerFormData {
4849 ethnicGroup : string [ ] ;
4950 maritalStatus : string ;
5051 hasKids : string ;
52+ timezone : string ;
5153 diagnosis : string ;
5254 dateOfDiagnosis : string ;
5355 treatments : string [ ] ;
5456 experiences : string [ ] ;
5557}
5658
57- const DEFAULT_VALUES : DemographicCancerFormData = {
59+ const getDefaultValues = ( ) : DemographicCancerFormData => ( {
5860 genderIdentity : '' ,
5961 pronouns : [ ] ,
6062 ethnicGroup : [ ] ,
6163 maritalStatus : '' ,
6264 hasKids : '' ,
65+ timezone : detectCanadianTimezone ( ) ,
6366 diagnosis : '' ,
6467 dateOfDiagnosis : '' ,
6568 treatments : [ ] ,
6669 experiences : [ ] ,
67- } ;
70+ } ) ;
6871
6972const DIAGNOSIS_OPTIONS = [
7073 'Acute Myeloid Leukaemia' ,
@@ -106,6 +109,8 @@ const PRONOUNS_OPTIONS = [
106109 'Self-describe' ,
107110] ;
108111
112+ const TIMEZONE_OPTIONS = [ 'NST' , 'AST' , 'EST' , 'CST' , 'MST' , 'PST' ] ;
113+
109114const ETHNIC_OPTIONS = [
110115 'Indigenous' ,
111116 'Arab' ,
@@ -274,7 +279,7 @@ export function DemographicCancerForm({
274279 caringForSomeone,
275280} : DemographicCancerFormProps ) {
276281 const { control, handleSubmit, formState, watch } = useForm < DemographicCancerFormData > ( {
277- defaultValues : DEFAULT_VALUES ,
282+ defaultValues : getDefaultValues ( ) ,
278283 } ) ;
279284 const { errors, isSubmitting } = formState ;
280285
@@ -516,6 +521,29 @@ export function DemographicCancerForm({
516521 ) }
517522 </ HStack >
518523
524+ { /* Time Zone - Left aligned */ }
525+ < HStack gap = { 4 } w = "full" align = "start" >
526+ < Box w = "50%" >
527+ < FormField label = "Time Zone" error = { errors . timezone ?. message } >
528+ < Controller
529+ name = "timezone"
530+ control = { control }
531+ rules = { { required : 'Time zone is required' } }
532+ render = { ( { field } ) => (
533+ < StyledSelect { ...field } error = { ! ! errors . timezone } >
534+ < option value = "" > Time Zone</ option >
535+ { TIMEZONE_OPTIONS . map ( ( tz ) => (
536+ < option key = { tz } value = { tz } >
537+ { tz }
538+ </ option >
539+ ) ) }
540+ </ StyledSelect >
541+ ) }
542+ />
543+ </ FormField >
544+ </ Box >
545+ </ HStack >
546+
519547 { /* Ethnic or Cultural Group - Left aligned */ }
520548 < HStack gap = { 4 } w = "full" align = "start" >
521549 < Box w = "50%" >
@@ -803,15 +831,17 @@ interface BasicDemographicsFormData {
803831 ethnicGroup : string [ ] ;
804832 maritalStatus : string ;
805833 hasKids : string ;
834+ timezone : string ;
806835}
807836
808- const BASIC_DEFAULT_VALUES : BasicDemographicsFormData = {
837+ const getBasicDefaultValues = ( ) : BasicDemographicsFormData => ( {
809838 genderIdentity : '' ,
810839 pronouns : [ ] ,
811840 ethnicGroup : [ ] ,
812841 maritalStatus : '' ,
813842 hasKids : '' ,
814- } ;
843+ timezone : detectCanadianTimezone ( ) ,
844+ } ) ;
815845
816846interface BasicDemographicsFormProps {
817847 formType ?: 'participant' | 'volunteer' ;
@@ -825,7 +855,7 @@ export function BasicDemographicsForm({ formType, onNext }: BasicDemographicsFor
825855 formState : { errors, isSubmitting } ,
826856 watch,
827857 } = useForm < BasicDemographicsFormData > ( {
828- defaultValues : BASIC_DEFAULT_VALUES ,
858+ defaultValues : getBasicDefaultValues ( ) ,
829859 } ) ;
830860
831861 // Local state for custom values
@@ -1020,6 +1050,29 @@ export function BasicDemographicsForm({ formType, onNext }: BasicDemographicsFor
10201050 ) }
10211051 </ HStack >
10221052
1053+ { /* Time Zone - Left aligned */ }
1054+ < HStack gap = { 4 } w = "full" align = "start" >
1055+ < Box w = "50%" >
1056+ < FormField label = "Time Zone" error = { errors . timezone ?. message } >
1057+ < Controller
1058+ name = "timezone"
1059+ control = { control }
1060+ rules = { { required : 'Time zone is required' } }
1061+ render = { ( { field } ) => (
1062+ < StyledSelect { ...field } error = { ! ! errors . timezone } >
1063+ < option value = "" > Time Zone</ option >
1064+ { TIMEZONE_OPTIONS . map ( ( tz ) => (
1065+ < option key = { tz } value = { tz } >
1066+ { tz }
1067+ </ option >
1068+ ) ) }
1069+ </ StyledSelect >
1070+ ) }
1071+ />
1072+ </ FormField >
1073+ </ Box >
1074+ </ HStack >
1075+
10231076 { /* Ethnic or Cultural Group */ }
10241077 < HStack gap = { 4 } w = "full" align = "start" >
10251078 < Box w = "50%" >
0 commit comments