@@ -95,7 +95,6 @@ export async function action({ request, params }: ActionFunctionArgs) {
95
95
export async function usertRecipientAction ( {
96
96
formData,
97
97
userId,
98
- request,
99
98
recipient,
100
99
} : Pick < RecipientActionArgs , 'formData' | 'request' | 'userId' > & {
101
100
recipient : RecipientActionArgs [ 'recipient' ] | null
@@ -128,7 +127,6 @@ export async function usertRecipientAction({
128
127
129
128
if ( recipientId ) {
130
129
invariantResponse ( recipient , 'Recipient not found' )
131
- const verified = phoneNumber === recipient ?. phoneNumber
132
130
const updatedRecipient = await prisma . recipient . update ( {
133
131
select : { id : true } ,
134
132
where : { id : recipientId } ,
@@ -143,14 +141,10 @@ export async function usertRecipientAction({
143
141
timeZone,
144
142
} ,
145
143
} )
146
- if ( verified ) {
147
- return redirect ( `/recipients/${ updatedRecipient . id } ` )
148
- } else {
149
- return sendVerificationAction ( { formData, userId, request, recipient } )
150
- }
144
+ return redirect ( `/recipients/${ updatedRecipient . id } ` )
151
145
} else {
152
- recipient = await prisma . recipient . create ( {
153
- select : { id : true , name : true , phoneNumber : true , verified : true } ,
146
+ const newRecipient = await prisma . recipient . create ( {
147
+ select : { id : true } ,
154
148
data : {
155
149
name,
156
150
phoneNumber,
@@ -161,7 +155,12 @@ export async function usertRecipientAction({
161
155
} ,
162
156
} )
163
157
164
- return sendVerificationAction ( { formData, userId, request, recipient } )
158
+ return redirectWithToast ( `/recipients/${ newRecipient . id } /edit` , {
159
+ type : 'success' ,
160
+ title : 'Recipient created' ,
161
+ description :
162
+ 'Your recipient has been created. You must verify them before sending messages.' ,
163
+ } )
165
164
}
166
165
}
167
166
0 commit comments