(values: any)
| 25 | const [isSubmitting, setIsSubmitting] = useState(false); |
| 26 | |
| 27 | const validate = (values: any): string | null => { |
| 28 | // either Auths or Clients must be defined |
| 29 | if (values.items?.length === 0 && values.clients?.length === 0) { |
| 30 | return intl.formatMessage({ id: "error.access.at-least-one" }); |
| 31 | } |
| 32 | |
| 33 | // ensure the items don't contain the same username twice |
| 34 | const usernames = values.items.map((i: any) => i.username); |
| 35 | const uniqueUsernames = Array.from(new Set(usernames)); |
| 36 | if (usernames.length !== uniqueUsernames.length) { |
| 37 | return intl.formatMessage({ id: "error.access.duplicate-usernames" }); |
| 38 | } |
| 39 | |
| 40 | return null; |
| 41 | }; |
| 42 | |
| 43 | const onSubmit = async (values: any, { setSubmitting }: any) => { |
| 44 | if (isSubmitting) return; |
no outgoing calls
no test coverage detected