diff --git a/apps/scandic-web/components/Forms/Signup/index.tsx b/apps/scandic-web/components/Forms/Signup/index.tsx index 5828b1178..bd5ede0bc 100644 --- a/apps/scandic-web/components/Forms/Signup/index.tsx +++ b/apps/scandic-web/components/Forms/Signup/index.tsx @@ -51,6 +51,15 @@ export default function SignupForm({ title }: SignUpFormProps) { } }, onError: (error) => { + if (error.data?.code === "CONFLICT") { + toast.error( + intl.formatMessage({ + id: "An account with this email already exists. Please try signing in instead.", + }) + ) + return + } + toast.error(intl.formatMessage({ id: "Something went wrong!" })) console.error("Component Signup error:", error) }, diff --git a/apps/scandic-web/i18n/dictionaries/da.json b/apps/scandic-web/i18n/dictionaries/da.json index 8840a2bc8..402e30b4a 100644 --- a/apps/scandic-web/i18n/dictionaries/da.json +++ b/apps/scandic-web/i18n/dictionaries/da.json @@ -42,6 +42,7 @@ "Always open": "Altid åben", "Amenities": "Faciliteter", "Amusement park": "Forlystelsespark", + "An account with this email already exists. Please try signing in instead.": "En konto med denne e-mailadresse findes allerede. Log venligst ind i stedet.", "An error occurred trying to manage your preferences, please try again later.": "Der opstod en fejl under forsøget på at administrere dine præferencer. Prøv venligst igen senere.", "An error occurred when adding a credit card, please try again later.": "Der opstod en fejl under tilføjelse af et kreditkort. Prøv venligst igen senere.", "An error occurred when trying to update profile.": "Der opstod en fejl under forsøg på at opdatere profilen.", diff --git a/apps/scandic-web/i18n/dictionaries/de.json b/apps/scandic-web/i18n/dictionaries/de.json index 88c6ebc3d..86151b1af 100644 --- a/apps/scandic-web/i18n/dictionaries/de.json +++ b/apps/scandic-web/i18n/dictionaries/de.json @@ -42,6 +42,7 @@ "Always open": "Immer geöffnet", "Amenities": "Annehmlichkeiten", "Amusement park": "Vergnügungspark", + "An account with this email already exists. Please try signing in instead.": "Ein Konto mit dieser E-Mail-Adresse existiert bereits. Bitte melden Sie sich stattdessen an.", "An error occurred trying to manage your preferences, please try again later.": "Beim Versuch, Ihre Einstellungen zu verwalten, ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut.", "An error occurred when adding a credit card, please try again later.": "Beim Hinzufügen einer Kreditkarte ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut.", "An error occurred when trying to update profile.": "Beim Versuch, das Profil zu aktualisieren, ist ein Fehler aufgetreten.", diff --git a/apps/scandic-web/i18n/dictionaries/en.json b/apps/scandic-web/i18n/dictionaries/en.json index 66b23086a..2d9fa9e3e 100644 --- a/apps/scandic-web/i18n/dictionaries/en.json +++ b/apps/scandic-web/i18n/dictionaries/en.json @@ -43,6 +43,7 @@ "Always open": "Always open", "Amenities": "Amenities", "Amusement park": "Amusement park", + "An account with this email already exists. Please try signing in instead.": "An account with this email already exists. Please try signing in instead.", "An error occurred trying to manage your preferences, please try again later.": "An error occurred trying to manage your preferences, please try again later.", "An error occurred when adding a credit card, please try again later.": "An error occurred when adding a credit card, please try again later.", "An error occurred when trying to update profile.": "An error occurred when trying to update profile.", diff --git a/apps/scandic-web/i18n/dictionaries/fi.json b/apps/scandic-web/i18n/dictionaries/fi.json index 443d3ac8c..f61601d72 100644 --- a/apps/scandic-web/i18n/dictionaries/fi.json +++ b/apps/scandic-web/i18n/dictionaries/fi.json @@ -42,6 +42,7 @@ "Always open": "Aina auki", "Amenities": "Mukavuudet", "Amusement park": "Huvipuisto", + "An account with this email already exists. Please try signing in instead.": "Tällä sähköpostiosoitteella on jo olemassa tili. Ole hyvä ja kirjaudu sisään.", "An error occurred trying to manage your preferences, please try again later.": "Asetusten hallinnassa tapahtui virhe. Yritä myöhemmin uudelleen.", "An error occurred when adding a credit card, please try again later.": "Luottokorttia lisättäessä tapahtui virhe. Yritä myöhemmin uudelleen.", "An error occurred when trying to update profile.": "Profiilia päivitettäessä tapahtui virhe.", diff --git a/apps/scandic-web/i18n/dictionaries/no.json b/apps/scandic-web/i18n/dictionaries/no.json index 939e65324..1dfa7c4e4 100644 --- a/apps/scandic-web/i18n/dictionaries/no.json +++ b/apps/scandic-web/i18n/dictionaries/no.json @@ -42,6 +42,7 @@ "Always open": "Alltid åpen", "Amenities": "Fasiliteter", "Amusement park": "Tivoli", + "An account with this email already exists. Please try signing in instead.": "En konto med denne e-postadressen eksisterer allerede. Vennligst logg inn i stedet.", "An error occurred trying to manage your preferences, please try again later.": "Det oppstod en feil under forsøket på å administrere innstillingene dine. Prøv igjen senere.", "An error occurred when adding a credit card, please try again later.": "Det oppstod en feil ved å legge til et kredittkort. Prøv igjen senere.", "An error occurred when trying to update profile.": "Det oppstod en feil under forsøk på å oppdatere profilen.", diff --git a/apps/scandic-web/i18n/dictionaries/sv.json b/apps/scandic-web/i18n/dictionaries/sv.json index feaf61c9e..2bb807d54 100644 --- a/apps/scandic-web/i18n/dictionaries/sv.json +++ b/apps/scandic-web/i18n/dictionaries/sv.json @@ -42,6 +42,7 @@ "Always open": "Alltid öppet", "Amenities": "Bekvämligheter", "Amusement park": "Nöjespark", + "An account with this email already exists. Please try signing in instead.": "Ett konto med denna e-postadress finns redan. Vänligen logga in istället.", "An error occurred trying to manage your preferences, please try again later.": "Ett fel uppstod när du försökte hantera dina inställningar, försök igen senare.", "An error occurred when adding a credit card, please try again later.": "Ett fel uppstod när ett kreditkort lades till, försök igen senare.", "An error occurred when trying to update profile.": "Ett fel uppstod när du försökte uppdatera profilen.", diff --git a/apps/scandic-web/server/errors/trpc.ts b/apps/scandic-web/server/errors/trpc.ts index eda2ff86f..06f2d2241 100644 --- a/apps/scandic-web/server/errors/trpc.ts +++ b/apps/scandic-web/server/errors/trpc.ts @@ -16,6 +16,14 @@ export function forbiddenError(cause?: unknown) { }) } +export function conflictError(cause?: unknown) { + return new TRPCError({ + code: "CONFLICT", + message: `Conflict`, + cause, + }) +} + export function badRequestError(cause?: unknown) { return new TRPCError({ code: "BAD_REQUEST", @@ -41,7 +49,7 @@ export function internalServerError(cause?: unknown) { } export const SESSION_EXPIRED = "SESSION_EXPIRED" -export class SessionExpiredError extends Error { } +export class SessionExpiredError extends Error {} export function sessionExpiredError() { return new TRPCError({ code: "UNAUTHORIZED", @@ -51,7 +59,7 @@ export function sessionExpiredError() { } export const PUBLIC_UNAUTHORIZED = "PUBLIC_UNAUTHORIZED" -export class PublicUnauthorizedError extends Error { } +export class PublicUnauthorizedError extends Error {} export function publicUnauthorizedError() { return new TRPCError({ code: "UNAUTHORIZED", @@ -68,6 +76,8 @@ export function serverErrorByStatus(status: number, cause?: unknown) { return forbiddenError(cause) case 404: return notFound(cause) + case 409: + return conflictError(cause) case 500: default: return internalServerError(cause)