From 7239f0e33645361bcb2bc44495579536a681c8ce Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Fri, 1 Oct 2021 11:07:48 -0600 Subject: [PATCH] ui(admin): add egg variable elements --- .../components/admin/nests/eggs/EggRouter.tsx | 2 +- .../nests/eggs/EggVariablesContainer.tsx | 95 ++++++++++++++++++- .../scripts/components/elements/Checkbox.tsx | 43 ++++----- .../scripts/components/elements/Field.tsx | 42 ++++++-- .../scripts/components/elements/Label.tsx | 5 +- .../components/server/users/PermissionRow.tsx | 42 +++++++- 6 files changed, 185 insertions(+), 44 deletions(-) diff --git a/resources/scripts/components/admin/nests/eggs/EggRouter.tsx b/resources/scripts/components/admin/nests/eggs/EggRouter.tsx index 8ac6f15de..1d591869e 100644 --- a/resources/scripts/components/admin/nests/eggs/EggRouter.tsx +++ b/resources/scripts/components/admin/nests/eggs/EggRouter.tsx @@ -39,7 +39,7 @@ const EggRouter = () => { useEffect(() => { clearFlashes('egg'); - getEgg(Number(match.params?.id)) + getEgg(Number(match.params?.id), [ 'variables' ]) .then(egg => setEgg(egg)) .catch(error => { console.error(error); diff --git a/resources/scripts/components/admin/nests/eggs/EggVariablesContainer.tsx b/resources/scripts/components/admin/nests/eggs/EggVariablesContainer.tsx index 76a88ed33..41388a07e 100644 --- a/resources/scripts/components/admin/nests/eggs/EggVariablesContainer.tsx +++ b/resources/scripts/components/admin/nests/eggs/EggVariablesContainer.tsx @@ -1,11 +1,96 @@ +import { Form, Formik, useFormikContext } from 'formik'; import React from 'react'; +import tw from 'twin.macro'; +import { object } from 'yup'; +import { Egg, EggVariable } from '@/api/admin/eggs/getEgg'; import AdminBox from '@/components/admin/AdminBox'; -import { Egg } from '@/api/admin/eggs/getEgg'; +import Checkbox from '@/components/elements/Checkbox'; +import Field, { FieldRow, TextareaField } from '@/components/elements/Field'; +import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; + +function EggVariableForm ({ variable: { name } }: { variable: EggVariable }) { + const { isSubmitting } = useFormikContext(); -export default ({ egg }: { egg: Egg }) => { return ( - - {egg.name} + {name}