Skip to content

Commit 728797e

Browse files
authored
Merge pull request #68 from Coding-Club-IITG/prajit
Add file ui overhaul
2 parents b7bdfb3 + 165b25b commit 728797e

File tree

4 files changed

+67
-86
lines changed

4 files changed

+67
-86
lines changed

client/src/screens/contributions/index.jsx

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import { v4 as uuidv4 } from "uuid";
99
import { CreateNewContribution } from "../../api/Contribution";
1010
import { useSelector } from "react-redux";
1111
import { toast } from "react-toastify";
12-
import googleFormLink from "../../api/googleFormLink";
1312
import { useDispatch } from "react-redux";
1413

1514
import { getCourse } from "../../api/Course";
1615
import { UpdateCourses } from "../../actions/filebrowser_actions";
1716
const Contributions = () => {
1817
const uploadedBy = useSelector((state) => state.user.user._id);
1918
const userName = useSelector((state) => state.user.user.name);
19+
const isBR = useSelector((state) => state.user.user.isBR);
2020
const currentFolder = useSelector((state) => state.fileBrowser.currentFolder);
2121
const code = currentFolder?.course;
2222
const [contributionId, setContributionId] = useState("");
@@ -25,26 +25,18 @@ const Contributions = () => {
2525
setContributionId(uuidv4());
2626
}, []);
2727

28-
const [description, setDescription] = useState(null);
2928
const [submitEnabled, setSubmitEnabled] = useState(false);
3029

31-
useEffect(() => {
32-
if (!description) {
33-
setSubmitEnabled(false);
34-
return;
35-
}
36-
setSubmitEnabled(true);
37-
}, [description]);
38-
3930
// const [contributionId, setContributionId] = useState("");
4031

4132
let pond = useRef();
4233

