diff --git a/src/App.jsx b/src/App.jsx index c1a854c..2b9beb5 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -14,6 +14,7 @@ import FileDragDrop from './component/File-drag-drop'; import HistoryModal from './component/modals/History'; import LocalFileBrowser from './component/fileBrowser'; import FileEditModal from './component/modals/FileEdit'; +import ContributeDetails from './component/modals/ContributeDetails'; const app = () => { const [superState, dispatcher] = useReducer(reducer, initialState); @@ -33,6 +34,7 @@ const app = () => { + dispatcher({ type: T.Model_Close })} @@ -49,7 +51,7 @@ const app = () => { - + ); }; diff --git a/src/component/modals/ContributeDetails.jsx b/src/component/modals/ContributeDetails.jsx new file mode 100644 index 0000000..a4b3169 --- /dev/null +++ b/src/component/modals/ContributeDetails.jsx @@ -0,0 +1,105 @@ +import React, { useState } from 'react'; +import { toast } from 'react-toastify'; +import axios from 'axios'; +import Modal from './ParentModal'; +import { actionType as T } from '../../reducer'; +import './contributeDetails.css'; + +const ContributeDetails = ({ superState, dispatcher }) => { + const closeModal = () => { + dispatcher({ type: T.SET_CONTRIBUTE_MODAL, payload: false }); + }; + const [study, setStudy] = useState(''); + const [path, setPath] = useState(''); + const [auth, setAuth] = useState(''); + const [title, setTitle] = useState(''); + const [desc, setDesc] = useState(''); + const [branch, setBranch] = useState(''); + const [showAdvanceOptions, setShowAdvanceOptions] = useState(false); + const submit = async (e) => { + if (study === '' || path === '' || auth === '') { + toast.info('Please Provide necessary inputs'); + return; + } + const id = toast.loading('Processing your Request.Please wait...'); + try { + e.preventDefault(); + const result = await axios.post('http://127.0.0.1:5000/contribute', { + study, + auth, + desc, + title, + path, + branch, + }); + toast.success(result.data?.message); + } catch (error) { + if (error?.response?.status === 400) { + toast.info(error?.response?.data?.message); + } else { + toast.error(error?.response.data.message); + } + } + toast.dismiss(id); + closeModal(); + }; + const toggleOptions = () => { + setShowAdvanceOptions(!showAdvanceOptions); + }; + return ( + +
+ Study Name + setStudy(e.target.value)} + /> + Study Path + setPath(e.target.value)} + required + /> + Author Name + setAuth(e.target.value)} + required + /> + {showAdvanceOptions && ( + <> + Branch Name + setBranch(e.target.value)} + /> + Title of Study + setTitle(e.target.value)} + /> + Description of Study +