Infomelding
diff --git a/tavla/app/(admin)/edit/[id]/components/MetaSettings/actions.ts b/tavla/app/(admin)/edit/[id]/components/MetaSettings/actions.ts
index ad25a4dda..d0e8ad153 100644
--- a/tavla/app/(admin)/edit/[id]/components/MetaSettings/actions.ts
+++ b/tavla/app/(admin)/edit/[id]/components/MetaSettings/actions.ts
@@ -46,11 +46,11 @@ export async function saveTitle(
}
export async function saveFont(bid: TBoardID, data: FormData) {
- const font = data.get('font') as TFontSize
-
const access = await hasBoardEditorAccess(bid)
if (!access) return redirect('/')
+ const font = data.get('font') as TFontSize
+
try {
await firestore()
.collection('boards')
diff --git a/tavla/app/(admin)/organizations/[id]/page.tsx b/tavla/app/(admin)/organizations/[id]/page.tsx
index dc7aad16a..94a4ae513 100644
--- a/tavla/app/(admin)/organizations/[id]/page.tsx
+++ b/tavla/app/(admin)/organizations/[id]/page.tsx
@@ -3,7 +3,7 @@ import { Heading1, LeadParagraph } from '@entur/typography'
import { redirect } from 'next/navigation'
import { UploadLogo } from '../components/UploadLogo'
import { MemberAdministration } from '../components/MemberAdministration'
-import { CountiesSelect } from '../components/MemberAdministration/CountiesSelect'
+import { CountiesSelect } from '../components/CountiesSelect'
import { FontSelect } from '../components/FontSelect'
import { DefaultColumns } from '../components/DefaultColumns'
import { getOrganizationIfUserHasAccess } from 'app/(admin)/actions'
diff --git a/tavla/app/(admin)/organizations/components/MemberAdministration/CountiesSelect/actions.ts b/tavla/app/(admin)/organizations/components/CountiesSelect/actions.ts
similarity index 67%
rename from tavla/app/(admin)/organizations/components/MemberAdministration/CountiesSelect/actions.ts
rename to tavla/app/(admin)/organizations/components/CountiesSelect/actions.ts
index 8d8391c66..b76d8f1f4 100644
--- a/tavla/app/(admin)/organizations/components/MemberAdministration/CountiesSelect/actions.ts
+++ b/tavla/app/(admin)/organizations/components/CountiesSelect/actions.ts
@@ -1,4 +1,5 @@
'use server'
+import { getFormFeedbackForError } from 'app/(admin)/utils'
import {
initializeAdminApp,
userCanEditOrganization,
@@ -7,20 +8,22 @@ import { handleError } from 'app/(admin)/utils/handleError'
import { firestore } from 'firebase-admin'
import { revalidatePath } from 'next/cache'
import { redirect } from 'next/navigation'
-import { TCountyID, TOrganizationID } from 'types/settings'
+import { TOrganizationID } from 'types/settings'
initializeAdminApp()
export async function setCounties(
- oid: TOrganizationID,
- countiesList: TCountyID[],
+ oid: TOrganizationID | undefined,
+ data: FormData,
) {
+ if (!oid) return getFormFeedbackForError()
const access = userCanEditOrganization(oid)
if (!access) return redirect('/')
+ const counties = data.getAll('county') as string[]
try {
await firestore().collection('organizations').doc(oid).update({
- 'defaults.counties': countiesList,
+ 'defaults.counties': counties,
})
revalidatePath(`/organizations/${oid}`)
} catch (e) {
diff --git a/tavla/app/(admin)/organizations/components/MemberAdministration/CountiesSelect/index.tsx b/tavla/app/(admin)/organizations/components/CountiesSelect/index.tsx
similarity index 94%
rename from tavla/app/(admin)/organizations/components/MemberAdministration/CountiesSelect/index.tsx
rename to tavla/app/(admin)/organizations/components/CountiesSelect/index.tsx
index 669fd861e..4edb5f840 100644
--- a/tavla/app/(admin)/organizations/components/MemberAdministration/CountiesSelect/index.tsx
+++ b/tavla/app/(admin)/organizations/components/CountiesSelect/index.tsx
@@ -20,9 +20,7 @@ function CountiesSelect({
const { addToast } = useToast()
const setCounties = async (data: FormData) => {
- if (!oid) return
- const counties = data.getAll('county') as string[]
- const result = await setCountiesAction(oid, counties)
+ const result = await setCountiesAction(oid, data)
fireToastFeedback(addToast, result, 'Fylker lagret!')
}
diff --git a/tavla/app/(admin)/organizations/components/DefaultColumns/actions.ts b/tavla/app/(admin)/organizations/components/DefaultColumns/actions.ts
index 481118e79..b9f4b7f92 100644
--- a/tavla/app/(admin)/organizations/components/DefaultColumns/actions.ts
+++ b/tavla/app/(admin)/organizations/components/DefaultColumns/actions.ts
@@ -15,11 +15,14 @@ initializeAdminApp()
export async function saveColumns(
state: TFormFeedback | undefined,
- oid: TOrganizationID,
- columns: TColumn[],
+ oid: TOrganizationID | undefined,
+ data: FormData,
) {
+ if (!oid) return getFormFeedbackForError()
const access = userCanEditOrganization(oid)
if (!access) return redirect('/')
+
+ const columns = data.getAll('columns') as TColumn[]
if (columns.length === 0)
return getFormFeedbackForError('organization/invalid-columns')
diff --git a/tavla/app/(admin)/organizations/components/DefaultColumns/index.tsx b/tavla/app/(admin)/organizations/components/DefaultColumns/index.tsx
index fc3fb83e7..997100197 100644
--- a/tavla/app/(admin)/organizations/components/DefaultColumns/index.tsx
+++ b/tavla/app/(admin)/organizations/components/DefaultColumns/index.tsx
@@ -28,9 +28,7 @@ function DefaultColumns({
state: TFormFeedback | undefined,
data: FormData,
) => {
- if (!oid) return
- const columns = data.getAll('columns') as TColumn[]
- const result = await saveColumnsAction(state, oid, columns)
+ const result = await saveColumnsAction(state, oid, data)
if (result === undefined) {
addToast('Kolonner lagret!')
}
diff --git a/tavla/app/(admin)/organizations/components/FontSelect/actions.ts b/tavla/app/(admin)/organizations/components/FontSelect/actions.ts
index 9155942d2..c46371f96 100644
--- a/tavla/app/(admin)/organizations/components/FontSelect/actions.ts
+++ b/tavla/app/(admin)/organizations/components/FontSelect/actions.ts
@@ -1,4 +1,5 @@
'use server'
+import { getFormFeedbackForError } from 'app/(admin)/utils'
import {
initializeAdminApp,
userCanEditOrganization,
@@ -12,7 +13,12 @@ import { TOrganizationID } from 'types/settings'
initializeAdminApp()
-export async function setFontSize(oid: TOrganizationID, fontSize: TFontSize) {
+export async function setFontSize(
+ oid: TOrganizationID | undefined,
+ data: FormData,
+) {
+ if (!oid) return getFormFeedbackForError()
+ const fontSize = data.get('font') as TFontSize
const access = await userCanEditOrganization(oid)
if (!access) return redirect('/')
diff --git a/tavla/app/(admin)/organizations/components/FontSelect/index.tsx b/tavla/app/(admin)/organizations/components/FontSelect/index.tsx
index dd770c873..3f1dce269 100644
--- a/tavla/app/(admin)/organizations/components/FontSelect/index.tsx
+++ b/tavla/app/(admin)/organizations/components/FontSelect/index.tsx
@@ -18,9 +18,7 @@ function FontSelect({
const { addToast } = useToast()
const setFontSize = async (data: FormData) => {
- if (!oid) return
- const font = data.get('font') as TFontSize
- const result = await setFontSizeAction(oid, font)
+ const result = await setFontSizeAction(oid, data)
fireToastFeedback(addToast, result, 'Tekststørrelse lagret!')
}
diff --git a/tavla/app/(admin)/organizations/components/Footer/actions.ts b/tavla/app/(admin)/organizations/components/Footer/actions.ts
index 05a6e3113..a86982101 100644
--- a/tavla/app/(admin)/organizations/components/Footer/actions.ts
+++ b/tavla/app/(admin)/organizations/components/Footer/actions.ts
@@ -1,5 +1,6 @@
'use server'
import { isEmptyOrSpaces } from 'app/(admin)/edit/utils'
+import { getFormFeedbackForError } from 'app/(admin)/utils'
import { userCanEditOrganization } from 'app/(admin)/utils/firebase'
import { handleError } from 'app/(admin)/utils/handleError'
import { firestore } from 'firebase-admin'
@@ -7,10 +8,16 @@ import { revalidatePath } from 'next/cache'
import { redirect } from 'next/navigation'
import { TOrganizationID } from 'types/settings'
-export async function setFooter(oid: TOrganizationID, message?: string) {
+export async function setFooter(
+ oid: TOrganizationID | undefined,
+ data: FormData,
+) {
+ if (!oid) return getFormFeedbackForError()
const access = await userCanEditOrganization(oid)
if (!access) return redirect('/')
+ const message = data.get('footer') as string
+
try {
await firestore()
.collection('organizations')
diff --git a/tavla/app/(admin)/organizations/components/Footer/index.tsx b/tavla/app/(admin)/organizations/components/Footer/index.tsx
index 9eab5e610..897e65fdf 100644
--- a/tavla/app/(admin)/organizations/components/Footer/index.tsx
+++ b/tavla/app/(admin)/organizations/components/Footer/index.tsx
@@ -10,15 +10,13 @@ import { fireToastFeedback } from 'app/(admin)/utils'
function Footer({ oid, footer }: { oid?: TOrganizationID; footer?: string }) {
const { addToast } = useToast()
- const setFooter = async (data: FormData) => {
- if (!oid) return
- const message = data.get('footer') as string
- const result = await setFooterAction(oid, message)
+ const setOrgFooter = async (data: FormData) => {
+ const result = await setFooterAction(oid, data)
fireToastFeedback(addToast, result, 'Infomelding lagret!')
}
return (
-