Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 1x 1x 1x 1x 1x 1x 5x 5x 2x 2x 2x 2x 2x 2x 5x 2x 2x 2x 5x 5x 5x 5x 5x 5x 2x 2x 5x 5x 5x 5x 5x 5x | import BasicLayout from "main/layouts/BasicLayout/BasicLayout"; import RoleEmailForm from "main/components/Users/RoleEmailForm"; import { useNavigate } from "react-router"; import { useBackendMutation } from "main/utils/useBackend"; import { toast } from "react-toastify"; export default function InstructorsCreatePage({ storybook = false }) { const navigation = useNavigate(); const objectToAxiosParams = (instructor) => ({ url: "/api/admin/instructors/post", method: "POST", params: { email: instructor.email, }, }); const onSuccess = (instructor) => { toast(`New instructor added - email: ${instructor.email}`); if (!storybook) navigation("/admin/instructors"); }; const mutation = useBackendMutation( objectToAxiosParams, { onSuccess }, // Stryker disable next-line all : hard to set up test for caching ["/api/admin/instructors/all"], // mutation makes this key stale so that pages relying on it reload ); const onSubmit = async (data) => { mutation.mutate(data); }; return ( <BasicLayout> <div className="pt-2"> <h1>Add New Instructor</h1> <RoleEmailForm submitAction={onSubmit} /> </div> </BasicLayout> ); } |