@@ -27,21 +27,27 @@ import {
27
27
TextAreaField ,
28
28
} from "@calcom/ui" ;
29
29
30
+ enum ReassignType {
31
+ ROUND_ROBIN = "round_robin" ,
32
+ TEAM_MEMBER = "team_member" ,
33
+ }
34
+
30
35
type ReassignDialog = {
31
36
isOpenDialog : boolean ;
32
37
setIsOpenDialog : Dispatch < SetStateAction < boolean > > ;
33
38
teamId : number ;
34
39
bookingId : number ;
40
+ bookingFromRoutingForm : boolean ;
35
41
} ;
36
42
37
43
type FormValues = {
38
- reassignType : "round_robin" | "team_member" ;
44
+ reassignType : ReassignType . ROUND_ROBIN | ReassignType . TEAM_MEMBER ;
39
45
teamMemberId ?: number ;
40
46
reassignReason ?: string ;
41
47
} ;
42
48
43
49
const formSchema = z . object ( {
44
- reassignType : z . enum ( [ "round_robin" , "team_member" ] ) ,
50
+ reassignType : z . nativeEnum ( ReassignType ) ,
45
51
teamMemberId : z . number ( ) . optional ( ) ,
46
52
reassignReason : z
47
53
. string ( )
@@ -57,7 +63,13 @@ interface TeamMemberOption {
57
63
status : string ;
58
64
}
59
65
60
- export const ReassignDialog = ( { isOpenDialog, setIsOpenDialog, teamId, bookingId } : ReassignDialog ) => {
66
+ export const ReassignDialog = ( {
67
+ isOpenDialog,
68
+ setIsOpenDialog,
69
+ teamId,
70
+ bookingId,
71
+ bookingFromRoutingForm,
72
+ } : ReassignDialog ) => {
61
73
const { t } = useLocale ( ) ;
62
74
const utils = trpc . useUtils ( ) ;
63
75
const [ animationParentRef ] = useAutoAnimate < HTMLFormElement > ( {
@@ -101,7 +113,7 @@ export const ReassignDialog = ({ isOpenDialog, setIsOpenDialog, teamId, bookingI
101
113
const form = useForm < FormValues > ( {
102
114
resolver : zodResolver ( formSchema ) ,
103
115
defaultValues : {
104
- reassignType : "round_robin" ,
116
+ reassignType : bookingFromRoutingForm ? ReassignType . TEAM_MEMBER : ReassignType . ROUND_ROBIN ,
105
117
} ,
106
118
} ) ;
107
119
@@ -144,7 +156,7 @@ export const ReassignDialog = ({ isOpenDialog, setIsOpenDialog, teamId, bookingI
144
156
} ) ;
145
157
146
158
const handleSubmit = ( values : FormValues ) => {
147
- if ( values . reassignType === "round_robin" ) {
159
+ if ( values . reassignType === ReassignType . ROUND_ROBIN ) {
148
160
roundRobinReassignMutation . mutate ( { teamId, bookingId } ) ;
149
161
} else {
150
162
if ( values . teamMemberId ) {
@@ -176,23 +188,30 @@ export const ReassignDialog = ({ isOpenDialog, setIsOpenDialog, teamId, bookingI
176
188
< Form form = { form } handleSubmit = { handleSubmit } ref = { animationParentRef } >
177
189
< RadioArea . Group
178
190
onValueChange = { ( val ) => {
179
- form . setValue ( "reassignType" , val as "team_member" | "round_robin" ) ;
191
+ form . setValue ( "reassignType" , val as ReasonEnum ) ;
180
192
} }
193
+ defaultValue = { bookingFromRoutingForm ? ReassignType . TEAM_MEMBER : ReassignType . ROUND_ROBIN }
181
194
className = "mt-1 flex flex-col gap-4" >
195
+ { ! bookingFromRoutingForm ? (
196
+ < RadioArea . Item
197
+ value = { ReassignType . ROUND_ROBIN }
198
+ className = "w-full text-sm"
199
+ classNames = { { container : "w-full" } }
200
+ disabled = { bookingFromRoutingForm } >
201
+ < strong className = "mb-1 block" > { t ( "round_robin" ) } </ strong >
202
+ < p > { t ( "round_robin_reassign_description" ) } </ p >
203
+ </ RadioArea . Item >
204
+ ) : null }
182
205
< RadioArea . Item
183
- value = "round_robin"
184
- className = "w-full text-sm"
206
+ value = { ReassignType . TEAM_MEMBER }
207
+ className = "text-sm"
185
208
classNames = { { container : "w-full" } } >
186
- < strong className = "mb-1 block" > { t ( "round_robin" ) } </ strong >
187
- < p > { t ( "round_robin_reassign_description" ) } </ p >
188
- </ RadioArea . Item >
189
- < RadioArea . Item value = "team_member" className = "text-sm" classNames = { { container : "w-full" } } >
190
209
< strong className = "mb-1 block" > { t ( "team_member_round_robin_reassign" ) } </ strong >
191
210
< p > { t ( "team_member_round_robin_reassign_description" ) } </ p >
192
211
</ RadioArea . Item >
193
212
</ RadioArea . Group >
194
213
195
- { watchedReassignType === "team_member" && (
214
+ { watchedReassignType === ReassignType . TEAM_MEMBER && (
196
215
< div className = "mb-2" >
197
216
< Label className = "text-emphasis mt-6" > { t ( "select_team_member" ) } </ Label >
198
217
< div className = "mt-2" >
0 commit comments