1
- import { Button , Group , Stack , notifications , useForm } from "@quassel/ui" ;
1
+ import { Button , Group , Modal , Stack , notifications , useDisclosure , useForm } from "@quassel/ui" ;
2
2
import { createFileRoute , Link , useNavigate } from "@tanstack/react-router" ;
3
3
import { i18n } from "../../../../../stores/i18n" ;
4
4
import { useStore } from "@nanostores/react" ;
@@ -16,6 +16,9 @@ const messages = i18n("questionnaireEntries", {
16
16
addEntityLabel : "Add" ,
17
17
notificationSuccessCreateLanguage : "Successfully add a new language." ,
18
18
notificationSuccessCreateCarer : "Successfully add a new carer." ,
19
+ gapsDialogTitle : "Gaps detected in the calendar" ,
20
+ gapsDialogContinueAnyway : "Continue anyway" ,
21
+ gapsDialogHighlightGaps : "Highlight gaps" ,
19
22
} ) ;
20
23
21
24
function QuestionnaireEntries ( ) {
@@ -80,6 +83,8 @@ function QuestionnaireEntries() {
80
83
} ;
81
84
82
85
const [ gaps , setGaps ] = useState < GapsPerDay > ( ) ;
86
+ const [ highlightGaps , setHighlightGaps ] = useState ( false ) ;
87
+ const [ gapsDialogOpened , { open, close } ] = useDisclosure ( ) ;
83
88
84
89
const f = useForm < { entries : components [ "schemas" ] [ "QuestionnaireEntryDto" ] [ ] } > ( {
85
90
initialValues : {
@@ -90,7 +95,10 @@ function QuestionnaireEntries() {
90
95
const gaps = resolveGaps ( value ) ;
91
96
setGaps ( gaps ) ;
92
97
93
- return gaps . some ( ( dailyGaps ) => dailyGaps . length ) ;
98
+ const hasGaps = gaps . some ( ( { length } ) => length ) ;
99
+ if ( hasGaps ) open ( ) ;
100
+
101
+ return hasGaps ;
94
102
} ,
95
103
} ,
96
104
} ) ;
@@ -107,9 +115,24 @@ function QuestionnaireEntries() {
107
115
< >
108
116
< form onSubmit = { f . onSubmit ( handleSubmit ) } >
109
117
< Stack >
118
+ < Modal opened = { gapsDialogOpened } onClose = { close } centered title = { t . gapsDialogTitle } >
119
+ < Group justify = "flex-end" >
120
+ < Button onClick = { handleSubmit } variant = "light" type = "submit" >
121
+ { t . gapsDialogContinueAnyway }
122
+ </ Button >
123
+ < Button
124
+ onClick = { ( ) => {
125
+ setHighlightGaps ( true ) ;
126
+ close ( ) ;
127
+ } }
128
+ >
129
+ { t . gapsDialogHighlightGaps }
130
+ </ Button >
131
+ </ Group >
132
+ </ Modal >
110
133
< EntryCalendar
111
134
entries = { questionnaire . entries ?? [ ] }
112
- gaps = { gaps }
135
+ gaps = { highlightGaps ? gaps : undefined }
113
136
onAddEntry = { handleCreate }
114
137
onUpdateEntry = { handleUpdate }
115
138
onDeleteEntry = { handleDelete }
0 commit comments