Skip to content

Commit

Permalink
bug fix where the docbase new button does not appear
Browse files Browse the repository at this point in the history
  • Loading branch information
cophilot committed Feb 17, 2024
1 parent 8346330 commit 440c6fe
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 34 deletions.
9 changes: 6 additions & 3 deletions src/components/DocBaseOverview/DocBaseOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ import Icon from '../Icon/Icon';

interface Props {
organizationProp: Organization | undefined;
counter: number;
}

/**
* A list of all DocBases of an organization.
*/
function DocBaseOverview({ organizationProp }: Props) {
function DocBaseOverview({ organizationProp, counter }: Props) {
const [docBases, setDocBases] = useState<MyDocument[]>([]);
const [fileCount, setFileCount] = useState<number>(0);
const [selectedOrgID, setSelectedOrgID] = useState<number>(-1);
Expand All @@ -38,15 +39,17 @@ function DocBaseOverview({ organizationProp }: Props) {
useEffect(() => {
APIService.getOrganizationNames().then((orgs) => {
let orgID = -1;
if (organizationProp !== undefined) {
if (selectedOrgID !== -1) {
orgID = selectedOrgID;
} else if (organizationProp !== undefined) {
orgID = organizationProp.id;
} else if (orgs !== undefined && orgs.length > 0) {
orgID = orgs[0].id;
}
loadDocBases(orgID);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [organizationProp, counter]);

const loadDocBases = (orgID: number) => {
if (orgID === -1) {
Expand Down
14 changes: 14 additions & 0 deletions src/views/Home/Home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@
.Home {
margin-bottom: 100px;
}

.userStudy {
padding: 20px;
background-color: #083d60;
color: white;
width: 50%;
a {
color: white;
}
font-size: 20px;
border-radius: 15px;
border: 2px solid white;
box-shadow: 5px 5px 5px #0000008c;
}
69 changes: 39 additions & 30 deletions src/views/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Home() {

const [username] = useState(getUserName());
const isLoggedIn = useLoggedIn();
const [counter, setCounter] = useState(0);

if (isLoggedIn()) {
return (
Expand All @@ -37,35 +38,36 @@ function Home() {
Hi {username.slice(0, -2)}
<span className="db">{username.slice(-2)}</span> 👋
</h1>
<h2>
U<span className="db">se</span>r Study
</h2>
<p>
<b>
If you are from the user study, you can download
some sample documents{' '}
<a
href="https://github.com/cophilot/wannadb-sample-txt/archive/refs/heads/main.zip"
target="_blank"
>
here
</a>{' '}
to use them for the upload.
</b>
</p>
<p>
<i>
If the link does not download the file, please click{' '}
<a
href="https://github.com/cophilot/wannadb-sample-txt?tab=readme-ov-file#how-to-download"
target="_blank"
rel="noreferrer"
>
here
</a>{' '}
and download the file manually.
</i>
</p>
<div className="userStudy">
<h2>User Study</h2>
<p>
<b>
If you are from the user study, you can download
some sample documents{' '}
<a
href="https://github.com/cophilot/wannadb-sample-txt/archive/refs/heads/main.zip"
target="_blank"
>
here
</a>{' '}
to use them for the upload.
</b>
</p>
<p>
<i>
If the link does not download the file, please
click{' '}
<a
href="https://github.com/cophilot/wannadb-sample-txt?tab=readme-ov-file#how-to-download"
target="_blank"
rel="noreferrer"
>
here
</a>{' '}
and download the file manually.
</i>
</p>
</div>
<h2>
T<span className="db">ip</span>
</h2>
Expand All @@ -75,11 +77,18 @@ function Home() {
<h2>
Document <span className="db">Up</span>load
</h2>
<FileUpload organizationProp={undefined}></FileUpload>
<FileUpload
organizationProp={undefined}
afterUpload={() => {
//window.location.reload();
setCounter(counter + 1);
}}
></FileUpload>
<h2>
Doc<span className="db">Ba</span>se
</h2>
<DocBaseOverview
counter={counter}
organizationProp={undefined}
></DocBaseOverview>
{import.meta.env.VITE_APP_LOG === 'true' && (
Expand Down
9 changes: 8 additions & 1 deletion src/views/OrgPage/OrgPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function OrgPage() {
const [members, setMembers] = useState<string[]>([]);
const [documents, setDocuments] = useState<MyDocument[]>([]);
const [render, setRender] = useState<boolean>(false);
const [counter, setCounter] = useState(0);

const navigate = useNavigate();
const isLoggedIn = useLoggedIn();
Expand Down Expand Up @@ -139,11 +140,17 @@ function OrgPage() {
organization.id
).then((docs) => {
setDocuments(docs);
setCounter(counter + 1);
});
}}
></FileUpload>
<h2>Docbase</h2>
{render && <DocBaseOverview organizationProp={organization} />}
{render && (
<DocBaseOverview
organizationProp={organization}
counter={counter}
/>
)}
<button
className="btn"
style={{ marginBottom: '100px', marginTop: '50px' }}
Expand Down

0 comments on commit 440c6fe

Please sign in to comment.