Been struggling with this one for the better part of a day, and I'm not finding much about it.
This is just a simple form component with some Laravel validation, and it just makes an API request and returns an error or success via a flash message. This is all documented in a fairly straightforward manner.
However, on either error or success, Inertia returns the Redirect in a modal, every time.
Code is below:
Form Component (React)
function handleSubmit(e) {
e.preventDefault()
setSending(true)
Inertia.post('/shop/quote-request', formValues, {
onFinish: setSending(false),
})
}
Controller
public function standardSubmit(Request $request): string
{
$form = $this->validate($request, [
'companyName' => 'required|max:50',
'name' => 'required|max:50',
'email' => 'required|email:rfc,dns',
'phoneNumber' => 'required'
]);
if (empty($request['comments'])) {
$comments = 'No Content';
} else ($comments = $request['comments']);
try {
Zendesk::tickets()->create([
'subject' => 'Subject',
'recipient' => '[email protected]',
'email_cc_ids' => '',
'tags' => 'mtsps-tag',
'requester' => [
'email' => $form['email'],
'name' => $form['name']
],
'comment' => [
'html_body' =>
"Company Size: " . $request['size']
. "</br></br>" . "Message: " . $comments
],
'group_id' => 'xxxxxxxxx',
'priority' => 'normal'
]);
} catch (Throwable $th) {
return Redirect::route('shop.quote_request')->with('error', 'Something went wrong, please try again.');
}
return Redirect::route('shop.quote_request')->with('success', 'Your message has been delivered, someone will be in touch soon.');
}
And the part I really don't understand: the text that renders in the modal before the component re-renders.
Really appreciate any help here, happy to answer any questions or give any further detail on this if I've left anything out.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…