forked from KathiraveluLab/DHGWorkflow
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
164 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Modal | ||
ModelOpen={superState.contributeModal} | ||
title="Contribute" | ||
closeModal={closeModal} | ||
> | ||
<form className="contribute-details"> | ||
<span>Study Name</span> | ||
<input | ||
required | ||
value={study} | ||
onChange={(e) => setStudy(e.target.value)} | ||
/> | ||
<span>Study Path</span> | ||
<input | ||
placeholder="Enter Full Directory Path of Study" | ||
value={path} | ||
onChange={(e) => setPath(e.target.value)} | ||
required | ||
/> | ||
<span>Author Name</span> | ||
<input | ||
value={auth} | ||
onChange={(e) => setAuth(e.target.value)} | ||
required | ||
/> | ||
{showAdvanceOptions && ( | ||
<> | ||
<span>Branch Name</span> | ||
<input | ||
value={branch} | ||
onChange={(e) => setBranch(e.target.value)} | ||
/> | ||
<span>Title of Study</span> | ||
<input | ||
value={title} | ||
onChange={(e) => setTitle(e.target.value)} | ||
/> | ||
<span>Description of Study</span> | ||
<textarea | ||
value={desc} | ||
onChange={(e) => setDesc(e.target.value)} | ||
/> | ||
</> | ||
)} | ||
<button type="button" className="btn btn-secondary" onClick={toggleOptions}> | ||
{showAdvanceOptions ? 'Hide ' : 'Show '} | ||
Advance Options | ||
</button> | ||
<div className="expand"> | ||
<button type="submit" className="btn btn-primary" onClick={submit}>Generate PR</button> | ||
</div> | ||
</form> | ||
</Modal> | ||
); | ||
}; | ||
export default ContributeDetails; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.contribute-details{ | ||
padding: 20px; | ||
display: grid; | ||
grid-template-columns: auto auto; | ||
gap: 20px; | ||
} | ||
|
||
.contribute-details *{ | ||
padding: 10px 5px; | ||
text-align: center; | ||
} | ||
|
||
.contribute-details .expand{ | ||
grid-column: 1 / span 2; | ||
padding: 0; | ||
} | ||
|
||
.contribute-details .btn{ | ||
width: 100%; | ||
} | ||
.contribute-details .btn-secondary{ | ||
align-self: flex-end; | ||
} | ||
.contribute-details textarea{ | ||
resize: vertical; | ||
max-height: 200px; | ||
max-width: 300px; | ||
text-align: left; | ||
max-lines: 10; | ||
} | ||
.Toastify__toast-container { | ||
/* width: 350px; */ | ||
/* height: 80px; */ | ||
padding: 3px 15px; | ||
display: inline-block; | ||
} | ||
|
||
.Toastify__toast { | ||
/* width: 350px; */ | ||
/* height: 80px; */ | ||
width: fit-content; | ||
font-size: 16px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters