Skip to content

Commit 6859d0e

Browse files
committed
Fjern alle references til combinedTiles, isCombinedTiles nå obligatorisk
1 parent 0560ed1 commit 6859d0e

152 files changed

Lines changed: 1353 additions & 4007 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tavla/.prettierignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

tavla/.prettierrc.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

tavla/app/(admin)/actions.ts

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use server'
22
import * as Sentry from '@sentry/nextjs'
3-
import { Folder } from 'app/(admin)/utils/types'
3+
import type { Folder } from 'app/(admin)/utils/types'
44
import { FieldPath, getFirestore } from 'firebase-admin/firestore'
55
import { chunk, isEmpty } from 'lodash'
66
import { redirect } from 'next/navigation'
77
import { getFolder } from 'src/firebase'
8-
import { BoardDB, BoardDBSchema } from 'src/types/db-types/boards'
9-
import { FolderDB, FolderDBSchema } from 'src/types/db-types/folders'
10-
import { UserDB } from 'src/types/db-types/users'
8+
import { type BoardDB, BoardDBSchema } from 'src/types/db-types/boards'
9+
import { type FolderDB, FolderDBSchema } from 'src/types/db-types/folders'
10+
import type { UserDB } from 'src/types/db-types/users'
1111
import { FIREBASE_DEV_CONFIG, FIREBASE_PRD_CONFIG } from './utils/constants'
1212
import { getUserWithBoardIds, initializeAdminApp } from './utils/firebase'
1313
import { getUserFromSessionCookie } from './utils/server'
@@ -23,7 +23,7 @@ export async function getFirebaseClientConfig() {
2323
}
2424

2525
function userInFolder(uid?: UserDB['uid'], folder?: FolderDB) {
26-
return uid && folder && folder.owners?.includes(uid)
26+
return uid && folder?.owners?.includes(uid)
2727
}
2828

