Skip to content

Commit

Permalink
style: lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanHjelsethStorstad committed Oct 9, 2024
1 parent bd7c130 commit 20b5dda
Show file tree
Hide file tree
Showing 20 changed files with 92 additions and 98 deletions.
4 changes: 1 addition & 3 deletions src/actions/events/read.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use server'
import { ActionNoData } from '@/actions/Action'
import { safeServerCall } from '@/actions/safeServerCall'
import { Session } from '@/auth/Session'
import { Events } from '@/services/events'
import type { ReadPageInput } from '@/services/paging/Types'
import type { EventArchiveCursor, EventArchiveDetails } from '@/services/events/Types'
import { ActionNoData } from '../Action'

export const readCurrentEventsAction = ActionNoData(Events.readCurrent)

Expand Down
6 changes: 3 additions & 3 deletions src/actions/events/tags/destroy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use server'
import { ActionNoData } from "@/actions/Action"
import { EventTags } from "@/services/events/tags"
import { ActionNoData } from '@/actions/Action'
import { EventTags } from '@/services/events/tags'

export const destroyEventTagAction = ActionNoData(EventTags.destroy)
export const destroyEventTagAction = ActionNoData(EventTags.destroy)
2 changes: 1 addition & 1 deletion src/app/_components/Event/EventCard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styles from './EventCard.module.scss'
import SmallEventTag from './SmallEventTag'
import Image from '@/components/Image/Image'
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCalendar, faUsers } from '@fortawesome/free-solid-svg-icons'
import Link from 'next/link'
import type { EventExpanded } from '@/services/events/Types'
import SmallEventTag from './SmallEventTag'

