-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/comittee applications #522
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
Open
HaakonMikalsen
wants to merge
8
commits into
main
Choose a base branch
from
feat/Comittee_applications
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
85643b6
feat: add services for read committee applications and periodes and c…
HaakonMikalsen b1895c4
feat: Add committee aplication dev seeder
HaakonMikalsen 3412c6d
fix: number passed as string instead of number
HaakonMikalsen 13a2cd6
feat: styling and linting
HaakonMikalsen de04847
lint: fix linting
HaakonMikalsen a9fa432
Merge remote-tracking branch 'origin/main' into feat/Comittee_applica…
9233c20
fix: resolve merge conflicts
8ec286a
refactor: unflattened return form services. Moved time check to serve…
HaakonMikalsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
32 changes: 32 additions & 0 deletions
32
src/app/committees/[shortName]/periodes/[participationId]/page.module.scss
This file contains hidden or 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,32 @@ | ||
| @use '@/styles/ohma'; | ||
| //TODO: fix styling to be aligned to the future styling pr | ||
|
|
||
|
|
||
| .applicationContainer { | ||
| margin-top: 1em; | ||
| display: flex; | ||
| flex-direction: column; | ||
| border: 2px solid hsla(0, 0%, 70%, 0.507); | ||
| @include ohma.round; | ||
|
|
||
| } | ||
|
|
||
| .headingContainer { | ||
| display: flex; | ||
| align-items: center; | ||
|
|
||
| * { | ||
| display: inline-block; | ||
| margin-inline: 0.1em; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| .applicantName { | ||
| color: black; | ||
| } | ||
|
|
||
| .applicationsContainer {} | ||
| .profilePicture {} | ||
| .applicationTextContainer {} | ||
| .applicationText {} | ||
57 changes: 57 additions & 0 deletions
57
src/app/committees/[shortName]/periodes/[participationId]/page.tsx
This file contains hidden or 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,57 @@ | ||
| import styles from './page.module.scss' | ||
| import { unwrapActionReturn } from '@/app/redirectToErrorPage' | ||
| import { readCommitteeApplicationsInPeriodAction } from '@/services/applications/committeeParticipation/actions' | ||
| import ProfilePicture from '@/components/User/ProfilePicture' | ||
| import { readSpecialImageAction } from '@/services/images/actions' | ||
| import Link from 'next/link' | ||
| import type { Image as ImageT } from '@/prisma-generated-pn-types' | ||
| export type PropTypes = { | ||
| params: Promise<{ | ||
| shortName: string, | ||
| participationId: string, | ||
| }> | ||
| } | ||
|
|
||
|
|
||
| async function loadUserImage(image: ImageT | null) { | ||
|
HaakonMikalsen marked this conversation as resolved.
Outdated
|
||
| return image ? image : await readSpecialImageAction.bind( | ||
| null, { params: { special: 'DEFAULT_PROFILE_IMAGE' } } | ||
| )().then(res => { | ||
| if (!res.success) throw new Error('Kunne ikke finne standard profilbilde') | ||
| return res.data | ||
| }) | ||
| } | ||
|
|
||
|
|
||
| export default async function PeriodeCommitteePage({ params }: PropTypes) { | ||
| const participationId = parseInt((await params).participationId, 10) | ||
| const applications = unwrapActionReturn( | ||
| await readCommitteeApplicationsInPeriodAction({ params: { participationId } }) | ||
| ) | ||
| if (applications.length === 0) { return 'ingen søknader funnet' } | ||
| const sortedApplications = applications.sort((a, b) => a.applicationPriority - b.applicationPriority) | ||
| return ( | ||
| <div className={styles.applicationsContainer}> | ||
| {sortedApplications.map(async (application, index) => ( | ||
| <div className={styles.applicationContainer} key={index}> | ||
| <div className={styles.headingContainer}> | ||
| <h3>{application.applicationPriority}.</h3> | ||
| <ProfilePicture | ||
| width={50} | ||
| profileImage={(await loadUserImage(application.image))} | ||
| className={styles.profilePicture} | ||
| /> | ||
| <Link className={styles.applicantName} href={`/users/${application.username}`}> | ||
| <h3>{application.firstname} {application.lastname}</h3> | ||
| </Link> | ||
| </div> | ||
| <div className={styles.applicationTextContainer}> | ||
| <p className={styles.applicationText}>{application.applicationText}</p> | ||
| </div> | ||
| </div > | ||
| )) | ||
| } | ||
| </div > | ||
| ) | ||
| } | ||
|
|
||
This file contains hidden or 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,25 @@ | ||
| @use '@/styles/ohma'; | ||
| //TODO: fix styling to be aligned to the future styling pr | ||
|
|
||
|
|
||
|
|
||
| .periodTable{ | ||
| border: 2px solid hsla(0, 0%, 70%, 0.507); | ||
| border-collapse: collapse; | ||
| text-align: center; | ||
| @include ohma.round; | ||
| } | ||
|
|
||
|
|
||
| .tableEntry { | ||
| border: 2px solid hsla(0, 0%, 70%, 0.507); | ||
| padding: 1em; | ||
| } | ||
|
|
||
| .currentPeriodEntry{ | ||
| font-weight: bold; | ||
| background-color: hsla(120, 100%, 70%, 0.288); | ||
| } | ||
|
|
||
| .periodHeading{} | ||
| .periodSection{} |
This file contains hidden or 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,36 @@ | ||
| import styles from './page.module.scss' | ||
| import { PeriodSection } from './periodTableSection' | ||
| import getCommittee from '@/app/committees/[shortName]/getCommittee' | ||
| import { unwrapActionReturn } from '@/app/redirectToErrorPage' | ||
| import { readCommitteeParticipatingPeriodAction } from '@/services/applications/committeeParticipation/actions' | ||
|
|
||
| export type PropTypes = { | ||
| params: Promise<{ | ||
| shortName: string | ||
| }> | ||
| } | ||
|
|
||
|
|
||
| export default async function PeriodeCommitteePage({ params }: PropTypes) { | ||
|
HaakonMikalsen marked this conversation as resolved.
Outdated
|
||
| const committee = await getCommittee(params) | ||
| const shortName = (await params).shortName | ||
| const committeePeriodes = unwrapActionReturn( | ||
| await readCommitteeParticipatingPeriodAction({ params: { committeeId: committee.id } }) | ||
| ).sort((a, b) => b.startDate.getTime() - a.startDate.getTime()) | ||
| if (committeePeriodes.length === 0) { return 'ingen søknadsperioder funnet' } | ||
| return ( | ||
| <table className={styles.periodTable}> | ||
| <tr className={styles.periodHeading}> | ||
| <th className={styles.tableEntry}>Start dato</th> | ||
| <th className={styles.tableEntry}>Slutt dato</th> | ||
| <th className={styles.tableEntry}>Omprioritering slutt dato</th> | ||
| <th className={styles.tableEntry}>Søknader</th> | ||
| <th className={styles.tableEntry}>Søknadstall</th> | ||
| </tr> | ||
| {committeePeriodes.map((period, index) => ( | ||
| <PeriodSection shortName={shortName} key={index} period={period}></PeriodSection> | ||
| )) | ||
| } | ||
| </table > | ||
| ) | ||
| } | ||
42 changes: 42 additions & 0 deletions
42
src/app/committees/[shortName]/periodes/periodTableSection.tsx
This file contains hidden or 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,42 @@ | ||
| 'use client' //Use client to show user correct local time | ||
| import styles from './page.module.scss' | ||
| import { useState } from 'react' | ||
| import Link from 'next/link' | ||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
| import { faLink } from '@fortawesome/free-solid-svg-icons' | ||
|
|
||
| type periodType = { | ||
| participationId: number; | ||
| applicationCount: number; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| endPriorityDate: Date; | ||
| } | ||
|
|
||
| export function PeriodSection({ period, shortName }: { period: periodType, shortName: string }) { | ||
| const [now] = useState(() => Date.now()) | ||
|
HaakonMikalsen marked this conversation as resolved.
Outdated
|
||
| const isCurrentPeriod = (now > period.startDate.getTime()) && (now < period.endPriorityDate.getTime()) | ||
| const entriesClassName = `${styles.tableEntry} ${isCurrentPeriod && styles.currentPeriodEntry}` | ||
| return ( | ||
| <tr className={styles.periodSection}> | ||
| <td className={entriesClassName} > | ||
| {period.startDate.toLocaleDateString('en-GB')}, | ||
| kl: {period.startDate.toLocaleTimeString('en-GB')} | ||
| </td> | ||
| <td className={entriesClassName} > | ||
| {period.endDate.toLocaleDateString('en-GB')}, | ||
| kl: {period.endDate.toLocaleTimeString('en-GB')} | ||
| </td> | ||
| <td className={entriesClassName} > | ||
| {period.endPriorityDate.toLocaleDateString('en-GB')}, | ||
| kl: {period.endPriorityDate.toLocaleTimeString('en-GB')} | ||
| </td> | ||
| <td className={entriesClassName} > <Link href={`/committees/${shortName}/periodes/${period.participationId}`} > | ||
| <FontAwesomeIcon icon={faLink}> | ||
| </FontAwesomeIcon> | ||
| </Link> | ||
| </td> | ||
| <td className={entriesClassName} >{period.applicationCount}</td> | ||
| </tr> | ||
| ) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.