diff --git a/packages/design-system-component-library-yeahyeahyeah/components/form/InputForm.tsx b/packages/design-system-component-library-yeahyeahyeah/components/form/InputForm.tsx index 572edff..18dbab8 100644 --- a/packages/design-system-component-library-yeahyeahyeah/components/form/InputForm.tsx +++ b/packages/design-system-component-library-yeahyeahyeah/components/form/InputForm.tsx @@ -13,7 +13,8 @@ export interface IFormInputProps { errorMessage: string; autoComplete: 'off' | 'on'; inputValue: string; - setInputValue: React.Dispatch>; + setInputValue?: React.Dispatch>; + dispatch?: React.Dispatch; onPressEnter?: () => void; } @@ -29,6 +30,7 @@ export const InputForm: React.FC = ({ autoComplete, inputValue, setInputValue, + dispatch, onPressEnter, }) => { const [buttonType, setbuttonType] = useState(type); @@ -36,6 +38,7 @@ export const InputForm: React.FC = ({ const handleChange = (e: React.ChangeEvent) => { setInputValue && setInputValue(e.target.value); + dispatch && dispatch({ type: 'SET_INPUT_VALUE', payload: e.target.value }); }; const showPassword = () => { @@ -43,13 +46,15 @@ export const InputForm: React.FC = ({ }; const clearForm = () => { - setInputValue(''); + setInputValue && setInputValue(''); + dispatch && dispatch({ type: 'CLEAR_INPUT_VALUE' }); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.code === 'Enter' && e.shiftKey == false) { e.preventDefault(); - setInputValue(''); + setInputValue && setInputValue(''); + dispatch && dispatch({ type: 'CLEAR_INPUT_VALUE' }); onPressEnter && onPressEnter(); } }; diff --git a/packages/design-system-component-library-yeahyeahyeah/components/form/TextBox.tsx b/packages/design-system-component-library-yeahyeahyeah/components/form/TextBox.tsx index ea03c3e..57a301d 100644 --- a/packages/design-system-component-library-yeahyeahyeah/components/form/TextBox.tsx +++ b/packages/design-system-component-library-yeahyeahyeah/components/form/TextBox.tsx @@ -14,6 +14,7 @@ export interface ITextBoxProps { form: Pick; inputValue: string; setInputValue: React.Dispatch>; + dispatch?: React.Dispatch; variant: 'write' | 'inline' | 'start'; uploadCallback: () => void; sendCallback: () => void; @@ -41,6 +42,7 @@ export const TextBox: React.FC = ({ }, inputValue, setInputValue, + dispatch, uploadCallback = () => { return null; }, @@ -112,6 +114,7 @@ export const TextBox: React.FC = ({ autoComplete="off" inputValue={inputValue} setInputValue={setInputValue} + dispatch={dispatch} onPressEnter={onPressEnter} data-testid="testTextarea" /> diff --git a/packages/design-system-component-library-yeahyeahyeah/components/form/UploadForm.tsx b/packages/design-system-component-library-yeahyeahyeah/components/form/UploadForm.tsx index f2fea68..e5ac562 100644 --- a/packages/design-system-component-library-yeahyeahyeah/components/form/UploadForm.tsx +++ b/packages/design-system-component-library-yeahyeahyeah/components/form/UploadForm.tsx @@ -8,13 +8,25 @@ import { Modal } from '../modal'; export interface IUploadFormProps { onDropCallBack: (acceptedFiles: File[], fileRejections: FileRejection[]) => void; showModal: boolean; - setShowModal: React.Dispatch>; + setShowModal?: React.Dispatch>; + dispatch?: React.Dispatch; fileUploadError: string; } -export default function UploadForm({ onDropCallBack, showModal, setShowModal, fileUploadError }: IUploadFormProps) { +export default function UploadForm({ + onDropCallBack, + showModal, + setShowModal, + dispatch, + fileUploadError, +}: IUploadFormProps) { + const handleCloseModal = () => { + setShowModal && setShowModal(false); + dispatch && dispatch({ type: 'CLOSE_MODAL' }); + }; + return ( - setShowModal(false)}> +
console.log('Submit')} tw="container">