Skip to content

Commit 4c4a8af

Browse files
committed
fix
1 parent 7d99948 commit 4c4a8af

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

src/components/form.jsx

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,51 +46,50 @@ function Form({ questions = [], role = "" }) {
4646

4747

4848
const handleSubmit = async (e) => {
49-
console.log("formData", formData);
50-
console.log("role", role);
51-
console.log("Is form valid?", validateForm());
52-
53-
5449
e.preventDefault();
5550
if (!validateForm()) {
56-
return;
57-
console.log("Is form valid?", validateForm());
51+
return;
52+
}
5853

59-
}
6054
try {
61-
const response = await fetch("/api/slack", {
62-
method: "POST",
55+
const response = await fetch('/api/slack', {
56+
method: 'POST',
6357
headers: {
64-
"Content-Type": "application/json",
58+
'Content-Type': 'application/json',
6559
},
6660
body: JSON.stringify({ formData, role }),
6761
});
6862

6963
if (response.ok) {
7064
toast({
71-
title: "Success",
72-
description: "Successfully sent message to Slack",
73-
status: "success",
65+
title: 'Success',
66+
description: 'Successfully sent your application for review.',
67+
status: 'success',
7468
duration: 5000,
7569
isClosable: true,
7670
});
7771
setFormData({});
7872
} else {
79-
const { error } = await response.json();
73+
let error;
74+
try {
75+
error = await response.json();
76+
} catch (e) {
77+
error = await response.text();
78+
}
8079
toast({
81-
title: "Error",
80+
title: 'Error',
8281
description: error,
83-
status: "error",
82+
status: 'error',
8483
duration: 5000,
8584
isClosable: true,
8685
});
8786
}
8887
} catch (error) {
89-
console.error("There was an error sending the form data to Slack", error);
88+
console.error('There was an error sending the form data to Slack', error);
9089
toast({
91-
title: "Error",
92-
description: "An error occurred while processing your request.",
93-
status: "error",
90+
title: 'Error',
91+
description: 'An error occurred while processing your request.',
92+
status: 'error',
9493
duration: 5000,
9594
isClosable: true,
9695
});

0 commit comments

Comments
 (0)