Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CreateApi.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { ErrorMessage, Field, Form, Formik } from "formik";
  2. import * as Yup from "yup";
  3. const initialValues = {
  4. generateKey: "",
  5. confirmKey: "",
  6. };
  7. const CreateApiSchema = Yup.object().shape({
  8. generateKey: Yup.string().required("Generate Key is required"),
  9. confirmKey: Yup.string().required("Confirm Key required"),
  10. });
  11. function CreateApi() {
  12. return (
  13. <>
  14. <Formik
  15. initialValues={initialValues}
  16. validationSchema={CreateApiSchema}
  17. onSubmit={(fields) => {
  18. alert(
  19. "SUCCESS!! :-)\n\n" + JSON.stringify(fields, null, 4)
  20. );
  21. }}
  22. >
  23. {({ errors, status, touched }) => (
  24. <Form>
  25. <div className="row">
  26. <div className="col-xxl-6 col-xl-6 col-lg-6 mb-3">
  27. <label className="form-label">
  28. Generate New Key
  29. </label>
  30. <Field
  31. name="generateKey"
  32. type="text"
  33. className={
  34. "form-control" +
  35. (errors.generateKey &&
  36. touched.generateKey
  37. ? " is-invalid"
  38. : "")
  39. }
  40. />
  41. <ErrorMessage
  42. name="generateKey"
  43. component="div"
  44. className="invalid-feedback"
  45. />
  46. </div>
  47. <div className="col-xxl-6 col-xl-6 col-lg-6 mb-3">
  48. <label className="form-label">
  49. Confirm Passphrase
  50. </label>
  51. <Field
  52. name="confirmKey"
  53. type="text"
  54. className={
  55. "form-control" +
  56. (errors.confirmKey &&
  57. touched.confirmKey
  58. ? " is-invalid"
  59. : "")
  60. }
  61. />
  62. <ErrorMessage
  63. name="confirmKey"
  64. component="div"
  65. className="invalid-feedback"
  66. />
  67. </div>
  68. </div>
  69. <div className="mt-3">
  70. <button
  71. type="submit"
  72. className="btn btn-primary mr-2"
  73. >
  74. Save
  75. </button>
  76. </div>
  77. </Form>
  78. )}
  79. </Formik>
  80. </>
  81. );
  82. }
  83. export default CreateApi;