Skip to content

Commit a830501

Browse files
committed
bug fixes and minor design changes
1 parent 8eb5455 commit a830501

File tree

10 files changed

+142
-9
lines changed

10 files changed

+142
-9
lines changed

src/Routes.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Profile from './views/Profile/Profile';
88
import OrgPage from './views/OrgPage/OrgPage';
99
import Settings from './views/Settings/Settings';
1010
import About from './views/About/About';
11+
import NewDocBase from './views/NewDocBase/NewDocBase';
1112

1213
/**
1314
* All of our routes are defined here.
@@ -21,6 +22,10 @@ function Routes() {
2122
<Route path="/register" Component={Register} />
2223
<Route path="/organization/create" Component={CreateOrg} />
2324
<Route path="/organization/add/:id" Component={AddToOrg} />
25+
<Route
26+
path="/organization/:id/docbase/new"
27+
Component={NewDocBase}
28+
/>
2429
<Route path="/organization/:id" Component={OrgPage} />
2530
<Route path="/settings" Component={Settings} />
2631
<Route path="/about" Component={About} />

src/components/AttributeAdder/AttributeAdder.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,30 @@ import './AttributeAdder.scss';
33

44
interface Props {
55
populateAble: boolean;
6+
onListChange: (list: string[]) => void;
67
}
78

89
/**
910
* A component that allows the user to add attributes to there document base
1011
*/
11-
function AttributeAdder({ populateAble = true }: Props) {
12+
function AttributeAdder({ populateAble = true, onListChange }: Props) {
1213
const [attList, setAttList] = useState<string[]>([]);
1314
const [inputvalue, setInputValue] = useState<string>('');
1415

1516
const addAttribute = (att: string) => {
1617
if (attList.includes(att) || att.trim() === '') {
1718
return;
1819
}
19-
setAttList([...attList, att]);
20+
setAttributeList([...attList, att]);
2021
};
2122

2223
const deleteAttribute = (att: string) => {
23-
setAttList(attList.filter((a) => a !== att));
24+
setAttributeList(attList.filter((a) => a !== att));
25+
};
26+
27+
const setAttributeList = (list: string[]) => {
28+
onListChange(list);
29+
setAttList(list);
2430
};
2531

2632
const handlekeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {

src/index.scss

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ body {
99
a {
1010
color: var(--text-color);
1111
}
12-
12+
input {
13+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
14+
}
1315
.content {
1416
margin-top: 150px;
1517
margin-left: 50px;
@@ -41,6 +43,22 @@ a {
4143
}
4244
}
4345

46+
.ipt {
47+
margin: 0;
48+
height: 40px;
49+
background-color: var(--btn-color);
50+
border: 2px solid var(--text-color);
51+
border-radius: 5px;
52+
color: var(--text-color);
53+
padding: 0 10px;
54+
font-size: 1.2rem;
55+
margin-right: 10px;
56+
width: 300px;
57+
&:focus {
58+
outline: none;
59+
}
60+
}
61+
4462
.hor {
4563
display: flex;
4664
flex-direction: row;
@@ -66,6 +84,7 @@ a {
6684
width: 100%;
6785
height: 100%;
6886
background-color: rgba(0, 0, 0, 0.5);
87+
backdrop-filter: blur(5px);
6988
}
7089

7190
.mb {

src/utils/ApiService.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ describe('APIService', () => {
178178
expect(await APIService.leaveOrganization(eaterID as number)).toBe(
179179
false
180180
);
181-
expect(await APIService.getOrganizationNames()).toBe(undefined);
181+
//TODO does this make sense?
182+
//expect(await APIService.getOrganizationNames()).toStrictEqual([]);
183+
expect(await APIService.getOrganizationNames()).toBeUndefined();
182184
await APIService.login(salt, salt);
183185
});
184186

src/views/CreateOrg/CreateOrg.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function CreateOrg() {
2929
setErrorMessage('Organization name cannot be empty');
3030
return;
3131
}
32-
if (name.length > 20) {
32+
if (name.length > 30) {
3333
setErrorMessage(
34-
'Organization name cannot be longer than 20 characters'
34+
'Organization name cannot be longer than 30 characters'
3535
);
3636
return;
3737
}

src/views/Home/Home.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function Home() {
7070
className="btn"
7171
style={{ width: '100px' }}
7272
>
73+
<i className="bi bi-box-arrow-in-right mr icon"></i>
7374
Login
7475
</Link>
7576
</div>

src/views/NewDocBase/NewDocBase.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.NewDocBase {
2+
}

src/views/NewDocBase/NewDocBase.tsx

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { useEffect, useState } from 'react';
2+
import './NewDocBase.scss';
3+
import Navbar from '../../components/Navbar/Navbar';
4+
import AttributeAdder from '../../components/AttributeAdder/AttributeAdder';
5+
6+
/**
7+
* A page for creating a new Docbase
8+
*/
9+
function NewDocBase() {
10+
//const navigate = useNavigate();
11+
//const isLoggedIn = useLoggedIn();
12+
//const setLoadingScreen = useSetLoadingScreen();
13+
14+
const [name, setName] = useState<string>('');
15+
const [errorMsg, setErrorMsg] = useState<string>('');
16+
const [attList, setAttList] = useState<string[]>([]);
17+
18+
const onRun = () => {
19+
if (name.trim() === '') {
20+
setErrorMsg('Please enter a name');
21+
return;
22+
}
23+
if (attList.length === 0) {
24+
setErrorMsg('Please add at least one attribute');
25+
return;
26+
}
27+
setErrorMsg('');
28+
};
29+
30+
useEffect(() => {
31+
/* if (!isLoggedIn || !id) {
32+
navigate('/');
33+
}
34+
setLoadingScreen(true, 'Loading organization...');
35+
updateOrganizations().then((orgs) => {
36+
const org = id
37+
? orgs.find((org) => org.id === parseInt(id))
38+
: undefined;
39+
if (!org) {
40+
navigate('/');
41+
return;
42+
}
43+
setOrganization(org);
44+
45+
// Get members
46+
APIService.getMembersForOrganization(org.id).then((members) => {
47+
if (!members) {
48+
console.error('Failed to get members for org ' + org.id);
49+
return;
50+
}
51+
setMembers(members);
52+
});
53+
APIService.getDocumentForOrganization(org.id).then((docs) => {
54+
setDocuments(docs);
55+
setLoadingScreen(false);
56+
});
57+
}); */
58+
});
59+
60+
return (
61+
<div className="NewDocBase">
62+
<Navbar />
63+
<div className="content">
64+
<h1>
65+
Create new Docbase in Organization <i>ORGNAME</i>
66+
</h1>
67+
<h2>Name</h2>
68+
<input
69+
type="text"
70+
className="ipt"
71+
placeholder="Enter a name for the Docbase"
72+
onChange={(e) => setName(e.target.value)}
73+
/>
74+
<h2>Attributes</h2>
75+
<AttributeAdder
76+
populateAble={false}
77+
onListChange={(list) => {
78+
setAttList(list);
79+
}}
80+
></AttributeAdder>
81+
<p
82+
className="mt"
83+
style={{
84+
color: 'red',
85+
minHeight: '20px',
86+
}}
87+
>
88+
{errorMsg}
89+
</p>
90+
<button className="btn" onClick={onRun}>
91+
<i className="bi bi-play-fill icon mr"></i>Run
92+
</button>
93+
</div>
94+
</div>
95+
);
96+
}
97+
98+
export default NewDocBase;

templates/ContentPage/$$name$$.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Navbar from '../Navbar/Navbar';
1+
import Navbar from '../../components/Navbar/Navbar';
22
import './$$name$$.scss';
33

44
function $$name$$() {

templates/UserContentPage/$$name$$.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react';
22
import { useNavigate } from 'react-router-dom';
3-
import Navbar from '../Navbar/Navbar';
3+
import Navbar from '../../components/Navbar/Navbar';
44
import { useLoggedIn } from '../../providers/UserProvider';
55
import './$$name$$.scss';
66

0 commit comments

Comments
 (0)