Skip to content

Commit c09bd14

Browse files
committed
improvment and adding edge cases
1 parent e8af459 commit c09bd14

4 files changed

Lines changed: 51 additions & 21 deletions

File tree

src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const app = () => {
5151
</div>
5252
</section>
5353
<ReactTooltip place="bottom" type="dark" effect="solid" />
54-
<ToastContainer position="top-right" autoClose={5000} pauseOnHover={false} />
54+
<ToastContainer position="bottom-left" autoClose={5000} pauseOnHover={false} />
5555
</div>
5656
);
5757
};

src/component/modals/ContributeDetails.jsx

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react';
2+
import { toast } from 'react-toastify';
23
import axios from 'axios';
34
import Modal from './ParentModal';
45
import { actionType as T } from '../../reducer';
@@ -14,19 +15,23 @@ const ContributeDetails = ({ superState, dispatcher }) => {
1415
const [title, setTitle] = useState('');
1516
const [desc, setDesc] = useState('');
1617
const [branch, setBranch] = useState('');
18+
const [showAdvanceOptions, setShowAdvanceOptions] = useState(false);
1719
const submit = async (e) => {
20+
const id = toast.loading('Processing Your Request.Please wait...');
1821
try {
1922
e.preventDefault();
2023
const result = await axios.post(`http://127.0.0.1:5000/contribute?study=${study}&auth=${auth}&desc=${desc}&title=${title}&path=${path}&branch=${branch}`, { token: process.env.TOKEN });
2124
// eslint-disable-next-line
22-
console.log(process.env.Token);
23-
// eslint-disable-next-line
24-
alert(result.data.message);
25-
// console.log(result.data);
26-
closeModal();
25+
// console.log(process.env.Token);
26+
toast.success(result.data?.message);
2727
} catch (error) {
28-
// console.log(error);
28+
toast.error(error.response.data.message);
2929
}
30+
toast.dismiss(id);
31+
closeModal();
32+
};
33+
const toggleOptions = () => {
34+
setShowAdvanceOptions(!showAdvanceOptions);
3035
};
3136
return (
3237
<Modal
@@ -60,18 +65,26 @@ const ContributeDetails = ({ superState, dispatcher }) => {
6065
onChange={(e) => setBranch(e.target.value)}
6166
required
6267
/>
63-
<span>PR Title</span>
64-
<input
65-
value={title}
66-
onChange={(e) => setTitle(e.target.value)}
67-
required
68-
/>
69-
<span>PR Description</span>
70-
<input
71-
value={desc}
72-
onChange={(e) => setDesc(e.target.value)}
73-
required
74-
/>
68+
{showAdvanceOptions && (
69+
<>
70+
<span>PR Title</span>
71+
<input
72+
value={title}
73+
onChange={(e) => setTitle(e.target.value)}
74+
required
75+
/>
76+
<span>PR Description</span>
77+
<input
78+
value={desc}
79+
onChange={(e) => setDesc(e.target.value)}
80+
required
81+
/>
82+
</>
83+
)}
84+
<button type="button" className="btn btn-secondary" onClick={toggleOptions}>
85+
{showAdvanceOptions ? 'Hide ' : 'Show '}
86+
Advance Options
87+
</button>
7588
<div className="expand">
7689
<button type="submit" className="btn btn-primary" onClick={submit}>Generate PR</button>
7790
</div>

src/component/modals/contributeDetails.css

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,21 @@
1717

1818
.contribute-details .btn{
1919
width: 100%;
20-
}
20+
}
21+
.contribute-details .btn-secondary{
22+
align-self: flex-end;
23+
}
24+
.Toastify__toast-container {
25+
/* width: 350px; */
26+
/* height: 80px; */
27+
margin-right: 20px;
28+
padding: 3px 15px;
29+
display: inline-block;
30+
}
31+
32+
.Toastify__toast {
33+
/* width: 350px; */
34+
/* height: 80px; */
35+
width: fit-content;
36+
font-size: 16px;
37+
}

src/toolbarActions/toolbarList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ const toolbarList = (state, dispatcher) => [
228228
text: 'Contribute',
229229
icon: FiTriangle,
230230
action: contribute,
231-
active: state.curGraphInstance || state.uploadedDirName,
231+
active: true,
232232
visibility: true,
233233
},
234234
// {

0 commit comments

Comments
 (0)