useAutomation hook automates modal closing and toast notifications based on form response data.ts
import { useAutomation } from "@arkyn/components/useAutomation";
bash
bun add react-scroll
formResponseData (required)anyvoidtsx
import { useAutomation } from "@arkyn/components/useAutomation";function SubmitFeedback({ responseData }: { responseData: any }) {useAutomation(responseData);return null;}// Example response dataconst responseData = {closeModal: true,message: "Operation completed successfully!",name: "Success",};
closeModal is truthy, the hook calls closeAll() from useModal().message is present, it decides toast style by matching name against badResponses and successResponses.cause.data.scrollTo is set, the hook smooth-scrolls to the named element using react-scroll.cause.fieldErrors is present, the first field error takes priority and is shown in the toast instead of message.useModal and useToast.