🛂 Migrate to Chakra UI v3 (#1496)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { ApiError } from "./client"
|
||||
import useCustomToast from "./hooks/useCustomToast"
|
||||
|
||||
export const emailPattern = {
|
||||
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
||||
@@ -43,11 +44,12 @@ export const confirmPasswordRules = (
|
||||
return rules
|
||||
}
|
||||
|
||||
export const handleError = (err: ApiError, showToast: any) => {
|
||||
export const handleError = (err: ApiError) => {
|
||||
const { showErrorToast } = useCustomToast()
|
||||
const errDetail = (err.body as any)?.detail
|
||||
let errorMessage = errDetail || "Something went wrong."
|
||||
if (Array.isArray(errDetail) && errDetail.length > 0) {
|
||||
errorMessage = errDetail[0].msg
|
||||
}
|
||||
showToast("Error", errorMessage, "error")
|
||||
showErrorToast(errorMessage)
|
||||
}
|
||||
|
Reference in New Issue
Block a user