diff --git a/src/app/(auth)/layout.tsx b/src/app/(auth)/layout.tsx
index a154043ad..c96cef520 100644
--- a/src/app/(auth)/layout.tsx
+++ b/src/app/(auth)/layout.tsx
@@ -1,5 +1,6 @@
import styles from './layout.module.scss'
import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
+import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions'
import React from 'react'
type PropTypes = {
@@ -14,7 +15,14 @@ export default function AuthLayout({ children }: PropTypes) {
{children}
-
+
diff --git a/src/app/(home)/InfoBubbles.module.scss b/src/app/(frontpage)/InfoBubbles.module.scss
similarity index 100%
rename from src/app/(home)/InfoBubbles.module.scss
rename to src/app/(frontpage)/InfoBubbles.module.scss
diff --git a/src/app/(home)/InfoBubbles.tsx b/src/app/(frontpage)/InfoBubbles.tsx
similarity index 100%
rename from src/app/(home)/InfoBubbles.tsx
rename to src/app/(frontpage)/InfoBubbles.tsx
diff --git a/src/app/(home)/LoggedIn.module.scss b/src/app/(frontpage)/LoggedIn.module.scss
similarity index 100%
rename from src/app/(home)/LoggedIn.module.scss
rename to src/app/(frontpage)/LoggedIn.module.scss
diff --git a/src/app/(home)/LoggedIn.tsx b/src/app/(frontpage)/LoggedIn.tsx
similarity index 87%
rename from src/app/(home)/LoggedIn.tsx
rename to src/app/(frontpage)/LoggedIn.tsx
index ee6f13126..1559f941d 100644
--- a/src/app/(home)/LoggedIn.tsx
+++ b/src/app/(frontpage)/LoggedIn.tsx
@@ -10,6 +10,7 @@ import { unwrapActionReturn } from '@/app/redirectToErrorPage'
import { readNewsCurrentAction } from '@/services/news/actions'
import { readActiveJobAdsAction } from '@/services/career/jobAds/actions'
import { readCurrentEventsAction } from '@/services/events/actions'
+import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions'
import { faAngleDown } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Link from 'next/link'
@@ -28,7 +29,12 @@ export default async function LoggedInLandingPage() {
-
+
diff --git a/src/app/(home)/LoggedInSection.module.scss b/src/app/(frontpage)/LoggedInSection.module.scss
similarity index 100%
rename from src/app/(home)/LoggedInSection.module.scss
rename to src/app/(frontpage)/LoggedInSection.module.scss
diff --git a/src/app/(home)/LoggedInSection.tsx b/src/app/(frontpage)/LoggedInSection.tsx
similarity index 100%
rename from src/app/(home)/LoggedInSection.tsx
rename to src/app/(frontpage)/LoggedInSection.tsx
diff --git a/src/app/(home)/LoggedOut.tsx b/src/app/(frontpage)/LoggedOut.tsx
similarity index 82%
rename from src/app/(home)/LoggedOut.tsx
rename to src/app/(frontpage)/LoggedOut.tsx
index e4965423c..e0d176436 100644
--- a/src/app/(home)/LoggedOut.tsx
+++ b/src/app/(frontpage)/LoggedOut.tsx
@@ -5,6 +5,7 @@ import MazeMap from '@/components/MazeMap/MazeMap'
import SocialIcons from '@/components/SocialIcons/SocialIcons'
import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
import YouTube from '@/components/YouTube/YouTube'
+import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions'
import { faAngleDown } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Link from 'next/link'
@@ -15,7 +16,12 @@ export default async function LoggedOutLandingPage() {
-
+
Logg inn
Ny student
@@ -30,6 +36,7 @@ export default async function LoggedOutLandingPage() {
+
+
+ )
+ return (
+
+ {position === 'left' && imgContainer}
+
+
+ Les mer
+
+ {position === 'right' && imgContainer}
+
+ )
+}
+
+export default Section
diff --git a/src/app/(home)/backgroundimages/Omegamai.jpeg b/src/app/(frontpage)/backgroundimages/Omegamai.jpeg
similarity index 100%
rename from src/app/(home)/backgroundimages/Omegamai.jpeg
rename to src/app/(frontpage)/backgroundimages/Omegamai.jpeg
diff --git a/src/app/(home)/backgroundimages/frontImg.jpeg b/src/app/(frontpage)/backgroundimages/frontImg.jpeg
similarity index 100%
rename from src/app/(home)/backgroundimages/frontImg.jpeg
rename to src/app/(frontpage)/backgroundimages/frontImg.jpeg
diff --git a/src/app/(home)/backgroundimages/taktlause.jpeg b/src/app/(frontpage)/backgroundimages/taktlause.jpeg
similarity index 100%
rename from src/app/(home)/backgroundimages/taktlause.jpeg
rename to src/app/(frontpage)/backgroundimages/taktlause.jpeg
diff --git a/src/app/(home)/page.module.scss b/src/app/(frontpage)/page.module.scss
similarity index 100%
rename from src/app/(home)/page.module.scss
rename to src/app/(frontpage)/page.module.scss
diff --git a/src/app/(home)/page.tsx b/src/app/(frontpage)/page.tsx
similarity index 100%
rename from src/app/(home)/page.tsx
rename to src/app/(frontpage)/page.tsx
diff --git a/src/app/(home)/Section.tsx b/src/app/(home)/Section.tsx
deleted file mode 100644
index 15bea3932..000000000
--- a/src/app/(home)/Section.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import styles from './Section.module.scss'
-import SpecialCmsParagraph from '@/components/Cms/CmsParagraph/SpecialCmsParagraph'
-import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
-import React from 'react'
-import Link from 'next/link'
-import type {
- SpecialCmsImage as SpecialCmsImageT,
- SpecialCmsParagraph as SpecialCmsParagraphT
-} from '@prisma/client'
-
-type PropTypes = {
- specialCmsImage: SpecialCmsImageT,
- specialCmsParagraph: SpecialCmsParagraphT,
- lesMer: string,
- right?: boolean,
- imgWidth: number,
- id?: string,
-}
-
-function Section({ specialCmsImage, specialCmsParagraph, lesMer, right, imgWidth, id }: PropTypes) {
- const imgContainer = (
-
-
-
- )
- return (
-
- {!right && imgContainer}
-
-
- Les mer
-
- {right && imgContainer}
-
- )
-}
-
-export default Section
diff --git a/src/app/_components/Cms/Article/AddSection.tsx b/src/app/_components/Cms/Article/AddSection.tsx
index cc2132575..10bd011b4 100644
--- a/src/app/_components/Cms/Article/AddSection.tsx
+++ b/src/app/_components/Cms/Article/AddSection.tsx
@@ -2,28 +2,36 @@
import styles from './AddSection.module.scss'
import AddParts from '@/cms/AddParts'
-import { addSectionToArticleAction } from '@/cms/articles/actions'
-import { maxSections } from '@/cms/articles/ConfigVars'
+import { maxSections } from '@/cms/articles/constants'
import useEditing from '@/hooks/useEditing'
import { useRouter } from 'next/navigation'
import type { ArticleSectionPart } from '@/cms/articleSections/types'
+import type { AddSectionToArticleAction } from '@/cms/articles/types'
+import type { ConfiguredAction } from '@/services/actionTypes'
type PropTypes = {
- articleId: number,
currentNumberSections: number,
+ addSectionToArticleAction: ConfiguredAction
}
-export default function AddSection({ articleId, currentNumberSections }: PropTypes) {
+export default function AddSection({
+ currentNumberSections,
+ addSectionToArticleAction
+}: PropTypes) {
const { refresh } = useRouter()
const canEdit = useEditing({}) //TODO: check visibility of article for user and pass it to useEditing
- if (!canEdit) return null
- const handleAdd = async (part: ArticleSectionPart) => {
- addSectionToArticleAction(articleId, {
- [part]: true,
+ const handleAdd = async (includePart: ArticleSectionPart) => {
+ await addSectionToArticleAction({
+ data: {
+ includeParts: {
+ [includePart]: true,
+ }
+ }
})
refresh()
}
+ if (!canEdit) return null
return (
{
diff --git a/src/app/_components/Cms/Article/Article.tsx b/src/app/_components/Cms/Article/Article.tsx
index 78a0744c0..7af97a7c9 100644
--- a/src/app/_components/Cms/Article/Article.tsx
+++ b/src/app/_components/Cms/Article/Article.tsx
@@ -4,9 +4,18 @@ import SectionMover from './SectionMover'
import ChangeName from './ChangeName'
import CmsImage from '@/cms/CmsImage/CmsImage'
import SlideInOnView from '@/components/SlideInOnView/SlideInOnView'
-import ArticleSection from '@/cms/ArticleSection/ArticleSection'
+import { configureAction } from '@/services/configureAction'
+import ArticleSection, {
+ type ArticleSectionActions
+} from '@/cms/ArticleSection/ArticleSection'
import type { ReactNode } from 'react'
-import type { ExpandedArticle } from '@/cms/articles/types'
+import type {
+ AddSectionToArticleAction,
+ ExpandedArticle,
+ ReorderArticleSectionsAction,
+ UpdateArticleAction
+} from '@/cms/articles/types'
+import type { UpdateCmsImageAction } from '@/cms/images/types'
export type PropTypes = {
article: ExpandedArticle,
@@ -15,6 +24,13 @@ export type PropTypes = {
noMargin?: boolean
sideBarContent?: ReactNode
sideBarClassName?: string
+ actions: {
+ updateCoverImageAction: UpdateCmsImageAction,
+ updateArticleAction: UpdateArticleAction,
+ addSectionToArticleAction: AddSectionToArticleAction,
+ reorderArticleSectionsAction: ReorderArticleSectionsAction,
+ articleSections: ArticleSectionActions
+ }
}
export default function Article({
@@ -24,14 +40,27 @@ export default function Article({
noMargin = false,
sideBarContent,
sideBarClassName,
+ actions,
}: PropTypes) {
return (
{hideCoverImage ? <>> : (
-
+
-
+
)}
@@ -41,13 +70,22 @@ export default function Article({
article.articleSections.sort((a, b) => (a.order - b.order)).map((section, i) => (
-
+
@@ -63,7 +101,15 @@ export default function Article({
)}
-
+
)
diff --git a/src/app/_components/Cms/Article/ChangeName.tsx b/src/app/_components/Cms/Article/ChangeName.tsx
index 9056f196a..01079ebb6 100644
--- a/src/app/_components/Cms/Article/ChangeName.tsx
+++ b/src/app/_components/Cms/Article/ChangeName.tsx
@@ -1,17 +1,17 @@
'use client'
import styles from './ChangeName.module.scss'
import EditableTextField from '@/components/EditableTextField/EditableTextField'
-import { updateArticleAction } from '@/services/cms/articles/actions'
import React, { useState } from 'react'
import { usePathname } from 'next/navigation'
-import type { ExpandedArticle } from '@/cms/articles/types'
+import type { ExpandedArticle, UpdateArticleAction } from '@/cms/articles/types'
+import type { ConfiguredAction } from '@/services/actionTypes'
type PropTypes = {
article: ExpandedArticle
+ updateArticleAction: ConfiguredAction
}
-export default function ChangeName({ article }: PropTypes) {
- const changeName = updateArticleAction.bind(null, article.id)
+export default function ChangeName({ article, updateArticleAction }: PropTypes) {
const currentPath = usePathname()
const [currentName, setCurrentName] = useState(article.name)
const successCallback = (data: ExpandedArticle | undefined) => {
@@ -27,7 +27,7 @@ export default function ChangeName({ article }: PropTypes) {
}
-export default function SectionMover({ articleId, sectionId, className, showUp, showDown }: PropTypes) {
+export default function SectionMover({
+ className,
+ showUp,
+ showDown,
+ reorderArticleSectionsAction
+}: PropTypes) {
const canEdit = useEditing({}) //TODO: check visibility of section for user and pass it to useEditing
const { refresh } = useRouter()
const handleMove = useCallback(async (direction: 'UP' | 'DOWN') => {
- await moveSectionOrderAction(articleId, sectionId, direction)
+ await reorderArticleSectionsAction({ data: { direction } })
refresh()
- }, [sectionId, articleId, refresh])
+ }, [reorderArticleSectionsAction, refresh])
if (!canEdit) return null
return (
diff --git a/src/app/_components/Cms/ArticleSection/AddPartToArticleSection.tsx b/src/app/_components/Cms/ArticleSection/AddPartToArticleSection.tsx
index d4453fc28..26529b267 100644
--- a/src/app/_components/Cms/ArticleSection/AddPartToArticleSection.tsx
+++ b/src/app/_components/Cms/ArticleSection/AddPartToArticleSection.tsx
@@ -1,26 +1,34 @@
'use client'
import styles from './AddPartToArticleSection.module.scss'
-import { addArticleSectionPartAction } from '@/cms/articleSections/actions'
import AddParts from '@/cms/AddParts'
import useEditing from '@/hooks/useEditing'
import { useCallback } from 'react'
import { useRouter } from 'next/navigation'
import type { PropTypes as AddPartsPropTypes } from '@/cms/AddParts'
-import type { ArticleSectionPart } from '@/cms/articleSections/types'
+import type {
+ AddPartToArticleSectionAction,
+ ArticleSectionPart,
+} from '@/cms/articleSections/types'
import type { ReactNode } from 'react'
+import type { ConfiguredAction } from '@/services/actionTypes'
type PropTypes = Omit & {
- articleSectionName: string
children: ReactNode
+ addPartToArticleSectionAction: ConfiguredAction
}
-export default function AddPartToArticleSection({ articleSectionName, children, ...props }: PropTypes) {
+export default function AddPartToArticleSection({
+ children,
+ addPartToArticleSectionAction,
+ ...props
+}: PropTypes) {
const { refresh } = useRouter()
const canEdit = useEditing({}) //TODO: check visibility of article for user and pass it to useEditing
+
const handleAdd = useCallback(async (part: ArticleSectionPart) => {
- await addArticleSectionPartAction(articleSectionName, part)
+ await addPartToArticleSectionAction({ data: { part } })
refresh()
- }, [articleSectionName])
+ }, [addPartToArticleSectionAction, refresh])
if (!canEdit) return children
return (
diff --git a/src/app/_components/Cms/ArticleSection/ArticleSection.tsx b/src/app/_components/Cms/ArticleSection/ArticleSection.tsx
index 806204ec4..48c59900b 100644
--- a/src/app/_components/Cms/ArticleSection/ArticleSection.tsx
+++ b/src/app/_components/Cms/ArticleSection/ArticleSection.tsx
@@ -5,33 +5,62 @@ import AddPartToArticleSection from './AddPartToArticleSection'
import CmsLink from '@/cms/CmsLink/CmsLink'
import CmsImage from '@/cms/CmsImage/CmsImage'
import CmsParagraph from '@/cms/CmsParagraph/CmsParagraph'
-import type { ExpandedCmsImage } from '@/cms/images/types'
+import { configureAction } from '@/services/configureAction'
import type {
- ArticleSection as ArticleSectionT,
- CmsParagraph as CmsParagraphT,
- CmsLink as CmsLinkT
-} from '@prisma/client'
+ ExpandedArticleSection,
+ AddPartToArticleSectionAction,
+ RemovePartFromArticleSectionAction,
+ UpdateArticleSectionAction
+} from '@/cms/articleSections/types'
+import type { UpdateCmsParagraphAction } from '@/cms/paragraphs/types'
+import type { UpdateCmsImageAction } from '@/cms/images/types'
+import type { UpdateCmsLinkAction } from '@/cms/links/types'
type PropTypes = {
- articleSection: ArticleSectionT & {
- cmsParagraph: CmsParagraphT | null,
- cmsImage: ExpandedCmsImage | null,
- cmsLink: CmsLinkT | null
+ articleSection: ExpandedArticleSection
+ actions: {
+ updateCmsParagraph: UpdateCmsParagraphAction,
+ updateCmsImage: UpdateCmsImageAction,
+ updateCmsLink: UpdateCmsLinkAction,
+ updateArticleSection: UpdateArticleSectionAction,
+ addPartToArticleSection: AddPartToArticleSectionAction,
+ removePartFromArticleSection: RemovePartFromArticleSectionAction
}
}
-export default function ArticleSection({ articleSection }: PropTypes) {
+export type ArticleSectionActions = PropTypes['actions']
+
+export default function ArticleSection({
+ articleSection,
+ actions
+}: PropTypes) {
const { cmsParagraph, cmsImage, cmsLink } = articleSection
const cmsImageContent = (
{cmsImage && <>
-
-
+
+