@@ -25,6 +25,8 @@ const messages = i18n("entityForm", {
25
25
actionAddLanguage : "Add language" ,
26
26
actionAddRecurringRule : "Add recurring rule" ,
27
27
actionDelete : "Delete" ,
28
+ actionAdd : "Add" ,
29
+ actionUpdate : "Update" ,
28
30
labelCarer : "Carer" ,
29
31
labelLanguage : "Language" ,
30
32
labelRecurringRulePrefix : "Recurs every" ,
@@ -41,13 +43,13 @@ type EntityFormProps = {
41
43
carers : components [ "schemas" ] [ "CarerResponseDto" ] [ ] ;
42
44
languages : components [ "schemas" ] [ "LanguageResponseDto" ] [ ] ;
43
45
templates : components [ "schemas" ] [ "EntryTemplateDto" ] [ ] ;
44
- actionLabel : string ;
45
46
onSave : ( entity : EntryFormValues ) => void ;
46
47
entry : Partial < EntryFormValues > ;
48
+ mode : "create" | "update" ;
47
49
onDelete ?: ( ) => void ;
48
50
} ;
49
51
50
- export function EntityForm ( { onSave, onDelete, onAddCarer, onAddLanguage, actionLabel , entry, carers, languages, templates } : EntityFormProps ) {
52
+ export function EntityForm ( { onSave, onDelete, onAddCarer, onAddLanguage, entry, carers, languages, templates, mode } : EntityFormProps ) {
51
53
const isUpdateForm = ! ! onDelete ;
52
54
53
55
const t = useStore ( messages ) ;
@@ -56,7 +58,7 @@ export function EntityForm({ onSave, onDelete, onAddCarer, onAddLanguage, action
56
58
startedAt : "" ,
57
59
endedAt : "" ,
58
60
carer : - 1 ,
59
- weekday : isUpdateForm ? 0 : [ ] ,
61
+ weekday : mode === "update" ? 0 : [ ] ,
60
62
entryLanguages : [ { ratio : 100 } ] ,
61
63
} ,
62
64
validate : {
@@ -197,7 +199,7 @@ export function EntityForm({ onSave, onDelete, onAddCarer, onAddLanguage, action
197
199
{ t . actionDelete }
198
200
</ Button >
199
201
) }
200
- < Button type = "submit" > { actionLabel } </ Button >
202
+ < Button type = "submit" > { mode === "update" ? t . actionUpdate : t . actionAdd } </ Button >
201
203
</ Group >
202
204
</ Stack >
203
205
</ form >
0 commit comments