34+
const handleUpdateFiles = (fileItems) => {
35+
if(fileItems.length > 0) setSubmitEnabled(true);
36+
else setSubmitEnabled(false);
37+
}
38+
4339
async function handleSubmit() {
44-
if (!description) {
45-
toast.error("Please fill the complete form.");
46-
return;
47-
}
4840
const collection = document.getElementsByClassName("contri");
4941
const contributionSection = collection[0];
5042
// console.log(toggle);
@@ -56,7 +48,7 @@ const Contributions = () => {
5648
let resp = await CreateNewContribution({
5749
parentFolder: currentFolder._id,
5850
courseCode: currentFolder.course,
59-
description,
51+
description: "default",
6052
approved: false,
6153
contributionId,
6254
uploadedBy,
@@ -96,25 +88,15 @@ const Contributions = () => {
9688
return (
9789
<SectionC>
9890
<Wrapper>
99-
<div className="head">Contribute to CourseHub</div>
100-
<form>
101-
<div className="description">
102-
<label htmlFor="description" className="label_description">
103-
DESCRIPTION :
104-
</label>
105-
<textarea
106-
name="description"
107-
className="input_description"
108-
placeholder="Give a brief description"
109-
value={description ? description : ""}
110-
onChange={(e) => setDescription(e.target.value)}
111-
></textarea>
112-
</div>
113-
</form>
91+
<div className="head">{isBR ? "📁 Add Files" : "📁 Contribute to CourseHub"}</div>
92+
<div className="disclaimer">
93+
Selected Files will get uploaded to the current folder
94+
</div>
11495
<div className="file_pond">
11596
<FilePond
11697
name="file"
11798
allowMultiple={true}
99+
onupdatefiles={handleUpdateFiles}
118100
maxFiles={40}
119101
server={{
120102
url: "http://localhost:8080/api/contribution/upload",
@@ -131,12 +113,20 @@ const Contributions = () => {
131113
}}
132114
/>
133115
</div>
134-
<div className="uploaded">
135-
{/* <span>UPLOADED:</span> folder/file */}
136-
Or submit link on{" "}
137-
<a href={googleFormLink} target="_blank">
138-
Google forms.
139-
</a>
116+
<div id="disclaimer-container">
117+
<div id="uploaded-container">
118+
<div>🚫</div>
119+
<div>Do not close this popup until all files are successfully uploaded!</div>
120+
</div>
121+
{
122+
!isBR ?
123+
<div id="uploaded-container">
124+
<div>⚠️</div>
125+
<div>Please contact your Branch Representative to verify the files you have uploaded so that it may be visible to everyone</div>
126+
</div>
127+
:
128+
<></>
129+
}
140130
</div>
141131
<div className={`button ${submitEnabled}`} onClick={handleSubmit}>
142132
SUBMIT

client/src/screens/contributions/styles.scss

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
display: flex;
8484
align-items: flex-start;
8585
justify-content: space-between;
86+
margin-top: 2rem;
8687

8788
.label_description {
8889
font-family: 'Bold';
@@ -94,7 +95,7 @@
9495
width: 60%;
9596
padding: 0.5rem;
9697
font-size: 1rem;
97-
height: 10vh;
98+
height: 18vh;
9899
}
99100
}
100101

@@ -130,24 +131,33 @@
130131
display: none;
131132
font-size: 1rem;
132133
}
134+
}
133135

134-
.uploaded {
135-
text-align: start;
136-
width: 100%;
137-
margin-top: 0.75rem;
136+
#disclaimer-container {
137+
display: flex;
138+
flex-direction: column;
139+
gap: 0.1rem;
140+
margin-top: 2rem;
141+
}
138142

139-
span {
140-
font-family: 'bold';
141-
font-size: 1rem;
142-
}
143-
}
143+
#uploaded-container {
144+
display: flex;
145+
margin-bottom: 0;
146+
gap: 8px;
147+
color: #535353;
148+
}
144149

150+
.disclaimer {
151+
margin: 1rem 0px;
152+
justify-self: center;
153+
color: #535353;
145154
}
146155

147156
.button {
148157
text-align: center;
149158
background-color: #FECF6F;
150159
padding: 1rem;
160+
margin-top: 1rem;
151161
font-family: 'bold';
152162
cursor: pointer;
153163

client/src/screens/dashboard/components/contributionbanner/index.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ const ContributionBanner = (props) => {
99
<p className="para">
1010
By sharing your notes, past papers, and other resources, you'll not only be
1111
helping others succeed, but you'll also get recognition for your hard work –
12-
we'll feature your name alongside the files you contribute.
12+
we'll feature your name alongside the files you contribute. You can contribute
13+
by uploading a file to the appropriate folder and then requesting your Branch
14+
Representative to verify the files.
1315
</p>
1416
</div>
1517
<div className="middle"></div>
16-
<div className="right">
17-
<div className="upwings"></div>
18-
<ContributeButton contributionHandler={props.contributionHandler} />
19-
<div className="downwings"></div>
20-
</div>
2118
</div>
2219
</div>
2320
);
Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
$small: 850px;
1+
$small: 1000px;
22
$medium: 1250px;
33

44
.contributionbanner {
55
background-color: #FECF6F;
6-
background-image: url(contribute.svg), none;
7-
background-position: center;
8-
background-repeat: no-repeat;
96

107
.content {
118
max-width: 1400px;
12-
padding: 40px 64px;
9+
padding: 0px 32px 0 64px;
1310
margin: auto;
1411
display: flex;
1512
justify-content: space-between;
1613
align-items: center;
1714
width: 100%;
18-
height: 200px;
15+
height: 250px;
1916

2017
.left {
18+
margin: 40px 0;
2119
flex: 1;
2220

2321
.title {
@@ -26,12 +24,16 @@ $medium: 1250px;
2624
}
2725

2826
.para {
29-
max-width: 350px;
27+
margin-top: 0.8rem;
3028
font-size: 1rem;
3129
}
3230
}
3331

3432
.middle {
33+
background-image: url(contribute.svg), none;
34+
background-position: center;
35+
background-repeat: no-repeat;
36+
height: 100%;
3537
flex: 1;
3638
}
3739

@@ -61,22 +63,22 @@ $medium: 1250px;
6163
}
6264
}
6365

64-
@media screen and (max-width: $medium) {
65-
66-
background-image: url(contribute_smallscreen.svg), none;
67-
background-position: 30vw;
66+
@media screen and (max-width: $small) {
6867

6968
.content {
7069
height: 100%;
7170
justify-content: center;
7271

7372
.left {
74-
margin-left: 10px;
75-
margin-bottom: 15px;
73+
margin: 40px 0;
7674
}
7775

7876
.middle {
79-
display: none;
77+
flex: 1;
78+
background-image: url(contribute_smallscreen.svg), none;
79+
height: 250px;
80+
background-position: center;
81+
// display: none;
8082
}
8183

8284
.right {
@@ -88,24 +90,6 @@ $medium: 1250px;
8890
}
8991
}
9092
}
93+
}
9194

92-
@media screen and (max-width: 950px) {
93-
background-image: unset;
94-
}
95-
96-
@media screen and (max-width: 1176px) {
97-
background-position: 28vw;
98-
}
99-
100-
@media screen and (max-width: 1141px) {
101-
background-image: unset;
102-
}
103-
104-
@media screen and (max-width: $small) {
105-
.content {
106-
flex-direction: column;
107-
justify-content: flex-start;
108-
align-items: flex-start;
109-
}
110-
}
111-
}
95+
#contribute-info {}

0 commit comments

Comments
 (0)