2929
export async function getFolderIfUserHasAccess(folderid?: FolderDB['id']) {
@@ -54,8 +54,7 @@ export async function getFoldersForUser(): Promise<Folder[]> {
5454

5555
const queries = await Promise.all([owner])
5656
const folders = queries
57-
.map((query) => query.docs)
58-
.flat()
57+
.flatMap((query) => query.docs)
5958
.map((folderDocument) => {
6059
const folderData = {
6160
...folderDocument.data(),
@@ -143,31 +142,29 @@ export async function getBoardsForFolder(folderid: FolderDB['id']) {
143142

144143
const boardRefs = await Promise.all(boardQueries)
145144

146-
return boardRefs
147-
.map((ref) =>
148-
ref.docs.map((doc) => {
149-
const boardData = { id: doc.id, ...doc.data() }
150-
const parsedBoard = BoardDBSchema.safeParse(boardData)
151-
152-
if (!parsedBoard.success) {
153-
Sentry.captureMessage(
154-
'Board data validation failed in getBoardsForFolder',
155-
{
156-
level: 'warning',
157-
extra: {
158-
error: parsedBoard.error.flatten(),
159-
boardId: doc.id,
160-
folderID: folderid,
161-
},
145+
return boardRefs.flatMap((ref) =>
146+
ref.docs.map((doc) => {
147+
const boardData = { id: doc.id, ...doc.data() }
148+
const parsedBoard = BoardDBSchema.safeParse(boardData)
149+
150+
if (!parsedBoard.success) {
151+
Sentry.captureMessage(
152+
'Board data validation failed in getBoardsForFolder',
153+
{
154+
level: 'warning',
155+
extra: {
156+
error: parsedBoard.error.flatten(),
157+
boardId: doc.id,
158+
folderID: folderid,
162159
},
163-
)
164-
return boardData as BoardDB
165-
}
160+
},
161+
)
162+
return boardData as BoardDB
163+
}
166164

167-
return parsedBoard.data
168-
}),
169-
)
170-
.flat()
165+
return parsedBoard.data
166+
}),
167+
)
171168
} catch (error) {
172169
Sentry.captureMessage(
173170
'Error while fetching boards for folder with folderID ' + folderid,
@@ -189,30 +186,28 @@ export async function getBoards(ids?: BoardDB['id'][]) {
189186
)
190187

191188
const refs = await Promise.all(queries)
192-
return refs
193-
.map((ref) =>
194-
ref.docs.map((doc) => {
195-
const boardData = { id: doc.id, ...doc.data() }
196-
const parsedBoard = BoardDBSchema.safeParse(boardData)
197-
198-
if (!parsedBoard.success) {
199-
Sentry.captureMessage(
200-
'Board data validation failed in getBoards',
201-
{
202-
level: 'warning',
203-
extra: {
204-
error: parsedBoard.error.flatten(),
205-
boardId: doc.id,
206-
},
189+
return refs.flatMap((ref) =>
190+
ref.docs.map((doc) => {
191+
const boardData = { id: doc.id, ...doc.data() }
192+
const parsedBoard = BoardDBSchema.safeParse(boardData)
193+
194+
if (!parsedBoard.success) {
195+
Sentry.captureMessage(
196+
'Board data validation failed in getBoards',
197+
{
198+
level: 'warning',
199+
extra: {
200+
error: parsedBoard.error.flatten(),
201+
boardId: doc.id,
207202
},
208-
)
209-
return boardData as BoardDB
210-
}
203+
},
204+
)
205+
return boardData as BoardDB
206+
}
211207

212-
return parsedBoard.data
213-
}),
214-
)
215-
.flat()
208+
return parsedBoard.data
209+
}),
210+
)
216211
} catch (error) {
217212
Sentry.captureMessage('Error while fetching list of boards: ' + ids)
218213
throw error

tavla/app/(admin)/components/CreateBoard/NameAndFolderSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { HiddenInput } from 'app/(admin)/components/Form/HiddenInput'
66
import { SubmitButton } from 'app/(admin)/components/Form/SubmitButton'
77
import { useFolderDropdown } from 'app/(admin)/hooks/useFolders'
88
import { getFormFeedbackForField } from 'app/(admin)/utils'
9-
import { Folder } from 'app/(admin)/utils/types'
9+
import type { Folder } from 'app/(admin)/utils/types'
1010
import ClientOnlyTextField from 'app/components/NoSSR/TextField'
1111
import { usePosthogTracking } from 'app/posthog/usePosthogTracking'
1212
import rabbits from 'assets/illustrations/Rabbits.png'
1313
import { isNull } from 'lodash'
1414
import Image from 'next/image'
1515
import { useActionState } from 'react'
16-
import { FolderDB } from 'src/types/db-types/folders'
16+
import type { FolderDB } from 'src/types/db-types/folders'
1717
import { FormError } from '../FormError'
1818
import { createBoard } from './actions'
1919

tavla/app/(admin)/components/CreateBoard/actions.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
'use server'
22
import * as Sentry from '@sentry/nextjs'
3-
import { TFormFeedback, getFormFeedbackForError } from 'app/(admin)/utils'
3+
import { getFormFeedbackForError, type TFormFeedback } from 'app/(admin)/utils'
44
import { initializeAdminApp } from 'app/(admin)/utils/firebase'
55
import { handleError } from 'app/(admin)/utils/handleError'
66
import { getUserFromSessionCookie } from 'app/(admin)/utils/server'
77
import admin, { firestore } from 'firebase-admin'
88
import { redirect } from 'next/navigation'
9-
import { BoardDB } from 'src/types/db-types/boards'
10-
import { FolderDB } from 'src/types/db-types/folders'
9+
import type { BoardDB } from 'src/types/db-types/boards'
10+
import type { FolderDB } from 'src/types/db-types/folders'
1111

1212
initializeAdminApp()
1313

1414
export async function createBoard(
15-
prevState: TFormFeedback | undefined,
15+
_prevState: TFormFeedback | undefined,
1616
data: FormData,
1717
) {
1818
const name = data.get('name') as string
@@ -23,14 +23,15 @@ export async function createBoard(
2323
const user = await getUserFromSessionCookie()
2424
if (!user) return getFormFeedbackForError('auth/operation-not-allowed')
2525

26-
let createdBoard
26+
let createdBoard: FirebaseFirestore.DocumentReference | undefined
2727

2828
try {
2929
createdBoard = await firestore()
3030
.collection('boards')
3131
.add({
3232
tiles: [],
3333
theme: 'dark',
34+
isCombinedTiles: false,
3435
meta: {
3536
title: name.substring(0, 50),
3637
fontSize: 'medium',

tavla/app/(admin)/components/CreateBoard/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import { IconButton, PrimaryButton } from '@entur/button'
33
import { BoardIcon, CloseIcon } from '@entur/icons'
44
import { Modal } from '@entur/modal'
5-
import { Folder } from 'app/(admin)/utils/types'
6-
import { EventProps } from 'app/posthog/events'
5+
import type { Folder } from 'app/(admin)/utils/types'
6+
import type { EventProps } from 'app/posthog/events'
77
import { usePosthogTracking } from 'app/posthog/usePosthogTracking'
88
import { useState } from 'react'
9-
import { FolderDB } from 'src/types/db-types/folders'
9+
import type { FolderDB } from 'src/types/db-types/folders'
1010
import { NameAndFolderSelector } from './NameAndFolderSelector'
1111

1212
type CreateBoardProps = {

tavla/app/(admin)/components/CreateFolder/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use server'
22

33
import * as Sentry from '@sentry/nextjs'
4-
import { TFormFeedback, getFormFeedbackForError } from 'app/(admin)/utils'
4+
import { getFormFeedbackForError, type TFormFeedback } from 'app/(admin)/utils'
55
import { initializeAdminApp } from 'app/(admin)/utils/firebase'
66
import { handleError } from 'app/(admin)/utils/handleError'
77
import { getUserFromSessionCookie } from 'app/(admin)/utils/server'
@@ -13,7 +13,7 @@ initializeAdminApp()
1313
const db = getFirestore()
1414

1515
export async function createFolder(
16-
prevState: TFormFeedback | undefined,
16+
_prevState: TFormFeedback | undefined,
1717
data: FormData,
1818
) {
1919
const name = data.get('name')?.toString() ?? ''
@@ -25,7 +25,7 @@ export async function createFolder(
2525

2626
if (!user) return getFormFeedbackForError('auth/operation-not-allowed')
2727

28-
let folder
28+
let folder: FirebaseFirestore.DocumentReference | undefined
2929

3030
try {
3131
folder = await db.collection('folders').add({

tavla/app/(admin)/components/Delete/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use server'
22

3-
import { TFormFeedback, getFormFeedbackForError } from 'app/(admin)/utils'
3+
import { getFormFeedbackForError, type TFormFeedback } from 'app/(admin)/utils'
44
import { deleteFolder } from 'app/(admin)/utils/firebase'
55
import { handleError } from 'app/(admin)/utils/handleError'
66
import { getUserFromSessionCookie } from 'app/(admin)/utils/server'
77
import { revalidatePath } from 'next/cache'
88
import { redirect } from 'next/navigation'
9-
import { FolderDB } from 'src/types/db-types/folders'
9+
import type { FolderDB } from 'src/types/db-types/folders'
1010

1111
export async function deleteFolderAction(
12-
prevState: TFormFeedback | undefined,
12+
_prevState: TFormFeedback | undefined,
1313
data: FormData,
1414
) {
1515
const user = await getUserFromSessionCookie()

tavla/app/(admin)/components/Delete/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { DeleteButton } from 'app/(admin)/oversikt/components/Column/Delete'
1111
import {
1212
getFormFeedbackForError,
1313
getFormFeedbackForField,
14-
TFormFeedback,
14+
type TFormFeedback,
1515
} from 'app/(admin)/utils'
1616
import ClientOnlyTextField from 'app/components/NoSSR/TextField'
1717
import { usePosthogTracking } from 'app/posthog/usePosthogTracking'
1818
import ducks from 'assets/illustrations/Ducks.png'
1919
import Image from 'next/image'
2020
import { useActionState, useState } from 'react'
21-
import { FolderDB } from 'src/types/db-types/folders'
21+
import type { FolderDB } from 'src/types/db-types/folders'
2222
import { FormError } from '../FormError'
2323
import { deleteFolderAction } from './actions'
2424

tavla/app/(admin)/components/DeleteAccount/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@entur/typography'
1212
import { SubmitButton } from 'app/(admin)/components/Form/SubmitButton'
1313
import { useSearchParamsModal } from 'app/(admin)/hooks/useSearchParamsModal'
14-
import { getFormFeedbackForField, TFormFeedback } from 'app/(admin)/utils'
14+
import { getFormFeedbackForField, type TFormFeedback } from 'app/(admin)/utils'
1515
import ClientOnlyTextField from 'app/components/NoSSR/TextField'
1616
import sheep from 'assets/illustrations/Sheep.png'
1717
import Image from 'next/image'
@@ -26,7 +26,7 @@ function DeleteAccount() {
2626
const posthog = usePostHog()
2727

2828
const submit = async (
29-
prevState: TFormFeedback | undefined,
29+
_prevState: TFormFeedback | undefined,
3030
data: FormData,
3131
) => {
3232
const formFeedback = await deleteAccount(data)

0 commit comments

Comments
 (0)