Skip to content

Commit

Permalink
docs: added docs for all other remaining components
Browse files Browse the repository at this point in the history
  • Loading branch information
ayanchoudhary committed Apr 29, 2020
1 parent a43f5b8 commit 435097c
Show file tree
Hide file tree
Showing 23 changed files with 320 additions and 8 deletions.
5 changes: 4 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#integrate login/signup flow
#make no activity page
#add notifications
#integrate logout flow
#integrate logout flow
#change number of downloads
#link file with activity
#refresh request
3 changes: 3 additions & 0 deletions src/components/common/notificationCard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React,{ Component } from 'react';
import 'styles/main.scss';

/**
* Component to render notifications.
*/
class NotificationCard extends Component {
render() {
return(
Expand Down
6 changes: 6 additions & 0 deletions src/components/common/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import polygon from 'assets/Polygon.svg';
import notif from 'assets/notif.svg';
import 'styles/main.scss';

/**
* Notification component for Studyportal.
*/
class Notifications extends Component {
render() {
return(
Expand All @@ -31,7 +34,10 @@ class Notifications extends Component {
export default Notifications;

Notifications.propTypes = {
/** Identifies notification popup toggle status. */
notifications: PropTypes.bool,
/** Function to toggle state of modals. */
handleClick: PropTypes.func,
/** Function to close modals. */
close: PropTypes.func
};
7 changes: 7 additions & 0 deletions src/components/common/userMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const mapStateToProps = state => {
return { user: state };
};

/**
* User-Menu component for Studyportal.
*/
class UserMenu extends Component {
render() {
return(
Expand Down Expand Up @@ -39,8 +42,12 @@ class UserMenu extends Component {
export default connect(mapStateToProps)(UserMenu);

UserMenu.propTypes = {
/** Holds user data which is handled through Redux. */
user: PropTypes.object,
/** Identifies user-menu popup toggle status */
userMenu: PropTypes.bool,
/** Function to toggle state of modals */
handleClick: PropTypes.func,
/** Function to close modals. */
close: PropTypes.func
};
30 changes: 30 additions & 0 deletions src/components/coursecard/coursePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function mapStateToProps(state) {
return { user: state };
}

/**
* Coursepage component for Studyportal.
*/
class CoursePage extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -55,6 +58,11 @@ class CoursePage extends Component {
}
}

/**
* Fetches files according to params.
*
* @param {object} nextProps
*/
getFiles(nextProps) {
this.setState({ loading:true });
getDepartmentInfoByAbbr(nextProps.department_abbr).then((res,err) => {
Expand Down Expand Up @@ -99,6 +107,11 @@ class CoursePage extends Component {
});}}});}});
}

/**
* Sorts files by creation date.
*
* @param {array} files
*/
sortFilesByYear(files) {
if(!_.isEmpty(files)) {
let years = [];
Expand All @@ -120,6 +133,11 @@ class CoursePage extends Component {
else return files;
}

/**
* Checks if this course is registered for the user.
*
* @param {object} props
*/
async checkCourse(props) {
if(props.user.login) {
this.setState({ mycourse:false });
Expand All @@ -130,6 +148,9 @@ class CoursePage extends Component {
}
}

/**
* Registers course for user.
*/
addCourse() {
const token = getCookie('token');
addCourseForUser(token,this.state.id).then((res,err) => {
Expand All @@ -143,6 +164,9 @@ class CoursePage extends Component {
});
}

/**
* Removes registered course from user.
*/
deleteCourse() {
const token = getCookie('token');
deleteCourseForUser(token,this.state.id).then((res,err) => {
Expand Down Expand Up @@ -245,10 +269,16 @@ class CoursePage extends Component {
export default connect(mapStateToProps)(CoursePage);

CoursePage.propTypes = {
/** Holds user data which is handled through Redux. */
user: PropTypes.object,
/** Fetch user details from API. */
getUserDetails: PropTypes.func,
/** Function to close modals. */
close: PropTypes.func,
/** Holds course code for the course. */
course_code: PropTypes.string,
/** Holds file type displayed currently. */
file_type: PropTypes.string,
/** Holds department abbreviation for the department. */
department_abbr: PropTypes.string
};
16 changes: 16 additions & 0 deletions src/components/coursecard/materialCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import download1 from 'assets/download.svg';
import download2 from 'assets/download1.svg';
import CustomCheckbox from 'components/customcheckbox/customCheckbox';

/**
* Component to render files.
*/
class MaterialCard extends Component {
constructor(props) {
super(props);
Expand All @@ -29,10 +32,16 @@ class MaterialCard extends Component {
this.leave = this.leave.bind(this);
}

/**
* Highlight download icon.
*/
hover() {
this.setState({ queue: '1' });
}

/**
* Remove highlight from download icon.
*/
leave() {
this.setState({ queue: '2' });
}
Expand Down Expand Up @@ -71,11 +80,18 @@ class MaterialCard extends Component {
export default MaterialCard;

MaterialCard.propTypes = {
/** Holds download icon highlight status. */
queue: PropTypes.string,
/** Holds file name. */
name: PropTypes.string,
/** Holds file size. */
size: PropTypes.string,
/** Holds number of downloads. */
downloads: PropTypes.number,
/** Holds driveid of the file. */
url: PropTypes.string,
/** Holds file extension to display icon. */
ext: PropTypes.string,
/** Holds creation date of file. */
date_modified: PropTypes.string
};
4 changes: 4 additions & 0 deletions src/components/cover/courseCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import PropTypes from 'prop-types';
import courseselect from 'assets/course_select.svg';
import 'styles/main.scss';

/**
* Coursecover component for Studyportal.
*/
function CourseCover(props) {
return (
<div className='coursecover' onClick={props.close}>
Expand All @@ -15,5 +18,6 @@ function CourseCover(props) {
export default CourseCover;

CourseCover.propTypes = {
/** Function to close modals. */
close: PropTypes.func
};
4 changes: 4 additions & 0 deletions src/components/cover/fileCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import PropTypes from 'prop-types';
import loader from 'assets/fileloader.svg';
import 'styles/main.scss';

/**
* Filecover component for Studyportal.
*/
function FileCover(props) {
return (
<div className='filecover' onClick={props.close}>
Expand All @@ -15,5 +18,6 @@ function FileCover(props) {
export default FileCover;

FileCover.propTypes = {
/** Function to close modals. */
close: PropTypes.func
};
14 changes: 14 additions & 0 deletions src/components/customcheckbox/customCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import 'styles/main.scss';

/**
* Component to render custom checkboxes.
*/
class CustomCheckbox extends Component {
constructor(props) {
super(props);
Expand All @@ -14,10 +17,16 @@ class CustomCheckbox extends Component {
this.leave = this.leave.bind(this);
}

/**
* Highlight checkbox.
*/
hover() {
this.setState({ hover: true });
}

/**
* Remove highlight from checkbox.
*/
leave() {
this.setState({ hover: false });
}
Expand All @@ -39,9 +48,14 @@ class CustomCheckbox extends Component {
export default CustomCheckbox;

CustomCheckbox.propTypes = {
/** Identifies checked status of checkbox. */
value: PropTypes.bool,
/** Identifies the checkbox toggle status. */
handleChange: PropTypes.func,
/** Holds border color for checkbox. */
border: PropTypes.string,
/** Holds border color for checkbox on hover. */
borderhover: PropTypes.string,
/** Holds colour displayed on higlight. */
hover: PropTypes.string
};
4 changes: 4 additions & 0 deletions src/components/error/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import error from 'assets/error.svg';

/**
* 404Page component for Studyportal.
*/
function Error(props) {
return (
<div className='error' onClick={props.close}>
Expand All @@ -22,5 +25,6 @@ function Error(props) {
export default Error;

Error.propTypes = {
/** Function to close modals. */
close: PropTypes.func
};
11 changes: 10 additions & 1 deletion src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const mapStateToProps = state => {
return { user: state };
};

/**
* Header component for Studyportal.
*/
class Header extends Component {
render() {
return(
Expand Down Expand Up @@ -72,12 +75,18 @@ class Header extends Component {
export default connect(mapStateToProps)(Header);

Header.propTypes = {
/** Holds status of user-menu popup. */
userMenu: PropTypes.bool,
/** Holds status of notifications popup. */
notifications: PropTypes.bool,
/** Holds status of search result popup. */
search: PropTypes.bool,
/** Function to close modals. */
close: PropTypes.func,
/** Function to toggle state of modals. */
handleClick: PropTypes.func,
handleSeeAll: PropTypes.func,
/** Function to toggle see-all modal. */
handleSeeAllClick: PropTypes.func,
/** Holds user data which is handled through Redux. */
user: PropTypes.object
};
19 changes: 18 additions & 1 deletion src/components/header/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { getSearchResults } from 'api/searchApi';
import { Link } from 'react-router-dom';
import emoji from 'assets/mdi_sentiment_very_dissatisfied.svg';

/**
* Component to render search.
*/
class Search extends Component {
constructor(props) {
super(props);
Expand All @@ -28,6 +31,11 @@ class Search extends Component {
this.setState({ search:props.search });
}

/**
* Fetches search result.
*
* @param {string} query
*/
getResults(query) {
getSearchResults(query).then((res,err) => {
if(err){
Expand All @@ -47,6 +55,11 @@ class Search extends Component {
});
}

/**
* Toggles search popup when text is typed in search bar.
*
* @param {object} e
*/
result(e) {
this.setState({ value: e.target.value });
if (e.target.value !== '') {
Expand Down Expand Up @@ -164,10 +177,14 @@ class Search extends Component {
export default Search;

Search.propTypes = {
/** Holds status of search popup. */
search: PropTypes.bool,
/** Identifies whether search is in homepage. */
home: PropTypes.bool,
/** Function to close modals. */
close: PropTypes.func,
/** Function to toggle state of modals. */
handleClick: PropTypes.func,
handleReqClick: PropTypes.func,
/** Function to toggle see-all modal. */
handleSeeAllClick: PropTypes.func
};
10 changes: 10 additions & 0 deletions src/components/header/searchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import ppt from 'assets/material_ppt.svg';
import img from 'assets/material_img.svg';
import 'styles/main.scss';

/**
* Component to render files.
*/
class SearchResult extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -53,11 +56,18 @@ class SearchResult extends Component {
export default SearchResult;

SearchResult.propTypes = {
/** Holds file name. */
name: PropTypes.string,
/** Holds driveid of the file. */
url: PropTypes.string,
/** Holds creation date of file. */
date_modified: PropTypes.string,
/** Holds course title related to file. */
course_name: PropTypes.string,
/** Holds course code related to file. */
course_code: PropTypes.string,
/** Holds the type of file. */
file_type: PropTypes.string,
/** Holds extension of file. */
ext: PropTypes.string
};
Loading

0 comments on commit 435097c

Please sign in to comment.