Skip to content
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
1 change: 1 addition & 0 deletions projectNext
Submodule projectNext added at c7b2f2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use client'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be uppercased and have he same name as the function it exports

import { updateUserAction } from '@/services/users/actions'
import Form from '@/app/_components/Form/Form'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@/components

import Checkbox from '@/app/_components/UI/Checkbox'
import { configureAction } from '@/services/configureAction'


export default function RegisterKioleskapLeaderboard({
userId,
kioleskapLead,
}: {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use PropTypes semantics

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think (if this is a separate form) that the form name should include the word consent

userId: number,
kioleskapLead: boolean,
}) {
return <Form
action={configureAction(updateUserAction, { params: { id: userId } })}
submitText="Oppdater innstilling over"
>
<Checkbox name="kioleskapLead" defaultChecked={kioleskapLead}>Jeg vil vises på Kioleskapets leaderboard</Checkbox>
</Form>
}
4 changes: 4 additions & 0 deletions src/app/users/[username]/(user-admin)/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import RegisterKioleskapLeaderboard from './kioleskapLeaderboard'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

import UserSettingsForm from './UserProfileSettingsForm'
import { getProfileForAdmin } from '@/app/users/[username]/(user-admin)/getProfileForAdmin'
import Image from '@/components/Image/Image'
Expand All @@ -18,6 +20,8 @@ export default async function UserSettings({ params }: PropTypes) {
{/* TODO: add Email registration form and admin user settings */},.
<h2>Generelle Instillinger</h2>
<Image width={300} image={profile.user.image} />

<RegisterKioleskapLeaderboard userId={profile.user.id} kioleskapLead={profile.user.kioleskapLead} />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this form anyways just calls the updateUserAction the form should probably be for all updateable user fields and not its own form. I.e. all fields updateable through updateUser should be in the same form

</div>
)
}
13 changes: 7 additions & 6 deletions src/prisma/schema/ombul.prisma
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
model Ombul {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
name String
description String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
fsLocation String @unique //location in /store/ombul/[fsLocation]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
fsLocation String @unique //location in /store/ombul/[fsLocation]
year Int
issueNumber Int
coverImage CmsImage @relation(fields: [coverImageId], references: [id], onDelete: Cascade)
coverImageId Int @unique
coverImage CmsImage @relation(fields: [coverImageId], references: [id], onDelete: Cascade)
coverImageId Int @unique

@@unique([year, name])
@@unique([year, issueNumber])
}

2 changes: 2 additions & 0 deletions src/prisma/schema/user.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ model User {
memberships Membership[]
credentials Credentials?
feideAccount FeideAccount?
kioleskapLead Boolean @default(false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this field name is non-descriptive. It should at least include the word consent. Also: avoid abbreviating the name.


notificationSubscriptions NotificationSubscription[]
mailingLists MailingListUser[]
Expand All @@ -41,6 +42,7 @@ model User {
Event Event[]

cabinBooking Booking[] @relation()


// We need to explicitly mark the combination of 'id', 'username' and 'email' as
// unique to make the relation to 'Credentials' work.
Expand Down
1 change: 1 addition & 0 deletions src/services/users/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const userOperations = {
...userFilterSelection,
bio: true,
image: true,
kioleskapLead: true,
memberships: {
where: {
OR: [
Expand Down
7 changes: 6 additions & 1 deletion src/services/users/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ export const userSchema = z.object({
allergies: z.string().max(150).optional().nullable(),
bio: z.string().max(2047).optional(),
studentCard: studentCardSchema,
kioleskapLead: Zpn.checkboxOrBoolean({
label: 'leaderboard'
}),
password: z.string().max(50).min(12, {
// eslint-disable-next-line
message: 'Passoret må minst ha 12 tegn, en stor og en liten bokstav, et tall, en rune, to emojier, en musikk note, en magisk sopp og en dråpe smørekopp-blod (avsky).'
message: 'Passordet må minst ha 12 tegn, en stor og en liten bokstav, et tall, en rune, to emojier, en musikk note, en magisk sopp og en dråpe smørekopp-blod (avsky).'
}),
confirmPassword: z.string().max(50).min(12),
imageConsent: Zpn.checkboxOrBoolean({
Expand Down Expand Up @@ -46,6 +49,8 @@ export const userSchemas = {
firstname: true,
lastname: true,
username: true,
kioleskapLead: true,

mobile: true,
allergies: true,
sex: true,
Expand Down
Loading