MCPcopy
hub / github.com/NginxProxyManager/nginx-proxy-manager / onSubmit

Function onSubmit

frontend/src/modals/AccessListModal.tsx:43–83  ·  view source on GitHub ↗
(values: any, { setSubmitting }: any)

Source from the content-addressed store, hash-verified

41 };
42
43 const onSubmit = async (values: any, { setSubmitting }: any) => {
44 if (isSubmitting) return;
45
46 const vErr = validate(values);
47 if (vErr) {
48 setErrorMsg(vErr);
49 return;
50 }
51
52 setIsSubmitting(true);
53 setErrorMsg(null);
54
55 const { ...payload } = {
56 id: id === "new" ? undefined : id,
57 ...values,
58 };
59
60 // Filter out "items" to only use the "username" and "password" fields
61 payload.items = (values.items || []).map((i: AccessListItem) => ({
62 username: i.username,
63 password: i.password,
64 }));
65
66 // Filter out "clients" to only use the "directive" and "address" fields
67 payload.clients = (values.clients || []).map((i: AccessListClient) => ({
68 directive: i.directive,
69 address: i.address,
70 }));
71
72 setAccessList(payload, {
73 onError: (err: any) => setErrorMsg(<T id={err.message} />),
74 onSuccess: () => {
75 showObjectSuccess("access-list", "saved");
76 remove();
77 },
78 onSettled: () => {
79 setIsSubmitting(false);
80 setSubmitting(false);
81 },
82 });
83 };
84
85 const toggleClasses = "form-check-input";
86 const toggleEnabled = cn(toggleClasses, "bg-cyan");

Callers

nothing calls this directly

Calls 2

showObjectSuccessFunction · 0.90
validateFunction · 0.85

Tested by

no test coverage detected