-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from data-students/ExistingApunts
add: existing apunts toast
- Loading branch information
Showing
2 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,12 +69,24 @@ export function ProfileForm({ | |
const { data } = await axios.post("/api/subject/post/create", payload) | ||
return data | ||
}, | ||
onError: () => { | ||
toast({ | ||
title: "Alguna cosa no ha anat bé", | ||
description: "No s'ha pogut crear el post. Torna-ho a provar més tard.", | ||
variant: "destructive", | ||
}) | ||
onError: (error) => { | ||
if ((error as any).response && (error as any).response.status === 406) { | ||
return toast({ | ||
title: "Ja tens un post amb aquest títol per aquesta assignatura", | ||
description: | ||
"Si creus que això és un error, contacta amb nosaltres a [email protected]", | ||
}) | ||
} else { | ||
const Errmessage = (error as Error).message | ||
? (error as Error).message | ||
: "No s'ha pogut crear el post." | ||
toast({ | ||
title: Errmessage, | ||
description: | ||
"Alguna cosa ha anat malament, si creus que no hauria d'haver-hi cap problema, contacta amb nosaltres a [email protected]", | ||
variant: "destructive", | ||
}) | ||
} | ||
}, | ||
onSuccess: (subjectAcronym) => { | ||
router.push(`/${subjectAcronym}`) | ||
|