-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from vevcom/feat/dots
Feat/User Profile Admin Pages and Dots 1
- Loading branch information
Showing
88 changed files
with
1,529 additions
and
284 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 @@ | ||
'use server' | ||
import { Action } from '@/actions/Action' | ||
import { Dots } from '@/services/dots' | ||
|
||
export const createDotAction = Action(Dots.create) |
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,7 @@ | ||
'use server' | ||
import { ActionNoData } from '@/actions/Action' | ||
import { Dots } from '@/services/dots' | ||
|
||
export const readDotPage = ActionNoData(Dots.readPage) | ||
|
||
export const readDotWrapperForUser = ActionNoData(Dots.readWrapperForUser) |
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
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,15 @@ | ||
'use client' | ||
import { displayDate } from '@/dates/displayDate' | ||
|
||
type PropTypes = { | ||
date: Date | ||
} | ||
|
||
/** | ||
* Just a wrapper for the displayDate function. Importantly it is client side rendered to use the client's timezone. | ||
* @param date - The date to display | ||
* @returns the date in jsx | ||
*/ | ||
export default function Date({ date }: PropTypes) { | ||
return displayDate(date) | ||
} |
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 |
---|---|---|
|
@@ -23,7 +23,8 @@ | |
height: 25px; | ||
} | ||
&.magicHat { | ||
> * { | ||
position: relative; | ||
> .image { | ||
filter: invert(1); | ||
} | ||
} | ||
|
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
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,84 @@ | ||
@use '@/styles/ohma'; | ||
|
||
.UserNavigation { | ||
@include ohma.screenLg { | ||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
transform: translateY(calc(100% + .5em)); | ||
min-width: 300px; | ||
max-height: 90vh; | ||
@include ohma.boxShadow(); | ||
@include ohma.round(); | ||
} | ||
@include ohma.screenMobile { | ||
z-index: -1; | ||
padding: 1em; | ||
padding-top: 3em; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: calc(100vh - 50px); | ||
} | ||
background-color: ohma.$colors-gray-200; | ||
h2 { | ||
color: ohma.$colors-black; | ||
font-size: ohma.$fonts-xl; | ||
} | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
.logout { | ||
margin-top: .5em; | ||
width: 100%; | ||
> button { | ||
width: 100%; | ||
margin: 0; | ||
} | ||
} | ||
|
||
.navs { | ||
margin-top: 1em; | ||
width: 100%; | ||
display: flex; | ||
flex-flow: row wrap; | ||
gap: 1em; | ||
> * { | ||
flex: 1 1 calc(50% - 1em); | ||
@include ohma.round(); | ||
background-color: ohma.$colors-secondary; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
text-decoration: none; | ||
color: ohma.$colors-white; | ||
transition: color .6s; | ||
svg { | ||
width: 20px; | ||
height: 20px; | ||
color: ohma.$colors-white; | ||
transition: color .6s; | ||
margin: .3em; | ||
} | ||
&:hover { | ||
color: ohma.$colors-black; | ||
svg { | ||
color: ohma.$colors-black; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
.hidden { | ||
opacity: 0; | ||
width: 100%; | ||
height: 100%; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
} |
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,67 @@ | ||
'use client' | ||
import styles from './UserNavigation.module.scss' | ||
import ProfilePicture from '@/components/User/ProfilePicture' | ||
import BorderButton from '@/UI/BorderButton' | ||
import useClickOutsideRef from '@/hooks/useClickOutsideRef' | ||
import useOnNavigation from '@/hooks/useOnNavigation' | ||
import { faCog, faDotCircle, faMoneyBill, faSignOut, faUser } from '@fortawesome/free-solid-svg-icons' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import Link from 'next/link' | ||
import { useState } from 'react' | ||
import type { Profile } from '@/services/users/Types' | ||
|
||
type PropTypes = { | ||
profile: Profile | null | ||
} | ||
|
||
/** | ||
* This component either renders an empty link with a href to /login page if there is no profile | ||
* Else it renders a usefull component for a logged in user. | ||
* @param profile - The profile of the user | ||
* @returns | ||
*/ | ||
export default function UserNavigation({ profile }: PropTypes) { | ||
const [isMenuOpen, setIsMenuOpen] = useState(false) | ||
const ref = useClickOutsideRef(() => setIsMenuOpen(false)) | ||
useOnNavigation(() => setIsMenuOpen(false)) | ||
|
||
if (!profile || !profile.user) { | ||
return <Link className={styles.hidden} href="/login" /> | ||
} | ||
|
||
if (!isMenuOpen) { | ||
return <button className={styles.hidden} onClick={() => setIsMenuOpen(!isMenuOpen)} /> | ||
} | ||
|
||
return ( | ||
<div ref={ref} className={styles.UserNavigation}> | ||
<ProfilePicture profileImage={profile.user.image} width={180} /> | ||
<h2>{profile.user.firstname} {profile.user.lastname}</h2> | ||
|
||
<Link href="/logout" className={styles.logout}> | ||
<BorderButton color="secondary"> | ||
<FontAwesomeIcon icon={faSignOut} /> <p>Logg ut</p> | ||
</BorderButton> | ||
</Link> | ||
|
||
<div className={styles.navs}> | ||
<Link href="/users/me"> | ||
<FontAwesomeIcon icon={faUser} /> | ||
<p>Profil</p> | ||
</Link> | ||
<Link href="/users/me/dots"> | ||
<FontAwesomeIcon icon={faDotCircle} /> | ||
<p>Prikker</p> | ||
</Link> | ||
<Link href="/users/me/money"> | ||
<FontAwesomeIcon icon={faMoneyBill} /> | ||
<p>Konto</p> | ||
</Link> | ||
<Link href="/users/me/settings"> | ||
<FontAwesomeIcon icon={faCog} /> | ||
<p>Instillinger</p> | ||
</Link> | ||
</div> | ||
</div> | ||
) | ||
} |
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,14 @@ | ||
@use '@/styles/ohma'; | ||
|
||
.ProfilePicture { | ||
display: flex; | ||
justify-content: center; | ||
|
||
.image { | ||
border-radius: 50%; | ||
border: 3px solid ohma.$colors-white; | ||
background-color: ohma.$colors-white; | ||
aspect-ratio: 1; | ||
object-fit: cover; | ||
} | ||
} |
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,16 @@ | ||
import styles from './ProfilePicture.module.scss' | ||
import Image from '@/components/Image/Image' | ||
import type { Image as ImageT } from '@prisma/client' | ||
|
||
type PropTypes = { | ||
profileImage: ImageT, | ||
width: number, | ||
} | ||
|
||
export default function ProfilePicture({ profileImage, width }: PropTypes) { | ||
return ( | ||
<div className={styles.ProfilePicture}> | ||
<Image className={styles.image} image={profileImage} width={width}/> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.