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

Add: information about prikk #5316

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions app/routes/users/components/UserProfile/Penalties.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,16 @@
height: 1px;
background-color: var(--border-gray);
}

.cardContainer {
display: flex;
flex-direction: column;
position: relative;
}

.infoIcon {
position: absolute;
top: 0px;
right: 0px;
color: black;
ch0rizo marked this conversation as resolved.
Show resolved Hide resolved
}
129 changes: 70 additions & 59 deletions app/routes/users/components/UserProfile/Penalties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { useAppDispatch, useAppSelector } from 'app/store/hooks';
import styles from './Penalties.module.css';
import PenaltyForm from './PenaltyForm';
import type { EntityId } from '@reduxjs/toolkit';
import { Heading1, icons } from 'lucide-react';
import { Link } from 'react-router-dom';

type Props = {
userId: EntityId;
Expand All @@ -27,69 +29,78 @@ const Penalties = ({ userId }: Props) => {

return (
<ProfileSection title="Prikker">
{penalties.length ? (
<>
{penalties.map((penalty, index) => (
<>
<Flex key={penalty.id} column gap="var(--spacing-sm)">
<span className={styles.weight}>
{penalty.weight} {penalty.weight > 1 ? 'prikker' : 'prikk'}
</span>
<LinkInfoField
name="Fra arragement"
to={`/events/${
penalty.sourceEvent.slug || penalty.sourceEvent.id
}`}
>
{penalty.sourceEvent.title}
</LinkInfoField>
<InfoField name="Begrunnelse">{penalty.reason}</InfoField>
<InfoField name="Utgår">
<FormatTime
time={penalty.exactExpiration}
className={cx('secondaryFontColor', styles.time)}
/>
</InfoField>

{canDeletePenalties && (
<ConfirmModal
title="Slett prikk"
message="Er du sikker på at du vil slette denne prikken?"
onConfirm={() => {
dispatch(deletePenalty(penalty.id));
}}
closeOnConfirm
<div className={styles.cardContainer}>
{penalties.length ? (
<>
{penalties.map((penalty, index) => (
<>
<Flex key={penalty.id} column gap="var(--spacing-sm)">
<span className={styles.weight}>
{penalty.weight} {penalty.weight > 1 ? 'prikker' : 'prikk'}
</span>
<LinkInfoField
name="Fra arragement"
to={`/events/${
penalty.sourceEvent.slug || penalty.sourceEvent.id
}`}
>
{({ openConfirmModal }) => (
<Button danger onPress={openConfirmModal}>
Slett prikk
</Button>
)}
</ConfirmModal>
{penalty.sourceEvent.title}
</LinkInfoField>
<InfoField name="Begrunnelse">{penalty.reason}</InfoField>
<InfoField name="Utgår">
<FormatTime
time={penalty.exactExpiration}
className={cx('secondaryFontColor', styles.time)}
/>
</InfoField>

{canDeletePenalties && (
<ConfirmModal
title="Slett prikk"
message="Er du sikker på at du vil slette denne prikken?"
onConfirm={() => {
dispatch(deletePenalty(penalty.id));
}}
closeOnConfirm
>
{({ openConfirmModal }) => (
<Button danger onPress={openConfirmModal}>
Slett prikk
</Button>
)}
</ConfirmModal>
)}
</Flex>

{index !== penalties.length - 1 && (
<div className={styles.divider} />
)}
</>
))}
</>
) : (
<>
<Flex alignItems="center" gap="var(--spacing-md)">
<Icon
name="thumbs-up-outline"
size={40}
className={styles.success}
/>
<Flex column className={cx('secondaryFontColor', styles.info)}>
<span>Puh ...</span>
<span>Du har ingen prikker!</span>
</Flex>

{index !== penalties.length - 1 && (
<div className={styles.divider} />
)}
</>
))}
</>
) : (
<>
<Flex alignItems="center" gap="var(--spacing-md)">
<Icon
name="thumbs-up-outline"
size={40}
className={styles.success}
/>
<Flex column className={cx('secondaryFontColor', styles.info)}>
<span>Puh ...</span>
<span>Du har ingen prikker!</span>
</Flex>
</Flex>
</>
)}
</>
)}
<a href={`https://abakus.no/pages/arrangementer/26-arrangementsregler`}>
ch0rizo marked this conversation as resolved.
Show resolved Hide resolved
<Icon
name="information-circle-outline"
size={25}
className={styles.infoIcon}
/>
</a>
</div>

<PenaltyForm userId={userId} />
</ProfileSection>
Expand Down