Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated assignmentDetailPage #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/components/pages/assignmentDetailPage.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@import 'variables';

.header {
color: $text-color;
display: flex;
justify-content: space-between;
}

.name {
font-size: 1.5rem;
font-weight: 700;
margin-bottom: 0.4rem;
}

.subText {
font-size: 1.1rem;
width: 100%;
}

.assignmentBox {
text-decoration: none;

background: $list-item-background;
border-radius: 0.6rem;

padding: 1.5rem;

color: $text-color;

}

.button {
display: inline-block;
padding: 10px 20px;
font-size: 16px;
font-weight: bold;
text-align: center;
border: none;
border-radius: 4px;
color: $background;
background-color: $green;
transition: background-color 0.3s ease;
cursor: pointer;
}

.button:hover {
background-color: $green-lighter;
color: $text-color;
}

@media (max-width: 700px) {
.header {
display: block;
}
}
65 changes: 63 additions & 2 deletions src/components/pages/assignmentDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,68 @@
import React from 'react'
import React, { useState, useEffect } from 'react'
import { Assignment } from 'devu-shared-modules'
import { prettyPrintDate } from 'utils/date.utils'

import LoadingOverlay from 'components/shared/loaders/loadingOverlay'
import PageWrapper from 'components/shared/layouts/pageWrapper'
import ErrorPage from './errorPage'

const AssignmentDetailPage = ({}) => <PageWrapper>Assignment Detail</PageWrapper>
import RequestService from 'services/request.service'

import styles from './assignmentDetailPage.scss'

const AssignmentDetailPage = () => {
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)

const [assignment, setAssignment] = useState<Assignment | null>(null)

useEffect(() => {
fetchData()
}, [])

const fetchData = async () => {
try {
const currentAssignment = await RequestService.get<Assignment>(`/api/assignments/2`)
setAssignment(currentAssignment)
} catch (error) {
setError(error)
} finally {
setLoading(false)
}
}

if (loading) return <LoadingOverlay delay={250} />
if (error) return <ErrorPage error={error} />

return (
<PageWrapper>
<div className={styles.header}>
<h1>Assignment Details</h1>
</div>
<div className={styles.assignmentBox}>
{assignment ? (
<>
<div className={styles.name}>{assignment.name}</div>
<div className={styles.subText}>
<p>{assignment.description}</p>
<p>
Due: <b>{prettyPrintDate(assignment.dueDate)}</b>
</p>
<p>
Last day to handin: <b>{prettyPrintDate(assignment.endDate)}</b>
</p>

<button className={styles.button}>SUBMIT</button>
</div>
</>
) : (
<div>Could not find assignment</div>
)}
</div>

{/* Add submission history here */}
</PageWrapper>
)
}

export default AssignmentDetailPage