-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: View thesis TODO: Delete/Edit thesis TODO: Thesis admin TODO: Profile view
- Loading branch information
1 parent
a1cf4a8
commit 4ef850a
Showing
6 changed files
with
168 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
|
||
export default function ProfileView() { | ||
return <></>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import React, { useState, useRef } from 'react'; | ||
import { Table } from 'antd'; | ||
|
||
import { getColumnSearchProps } from '../../member-database/ColumnSearchProps'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
export default function ThesesTable({ theses }) { | ||
const [page, setPage] = useState(1); | ||
const [pageSize, setPageSize] = useState(10); | ||
const [searchText, setSearchText] = useState(''); | ||
const [searchedColumn, setSearchedColumn] = useState(''); | ||
const searchInput = useRef(null); | ||
|
||
let colSearchParams = [ | ||
searchInput, | ||
searchText, | ||
setSearchText, | ||
searchedColumn, | ||
setSearchedColumn, | ||
]; | ||
|
||
const cols = [ | ||
{ | ||
title: 'No', | ||
key: 'index', | ||
render: (value, item, index) => (page - 1) * pageSize + index + 1, | ||
}, | ||
{ | ||
title: 'Type', | ||
dataIndex: 'itemType', | ||
key: 'itemType', | ||
sorter: { | ||
compare: (a, b) => | ||
(a.itemType || '').localeCompare(b.itemType || ''), | ||
}, | ||
...getColumnSearchProps('itemType', ...colSearchParams), | ||
}, | ||
{ | ||
title: 'Title', | ||
dataIndex: 'title', | ||
key: 'title', | ||
sorter: { | ||
compare: (a, b) => (a.title || '').localeCompare(b.title || ''), | ||
}, | ||
...getColumnSearchProps('title', ...colSearchParams), | ||
}, | ||
{ | ||
title: 'Corresponding Author', | ||
dataIndex: 'correspondingAuthor', | ||
key: 'correspondingAuthor', | ||
sorter: { | ||
compare: (a, b) => | ||
(a.correspondingAuthor || '').localeCompare( | ||
b.correspondingAuthor || '' | ||
), | ||
}, | ||
...getColumnSearchProps('correspondingAuthor', ...colSearchParams), | ||
// eslint-disable-next-line react/display-name | ||
render: (author) => | ||
typeof author === 'string' ? ( | ||
author | ||
) : ( | ||
<Link to={`/app/profile/${author.id}`}>{author.name}</Link> | ||
), | ||
}, | ||
]; | ||
return ( | ||
<Table | ||
columns={cols} | ||
dataSource={theses} | ||
pagination={{ | ||
onChange(current) { | ||
setPage(current); | ||
}, | ||
onShowSizeChange(current, size) { | ||
setPageSize(size); | ||
}, | ||
showSizeChanger: true, | ||
pageSizeOptions: [5, 10, 20, 50, 100], | ||
}} | ||
scroll={{ x: true }} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import axios from 'axios'; | ||
import { useAuth } from '../../../utils/useAuth'; | ||
import { Card, Spin } from 'antd'; | ||
import { CopyOutlined } from '@ant-design/icons'; | ||
|
||
import ThesesTable from '../components/ThesesTable'; | ||
|
||
export default function ThesisMySubmissionsView() { | ||
const auth = useAuth(); | ||
const [theses, setTheses] = useState(null); | ||
|
||
useEffect(() => { | ||
// fetch data | ||
axios.get(`/api/thesis?createdBy=${auth.user._id}`).then((res) => { | ||
setTheses(res.data.theses); | ||
}); | ||
}, []); | ||
return ( | ||
<Card | ||
title={ | ||
<span> | ||
<CopyOutlined /> My Submissions | ||
</span> | ||
} | ||
> | ||
{theses ? <ThesesTable theses={theses} /> : <Spin />} | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import axios from 'axios'; | ||
import { Card, Spin } from 'antd'; | ||
import { SearchOutlined } from '@ant-design/icons'; | ||
|
||
import ThesesTable from '../components/ThesesTable'; | ||
|
||
export default function ThesisSearchView() { | ||
const [theses, setTheses] = useState(null); | ||
|
||
useEffect(() => { | ||
// fetch data | ||
axios.get(`/api/thesis`).then((res) => { | ||
setTheses(res.data.theses); | ||
}); | ||
}, []); | ||
return ( | ||
<Card | ||
title={ | ||
<span> | ||
<SearchOutlined /> Search | ||
</span> | ||
} | ||
> | ||
{theses ? <ThesesTable theses={theses} /> : <Spin />} | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters