diff --git a/package-lock.json b/package-lock.json index 7c2f664..99943fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@testing-library/user-event": "^13.5.0", "axios": "^1.6.2", "formik": "^2.4.5", + "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^4.12.0", diff --git a/package.json b/package.json index 14607a7..1f87f93 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@testing-library/user-event": "^13.5.0", "axios": "^1.6.2", "formik": "^2.4.5", + "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^4.12.0", diff --git a/src/components/Button/FormSubmitButton.js b/src/components/Button/FormSubmitButton.js index bbf6f93..e72d934 100644 --- a/src/components/Button/FormSubmitButton.js +++ b/src/components/Button/FormSubmitButton.js @@ -1,11 +1,11 @@ import styled from '@emotion/styled'; -export const FormSubmitButton = styled.button` +const FormSubmitButton = styled.button` padding: 0.56rem 5.06rem; font-weight: 400; - color: #FFFFFF; + color: #000; margin-top: 10px; - border-radius: 0.25rem; + border-radius: 0.9rem; border: 1px solid transparent; font-size: 1.125rem; height: fit-content; @@ -47,3 +47,5 @@ export const FormSubmitButton = styled.button` width: fit-content; } `; + +export default FormSubmitButton; diff --git a/src/components/Button/TertiaryButton.js b/src/components/Button/TertiaryButton.js index a180670..ae978e3 100644 --- a/src/components/Button/TertiaryButton.js +++ b/src/components/Button/TertiaryButton.js @@ -1,9 +1,8 @@ +import PropTypes from 'prop-types'; import React from 'react'; import styled from '@emotion/styled'; -export const TertiaryButton = ({ children }) => { - return {children}; -}; +const TertiaryButton = ({ children }) => {children}; const StyledButton = styled.button` display: flex; @@ -14,3 +13,9 @@ const StyledButton = styled.button` background-color: transparent; cursor: pointer; `; + +TertiaryButton.propTypes = { + children: PropTypes.node.isRequired, +}; + +export default TertiaryButton; diff --git a/src/components/Form/FormComponent.js b/src/components/Form/FormComponent.js index f45664f..33a02f6 100644 --- a/src/components/Form/FormComponent.js +++ b/src/components/Form/FormComponent.js @@ -1,32 +1,48 @@ +import PropTypes from 'prop-types'; import { Form, Formik } from 'formik'; import styled from '@emotion/styled'; - -export const FormComponent = ({ +const FormComponent = ({ initialValues, schema, onSubmit, children, className, -}) => { - return ( - - - {children} - - - ); +}) => ( + + + {children} + + +); + +FormComponent.propTypes = { + initialValues: PropTypes.shape({ + userName: PropTypes.string.isRequired, + email: PropTypes.string.isRequired, + password: PropTypes.string.isRequired, + confirm_password: PropTypes.string.isRequired, + }).isRequired, + schema: PropTypes.shape({ + userName: PropTypes.string.isRequired, + email: PropTypes.string.isRequired, + password: PropTypes.string.isRequired, + confirm_password: PropTypes.string.isRequired, + }).isRequired, + onSubmit: PropTypes.func.isRequired, + children: PropTypes.node.isRequired, + className: PropTypes.string.isRequired, }; const StyledForm = styled(Form)` border: 1px solid orange; &.flex { - dispaly: flex; + display: flex; width: 60%; } @@ -35,7 +51,7 @@ const StyledForm = styled(Form)` } & > .margin { - gird-colum: span 2; + gird-column: span 2; margin-left: 15%; margin-right: 15%; } @@ -45,3 +61,5 @@ const StyledForm = styled(Form)` align-items: last baseline; } `; + +export default FormComponent; diff --git a/src/components/Form/FormField.js b/src/components/Form/FormField.js index 29b89eb..c60c714 100644 --- a/src/components/Form/FormField.js +++ b/src/components/Form/FormField.js @@ -1,9 +1,12 @@ -import { useField } from "formik"; -import React from 'react' +import { useField } from 'formik'; +import React from 'react'; +import PropTypes from 'prop-types'; -import styled from "@emotion/styled"; +import styled from '@emotion/styled'; -export const SelectField = ({label, lpiSrc, rpiSrc, className, name, id, ...props}) => { +export const SelectField = ({ + label, lpiSrc, rpiSrc, className, name, id, ...props +}) => { const [field, meta] = useField(name); return ( @@ -19,19 +22,30 @@ export const SelectField = ({label, lpiSrc, rpiSrc, className, name, id, ...prop {meta.error} ) : null} - ) -} + ); +}; -export const TextInputField = ({label, lpiSrc, rpiSrc, className, name, id, ...props}) => { +SelectField.propTypes = { + label: PropTypes.string.isRequired, + lpiSrc: PropTypes.string.isRequired, + rpiSrc: PropTypes.string.isRequired, + className: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + id: PropTypes.string.isRequired, +}; + +export const TextInputField = ({ + label, lpiSrc, rpiSrc, className, name, placeholder, id, ...props +}) => { const [field, meta] = useField(name); - return( + return ( {label} - + {lpiSrc ? : null} {lpiSrc ? : null} @@ -39,39 +53,58 @@ export const TextInputField = ({label, lpiSrc, rpiSrc, className, name, id, ...p {meta.error} ) : null} - ) -} + ); +}; + +TextInputField.propTypes = { + label: PropTypes.string.isRequired, + lpiSrc: PropTypes.string.isRequired, + rpiSrc: PropTypes.string.isRequired, + className: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + placeholder: PropTypes.string.isRequired, + id: PropTypes.string.isRequired, +}; export const TextAreaInputField = ({ - label, - lpiSrc, - rpiSrc, - className, - name, - id, - ...props - }) => { - const [field, meta] = useField(name); - - return ( - - {label} - -