type PropTypes = {
event: EventExpanded
Expand Down
38 changes: 17 additions & 21 deletions src/app/_components/Event/EventTagsAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import TextInput from '@/UI/TextInput'
import Textarea from '@/UI/Textarea'
import ColorInput from '@/UI/ColorInput'
import { updateEventTagAction } from '@/actions/events/tags/update'
import type { EventTag as EventTagT } from '@prisma/client'
import Link from 'next/link'
import { QueryParams } from '@/lib/query-params/queryParams'
import { destroyEventTagAction } from '@/actions/events/tags/destroy'
import Link from 'next/link'
import type { EventTag as EventTagT } from '@prisma/client'

type PropTypes = {
eventTags: EventTagT[]
Expand Down Expand Up @@ -38,18 +38,14 @@ export default function EventTagsAdmin({
}: PropTypes) {
const baseUrl = page === 'EVENT' ? '/events' : '/events/archive'

const removeFromUrl = (tag: string) => {
return selectedTags.length === 1 ?
baseUrl :
baseUrl + QueryParams.eventTags.encodeUrl(
selectedTags.filter(t => t.name !== tag).map(t => t.name)
)
}
const addToUrl = (tag: string) => {
return baseUrl + QueryParams.eventTags.encodeUrl(
[...selectedTags.map(t => t.name), tag]
)
}
const removeFromUrl = (tag: string) => (selectedTags.length === 1 ?
baseUrl :
baseUrl + QueryParams.eventTags.encodeUrl(
selectedTags.filter(t => t.name !== tag).map(t => t.name)
))
const addToUrl = (tag: string) => baseUrl + QueryParams.eventTags.encodeUrl(
[...selectedTags.map(t => t.name), tag]
)
return (
<div className={styles.EventTagsAdmin}>
<h1>Tagger</h1>
Expand All @@ -68,17 +64,17 @@ export default function EventTagsAdmin({
{
eventTags.map((tag, index) => (
<li key={index} >
<Link
className={selectedTags.map(tag => tag.name).includes(tag.name) ? styles.selected : ''}
<Link
className={selectedTags.map(t => t.name).includes(tag.name) ? styles.selected : ''}
href={
selectedTags.map(tag => tag.name).includes(tag.name) ?
removeFromUrl(tag.name) : addToUrl(tag.name)
selectedTags.map(t => t.name).includes(tag.name) ?
removeFromUrl(tag.name) : addToUrl(tag.name)
}
>
<EventTag eventTag={tag} />
</Link>
{
canUpdate || canDestroy ? (
canUpdate || canDestroy ? (
<SettingsHeaderItemPopUp scale={25} PopUpKey={`EventTagPopUp${tag.id}`}>
{canUpdate && <span className={styles.update}>
<Form
Expand Down Expand Up @@ -112,12 +108,12 @@ export default function EventTagsAdmin({
<Form
refreshOnSuccess
action={destroyEventTagAction.bind(null, { id: tag.id })}
submitColor='red'
submitColor="red"
confirmation={{
confirm: true,
text: 'Er du sikker på at du vil slette denne taggen?'
}}
submitText='Slett'
submitText="Slett"
/>
</span>
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/_components/Event/SmallEventTag.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { faTag } from "@fortawesome/free-solid-svg-icons"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { EventTag } from "@prisma/client"
import styles from './SmallEventTag.module.scss'
import { faTag } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import type { EventTag } from '@prisma/client'

type PropTypes = {
eventTag: EventTag
Expand Down
6 changes: 3 additions & 3 deletions src/app/_components/UI/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ type PropTypes = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> & {
}

/**
*
*
* @param label - The label shown to user (optional)
* @param children - If given, the children will be clickable as part of checkbox
* @returns
* @returns
*/
function Checkbox({ label, children, ...props }: PropTypes) {
props.id ??= `id_input_${uuid()}`
Expand All @@ -26,7 +26,7 @@ function Checkbox({ label, children, ...props }: PropTypes) {
{ children }
{label ? label : <></>}
</label>
) : (
) : (
<>
<input type="checkbox" {...props} />
{label && <label htmlFor={props.id}>{ label }</label>}
Expand Down
12 changes: 6 additions & 6 deletions src/app/_components/UI/ColorInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ export type PropTypes = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> & {

const rgbToHex = (r: number, g: number, b: number): string => {
const toHex = (value: number) => {
const hex = value.toString(16);
return hex.length === 1 ? '0' + hex : hex;
};
const hex = value.toString(16)
return hex.length === 1 ? `0${hex}` : hex
}

return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
};
return `#${toHex(r)}${toHex(g)}${toHex(b)}`
}

/**
* A component for selecting a color. Uses the HTML input type color and native browser color picker.
* @param label - the label of the input (displayed to user)
* @param className - the class name of the input
* @param defaultValueRGB - the default value of the input in RGB format
* @prop name - the name of the input
* @returns
* @returns
*/
export default function ColorInput({ label, className, defaultValueRGB, ...props }: PropTypes) {
if (defaultValueRGB) {
Expand Down
34 changes: 17 additions & 17 deletions src/app/events/CreateOrUpdateEventForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use client'
import styles from './CreateOrUpdateEventForm.module.scss'
import Checkbox from '@/components/UI/Checkbox'
import { SelectString } from '@/components/UI/Select'
import DateInput from '@/components/UI/DateInput'
import Slider from '@/components/UI/Slider'
Expand All @@ -8,12 +10,10 @@ import TextInput from '@/components/UI/TextInput'
import { CanBeViewdByOptions } from '@/services/events/ConfigVars'
import { updateEventAction } from '@/actions/events/update'
import { createEventAction } from '@/actions/events/create'
import EventTag from '@/components/Event/EventTag'
import { useState } from 'react'
import type { Event, EventTag as EventTagT } from '@prisma/client'
import type { ChangeEvent } from 'react'
import EventTag from '@/components/Event/EventTag'
import styles from './CreateOrUpdateEventForm.module.scss'
import Checkbox from '../_components/UI/Checkbox'

type PropTypes = {
event?: Event & { tags: EventTagT[] }
Expand Down Expand Up @@ -58,20 +58,20 @@ export default function CreateOrUpdateEventForm({ event, eventTags }: PropTypes)
<DateInput label="Start" name="eventStart" includeTime defaultValue={event?.eventStart}/>
<DateInput label="Slutt" name="eventEnd" includeTime defaultValue={event?.eventEnd}/>
<ul className={styles.tags}>
<h2>Tags</h2>
{
eventTags.map(tag => (
<li key={tag.id}>
<Checkbox
name="tagIds"
value={tag.id}
defaultChecked={event ? event.tags.map(t => t.name).includes(tag.name) : false}
>
<EventTag eventTag={tag} />
</Checkbox>
</li>
))
}
<h2>Tags</h2>
{
eventTags.map(tag => (
<li key={tag.id}>
<Checkbox
name="tagIds"
value={tag.id}
defaultChecked={event ? event.tags.map(t => t.name).includes(tag.name) : false}
>
<EventTag eventTag={tag} />
</Checkbox>
</li>
))
}
</ul>
<Slider
label="Med registrering"
Expand Down
10 changes: 5 additions & 5 deletions src/app/events/EventsLandingLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styles from './EventsLandingLayout.module.scss'
import EventTag from '@/components/Event/EventTag'
import { QueryParams } from '@/lib/query-params/queryParams'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Link from 'next/link'
import type { EventTag as EventTagT } from '@prisma/client'
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
import type { ReactNode } from 'react'
import { EventTag as EventTagT } from '@prisma/client'
import EventTag from '@/components/Event/EventTag'
import { QueryParams } from '@/lib/query-params/queryParams'

type PropTypes = {
headerLinks: {
Expand All @@ -32,12 +32,12 @@ export default function EventsLandingLayout({
<h1>{title}</h1>
{
selectedTags?.map(tag =>
<Link href={selectedTags.length === 1 ? '/events' :
<Link key={tag.name} href={selectedTags.length === 1 ? '/events' :
`/events/${QueryParams.eventTags.encodeUrl(
selectedTags.filter(t => t.name !== tag.name).map(t => t.name)
)}`
}>
<EventTag key={tag.name} eventTag={tag} />
<EventTag eventTag={tag} />
</Link>
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/events/TagHeaderItem.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import { TagHeasderItemPopUp } from '@/components/HeaderItems/HeaderItemPopUp'
import PopUpProvider from '@/contexts/PopUp'
import EventTagsAdmin from '@/components/Event/EventTagsAdmin'
import { EventTag } from '@prisma/client'
import React from 'react'
import type { EventTag } from '@prisma/client'

type PropTypes = {
eventTags: EventTag[],
Expand Down
7 changes: 3 additions & 4 deletions src/app/events/[order]/[name]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import Form from '@/components/Form/Form'
import EventTag from '@/components/Event/EventTag'
import { destroyEvent } from '@/actions/events/destroy'
import { SettingsHeaderItemPopUp } from '@/app/_components/HeaderItems/HeaderItemPopUp'
import { faCalendar, faExclamation, faUsers } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { readEventTagsAction } from '@/actions/events/tags/read'
import { QueryParam } from '@/lib/query-params/QueryParam'
import { QueryParams } from '@/lib/query-params/queryParams'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCalendar, faExclamation, faUsers } from '@fortawesome/free-solid-svg-icons'
import Link from 'next/link'

type PropTypes = {
Expand Down Expand Up @@ -44,7 +43,7 @@ export default async function Event({ params }: PropTypes) {
<ul className={styles.tags}>
{event.tags.map(tag => (
<li key={tag.id}>
<Link href={'/events' + QueryParams.eventTags.encodeUrl([tag.name])}>
<Link href={`/events${QueryParams.eventTags.encodeUrl([tag.name])}`}>
<EventTag eventTag={tag} />
</Link>
</li>
Expand Down
18 changes: 9 additions & 9 deletions src/app/events/archive/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { readEventTagsAction } from '@/actions/events/tags/read'
import EventArchiveList from './EventArchiveList'
import TagHeaderItem from '@/app/events/TagHeaderItem'
import { readEventTagsAction } from '@/actions/events/tags/read'
import EventsLandingLayout from '@/app/events/EventsLandingLayout'
import EventArchivePagingProvider from '@/contexts/paging/EventArchivePaging'
import { QueryParams } from '@/lib/query-params/queryParams'
import { SearchParamsServerSide } from '@/lib/query-params/Types'
import { faArrowLeft } from '@fortawesome/free-solid-svg-icons'
import { CreateEventTagAuther, DestroyEventTagAuther, UpdateEventTagAuther } from '@/services/events/tags/Authers'
import TagHeaderItem from '../TagHeaderItem'
import { faArrowLeft } from '@fortawesome/free-solid-svg-icons'
import type { SearchParamsServerSide } from '@/lib/query-params/Types'

type PropTypes = SearchParamsServerSide

Expand All @@ -32,13 +32,13 @@ export default async function EventArchive({
icon: faArrowLeft
}
]} headerItem={
<TagHeaderItem
canCreate={canCreate.authorized}
canUpdate={canUpdate.authorized}
<TagHeaderItem
canCreate={canCreate.authorized}
canUpdate={canUpdate.authorized}
canDestroy={canDestroy.authorized}
currentTags={selectedTags}
currentTags={selectedTags}
eventTags={eventTags}
page='EVENT_ARCHIVE'
page="EVENT_ARCHIVE"
/>
} selectedTags={selectedTags}>
<EventArchivePagingProvider serverRenderedData={[]} startPage={{
Expand Down
18 changes: 9 additions & 9 deletions src/app/events/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import styles from './page.module.scss'
import CreateOrUpdateEventForm from './CreateOrUpdateEventForm'
import EventsLandingLayout from './EventsLandingLayout'
import TagHeaderItem from './TagHeaderItem'
import { AddHeaderItemPopUp } from '@/components/HeaderItems/HeaderItemPopUp'
import { readCurrentEventsAction } from '@/actions/events/read'
import EventCard from '@/components/Event/EventCard'
import { readEventTagsAction } from '@/actions/events/tags/read'
import { CreateEventTagAuther, DestroyEventTagAuther, UpdateEventTagAuther } from '@/services/events/tags/Authers'
import { faArchive } from '@fortawesome/free-solid-svg-icons'
import { SearchParamsServerSide } from '@/lib/query-params/Types'
import { QueryParams } from '@/lib/query-params/queryParams'
import TagHeaderItem from './TagHeaderItem'
import { faArchive } from '@fortawesome/free-solid-svg-icons'
import type { SearchParamsServerSide } from '@/lib/query-params/Types'

type PropTypes = SearchParamsServerSide

Expand Down Expand Up @@ -42,13 +42,13 @@ export default async function Events({
selectedTags={currentTags}
headerItem={
<>
<TagHeaderItem
eventTags={eventTags}
currentTags={currentTags}
canUpdate={canUpdate.authorized}
canCreate={canCreate.authorized}
<TagHeaderItem
eventTags={eventTags}
currentTags={currentTags}
canUpdate={canUpdate.authorized}
canCreate={canCreate.authorized}
canDestroy={canDestroy.authorized}
page='EVENT'
page="EVENT"
/>
<AddHeaderItemPopUp PopUpKey="CreateEventPopUp">
<div className={styles.createEvent}>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/query-params/QueryParam.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SearchParamsServerSide } from "./Types"
import type { SearchParamsServerSide } from './Types'

export abstract class QueryParam<Type> {
public name: string
Expand Down Expand Up @@ -51,4 +51,4 @@ export class StringArrayQueryParam extends QueryParam<string[]> {
}
return null
}
}
}
4 changes: 2 additions & 2 deletions src/lib/query-params/decoders.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SearchParamsServerSide } from "./Types"
import type { SearchParamsServerSide } from './Types'

export const stringDecoder = (raw: SearchParamsServerSide['searchParams']) => {
if (typeof raw !== 'string') {
Expand All @@ -12,4 +12,4 @@ export const stringArrayDecoder = (raw: SearchParamsServerSide['searchParams'])
return null
}
return raw
}
}
Loading

0 comments on commit 20b5dda

Please sign in to comment.