mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 15:48:23 -05:00
Simplify comments
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
import type { ActionFunction, ActionFunctionArgs } from "react-router";
|
||||
|
||||
/**
|
||||
* Wraps an existing action function for API use.
|
||||
* Converts redirect-based success/error responses to JSON responses.
|
||||
*
|
||||
* The existing actions use:
|
||||
* - `successToast(message)` which returns `redirect("?__success=message")`
|
||||
* - `errorToastIfFalsy/errorToastIfErr` which throw `redirect("?__error=message")`
|
||||
* - `{ fieldErrors }` returns for form validation failures
|
||||
* Wraps an action for API use, converting its redirect-based responses to JSON: `successToast`
|
||||
* returns `redirect("?__success=message")`, `errorToastIfFalsy/errorToastIfErr` throw
|
||||
* `redirect("?__error=message")`, and validation failures return `{ fieldErrors }`.
|
||||
*/
|
||||
export async function wrapActionForApi(
|
||||
actionFn: ActionFunction,
|
||||
|
||||
Reference in New Issue
Block a user