Skip to content

Commit

Permalink
added org links on home page and removed add button on upload
Browse files Browse the repository at this point in the history
  • Loading branch information
cophilot committed Mar 2, 2024
1 parent 4d1acd3 commit ae6282b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
23 changes: 14 additions & 9 deletions src/components/FileUpload/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import FileViewer from '../FileViewer/FileViewer';
import { useSetLoadingScreen } from '../../providers/LoadingScreenProvider';
import Organization from '../../types/Organization';
import Icon from '../Icon/Icon';
import Logger from '../../utils/Logger';

interface Props {
organizationProp: Organization | undefined;
Expand All @@ -34,14 +35,18 @@ function FileUpload({ organizationProp, afterUpload }: Props) {
const selectedFiles = event.target.files;
if (selectedFiles === null) return;
setstagedFiles([...selectedFiles, ...Array.from(stagedFiles)]);
setTimeout(() => {
addFile([...selectedFiles, ...Array.from(stagedFiles)]);
}, 300);
};

const addFile = (force: boolean = false) => {
if (stagedFiles.length === 0) {
const addFile = (zfiles: File[], force: boolean = false) => {
if (zfiles.length === 0) {
Logger.log('No files to add');
return;
}
if (!force) {
for (const stagedFile of stagedFiles) {
for (const stagedFile of zfiles) {
for (const file of files) {
if (
file.name === stagedFile.name &&
Expand All @@ -51,7 +56,7 @@ function FileUpload({ organizationProp, afterUpload }: Props) {
showChoiceNotification(
'File upload',
`The file ${stagedFile.name} is already in the list. Do you want to add it anyway?`,
() => addFile(true),
() => addFile(zfiles, true),
() => {},
'Yes',
'No'
Expand All @@ -62,13 +67,13 @@ function FileUpload({ organizationProp, afterUpload }: Props) {
}
}

setFiles([...files, ...stagedFiles]);
setFiles([...files, ...zfiles]);
setstagedFiles([]);
};

const discardFiles = () => {
/* const discardFiles = () => {
setstagedFiles([]);
};
}; */

const removeFile = (index: number) => {
const newFiles = [...files];
Expand Down Expand Up @@ -166,14 +171,14 @@ function FileUpload({ organizationProp, afterUpload }: Props) {
multiple={true}
/>
</div>
<div className="hor mb">
{/* <div className="hor mb">
<button className="btn" onClick={() => addFile()}>
Add
</button>
<button className="btn" onClick={discardFiles}>
Discard
</button>
</div>
</div> */}
{files.map((file, index) => (
<li className="file" key={index}>
<div className="dot"></div>
Expand Down
3 changes: 3 additions & 0 deletions src/views/Home/Home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
.helpIcon {
margin-left: 10px;
}
h2 {
margin-top: 70px;
}
}

.userStudy {
Expand Down
38 changes: 36 additions & 2 deletions src/views/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Home() {
Hi {username.slice(0, -2)}
<span className="db">{username.slice(-2)}</span> 👋
</h1>
<div className="userStudy">
{/* <div className="userStudy">
<h2>User Study</h2>
<p>
<b>
Expand Down Expand Up @@ -67,13 +67,47 @@ function Home() {
and download the file manually.
</i>
</p>
</div>
</div> */}
<h2>
T<span className="db">ip</span>
</h2>
<p>
<i>{getRandomTip()}</i>
</p>
<h2>
<span className="db">Or</span>ganization
</h2>
<p>
You can view your organizations{' '}
<span
onClick={() => {
navigate('/profile');
}}
style={{
cursor: 'pointer',
textDecoration: 'underline',
}}
>
here
</span>
.
</p>
<p>
Or you can create a new organization{' '}
<span
onClick={() => {
navigate('/organization/create');
}}
style={{
cursor: 'pointer',
textDecoration: 'underline',
}}
>
here
</span>
.
</p>

<h2>
Document <span className="db">Up</span>load{' '}
<i
Expand Down

0 comments on commit ae6282b

Please sign in to comment.