Skip to content

Commit

Permalink
fix: form needs action to explicitly return void
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanHjelsethStorstad committed Oct 23, 2024
1 parent 4ee9acb commit da54e09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/app/_components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,24 @@ export default function Form<GiveActionReturn, DataGuarantee extends boolean>({
PopUpCtx?.remove(closePopUpOnSuccess)
}, 2000)
}
return setTimeout(() => {
setTimeout(() => {
setSuccess(false)
if (refreshOnSuccess) refresh()
if (navigateOnSuccess) {
push(typeof navigateOnSuccess === 'string' ? navigateOnSuccess : navigateOnSuccess(res.data))
}
}, SUCCESS_FEEDBACK_TIME)
return
}
//No error provided
if (!res.error) {
return setGeneralErrors([
setGeneralErrors([
{
path: [],
message: 'error with input'
}
])
return
}

//sort errors
Expand All @@ -129,7 +131,8 @@ export default function Form<GiveActionReturn, DataGuarantee extends boolean>({
if (inputWithError) return inputWithError.errors.push(error)
return setGeneralErrors((prev) => (prev ? [...prev, error] : [error]))
})
return setInputs(inputs_)
setInputs(inputs_)
return
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/app/admin/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type PropTypes = {
*/
export default function BackButton({ className }: PropTypes) {
const pathname = usePathname()
const href = `/${pathname?.split('/').slice(1, -1).join('/')}` ?? '/admin'
const href = `/${pathname?.split('/').slice(1, -1).join('/')}`

return (
<Link className={`${styles.BackButton} ${className}`} href={href}>
Expand Down

0 comments on commit da54e09

Please sign in to comment.