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 && <> - - + +
- +
} @@ -41,10 +70,13 @@ export default function ArticleSection({ articleSection }: PropTypes) { return (
{ @@ -56,18 +88,38 @@ export default function ArticleSection({ articleSection }: PropTypes) { cmsParagraph &&
- +
- +
} { cmsLink &&
- +
- +
}
diff --git a/src/app/_components/Cms/ArticleSection/ImageControls.tsx b/src/app/_components/Cms/ArticleSection/ImageControls.tsx index 21805c64f..46543095a 100644 --- a/src/app/_components/Cms/ArticleSection/ImageControls.tsx +++ b/src/app/_components/Cms/ArticleSection/ImageControls.tsx @@ -1,7 +1,6 @@ 'use client' import styles from './ImageControls.module.scss' -import { updateArticleSectionAction } from '@/cms/articleSections/actions' -import { imageSizeIncrement, maxImageSize, minImageSize } from '@/cms/articleSections/ConfigVars' +import { imageSizeIncrement, maxImageSize, minImageSize } from '@/cms/articleSections/constants' import useEditing from '@/hooks/useEditing' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { @@ -12,39 +11,52 @@ import { } from '@fortawesome/free-solid-svg-icons' import { useRouter } from 'next/navigation' import type { ArticleSection } from '@prisma/client' - -/** - * This component is used to control the image in the article section - * i.e move it left or right and size it - */ +import type { UpdateArticleSectionAction } from '@/cms/articleSections/types' type PropTypes = { articleSection: ArticleSection className?: string + updateArticleSectionAction: UpdateArticleSectionAction } -export default function ImageControls({ articleSection, className }: PropTypes) { +/** + * This component is used to control the image in the article section + * i.e move it left or right and size it + */ +export default function ImageControls({ articleSection, className, updateArticleSectionAction }: PropTypes) { const canEdit = useEditing({}) //TODO: check visibility of article for user and pass it to useEditing const { refresh } = useRouter() if (!canEdit) return null const moveLeft = async () => { - await updateArticleSectionAction(articleSection.name, { imagePosition: 'LEFT' }) + await updateArticleSectionAction( + { params: { articleSectionName: articleSection.name } }, + { data: { position: 'LEFT' } } + ) refresh() } const moveRight = async () => { - await updateArticleSectionAction(articleSection.name, { imagePosition: 'RIGHT' }) + await updateArticleSectionAction( + { params: { articleSectionName: articleSection.name } }, + { data: { position: 'RIGHT' } } + ) refresh() } const increaseSize = async () => { - await updateArticleSectionAction(articleSection.name, { imageSize: articleSection.imageSize + imageSizeIncrement }) + await updateArticleSectionAction( + { params: { articleSectionName: articleSection.name } }, + { data: { imageSize: articleSection.imageSize + imageSizeIncrement } } + ) refresh() } const decreaseSize = async () => { - await updateArticleSectionAction(articleSection.name, { imageSize: articleSection.imageSize - imageSizeIncrement }) + await updateArticleSectionAction( + { params: { articleSectionName: articleSection.name } }, + { data: { imageSize: articleSection.imageSize - imageSizeIncrement } } + ) refresh() } diff --git a/src/app/_components/Cms/ArticleSection/RemovePart.tsx b/src/app/_components/Cms/ArticleSection/RemovePart.tsx index e13e7625e..d2198be3c 100644 --- a/src/app/_components/Cms/ArticleSection/RemovePart.tsx +++ b/src/app/_components/Cms/ArticleSection/RemovePart.tsx @@ -1,6 +1,5 @@ 'use client' import styles from './RemovePart.module.scss' -import { removeArticleSectionPartAction } from '@/cms/articleSections/actions' import Form from '@/components/Form/Form' import useClickOutsideRef from '@/hooks/useClickOutsideRef' import useEditing from '@/hooks/useEditing' @@ -8,20 +7,21 @@ import { useRouter } from 'next/navigation' import { useState } from 'react' import { faX } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import type { ArticleSectionPart } from '@/cms/articleSections/types' +import type { ArticleSectionPart, RemovePartFromArticleSectionAction } from '@/cms/articleSections/types' +import type { ConfiguredAction } from '@/services/actionTypes' type PropTypes = { part: ArticleSectionPart, - articleSectionName: string + removePartFromArticleSectionAction: ConfiguredAction } -export default function RemovePart({ part, articleSectionName }: PropTypes) { +export default function RemovePart({ part, removePartFromArticleSectionAction }: PropTypes) { const { refresh } = useRouter() const canEdit = useEditing({}) const [confirmOpen, setConfirmOpen] = useState(false) const confirmRef = useClickOutsideRef(() => setConfirmOpen(false)) if (!canEdit) return null - const handleRemove = removeArticleSectionPartAction.bind(null, articleSectionName).bind(null, part) + const handleRemove = removePartFromArticleSectionAction.bind(null, { data: { part } }) return (
diff --git a/src/app/_components/Cms/CmsImage/ChangeImage.tsx b/src/app/_components/Cms/CmsImage/ChangeImage.tsx index b154db70d..ccc7ae8fd 100644 --- a/src/app/_components/Cms/CmsImage/ChangeImage.tsx +++ b/src/app/_components/Cms/CmsImage/ChangeImage.tsx @@ -4,19 +4,21 @@ import ChangeImageForm from './ChangeImageForm' import Image from '@/components/Image/Image' import { ImageSelectionContext } from '@/contexts/ImageSelection' import Form from '@/components/Form/Form' -import { updateCmsImageConfigAction } from '@/services/cms/images/actions' +import { configureAction } from '@/services/configureAction' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faTurnUp } from '@fortawesome/free-solid-svg-icons' import React, { useContext, useEffect, useState } from 'react' import type { ImageSize, Image as ImageT } from '@prisma/client' +import type { UpdateCmsImageAction } from '@/cms/images/types' type PropTypes = { currentImage: ImageT, cmsImageId: number, currentImageSize: ImageSize, + updateCmsImageAction: UpdateCmsImageAction } -export default function ChangeImage({ currentImage, cmsImageId, currentImageSize }: PropTypes) { +export default function ChangeImage({ currentImage, cmsImageId, currentImageSize, updateCmsImageAction }: PropTypes) { const selectedContext = useContext(ImageSelectionContext) if (!selectedContext) throw new Error('ImageSelectionContext required to use ChangeImage') @@ -62,15 +64,16 @@ export default function ChangeImage({ currentImage, cmsImageId, currentImageSize image name: {currentImage.name} { selectedContext.selectedImage && selectedContext.selectedImage.id !== currentImage.id ? ( - + ) : (

Resolution: {currentImageSize.toLowerCase()}

diff --git a/src/app/_components/Cms/CmsImage/CmsImage.tsx b/src/app/_components/Cms/CmsImage/CmsImage.tsx index 514ddb69c..216b46700 100644 --- a/src/app/_components/Cms/CmsImage/CmsImage.tsx +++ b/src/app/_components/Cms/CmsImage/CmsImage.tsx @@ -3,13 +3,14 @@ import styles from './CmsImage.module.scss' import Image, { SrcImage } from '@/components/Image/Image' import { readSpecialImageAction } from '@/services/images/actions' import React from 'react' -import type { ExpandedCmsImage } from '@/cms/images/types' +import type { ExpandedCmsImage, UpdateCmsImageAction } from '@/cms/images/types' import type { PropTypes as ImagePropTypes } from '@/components/Image/Image' export type PropTypes = Omit< ImagePropTypes, 'className' | 'imageSize' | 'smallSize' | 'largeSize' | 'image' | 'children' > & { cmsImage: ExpandedCmsImage, + updateCmsImageAction: UpdateCmsImageAction, children?: React.ReactNode className?: string classNameImage?: string @@ -29,6 +30,7 @@ export const fallbackImage = '/images/fallback.jpg' */ export default async function CmsImage({ cmsImage, + updateCmsImageAction, children, className = '', classNameImage, @@ -44,7 +46,10 @@ export default async function CmsImage({ return (
- {!disableEditor && } + {!disableEditor && }
{children}
diff --git a/src/app/_components/Cms/CmsImage/CmsImageClient.tsx b/src/app/_components/Cms/CmsImage/CmsImageClient.tsx index fa544f701..b17d3187a 100644 --- a/src/app/_components/Cms/CmsImage/CmsImageClient.tsx +++ b/src/app/_components/Cms/CmsImage/CmsImageClient.tsx @@ -19,6 +19,7 @@ import type { Image as ImageT } from '@prisma/client' */ export default function CmsImageClient({ cmsImage, + updateCmsImageAction, children, className = '', classNameImage, @@ -38,7 +39,10 @@ export default function CmsImageClient({ return (
- {(image && !disableEditor) && } + {(image && !disableEditor) && }
{children}
{image && (cmsImage.image.collectionId) @@ -66,9 +68,14 @@ export default function CmsImageEditor({ cmsImage }: PropTypes) { currentImageSize={cmsImage.imageSize} currentImage={cmsImage.image} cmsImageId={cmsImage.id} + updateCmsImageAction={updateCmsImageAction} />
- +
diff --git a/src/app/_components/Cms/CmsImage/SpecialCmsImage.tsx b/src/app/_components/Cms/CmsImage/SpecialCmsImage.tsx index 0def3826d..b0f1394b3 100644 --- a/src/app/_components/Cms/CmsImage/SpecialCmsImage.tsx +++ b/src/app/_components/Cms/CmsImage/SpecialCmsImage.tsx @@ -1,10 +1,12 @@ import CmsImage from './CmsImage' -import { readSpecialCmsImageAction } from '@/services/cms/images/actions' +import { configureAction } from '@/services/configureAction' import type { SpecialCmsImage as SpecialCmsImageT } from '@prisma/client' import type { PropTypes as CmsImageProps } from './CmsImage' +import type { ReadSpecialCmsImageAction } from '@/cms/images/types' export type PropTypes = Omit & { - special: SpecialCmsImageT + special: SpecialCmsImageT, + readSpecialCmsImageAction: ReadSpecialCmsImageAction } /** * WARNING: This component is only meant for the server - use SpecialCmsImageClient for the client @@ -12,8 +14,8 @@ export type PropTypes = Omit & { * @param special - the special cms image to display * @returns */ -export default async function SpecialCmsImage({ special, ...props }: PropTypes) { - const imageRes = await readSpecialCmsImageAction(special) +export default async function SpecialCmsImage({ special, readSpecialCmsImageAction, ...props }: PropTypes) { + const imageRes = await configureAction(readSpecialCmsImageAction, { params: { special } })() if (!imageRes.success) throw new Error(`No special cms image found for ${special}`) const cmsImage = imageRes.data diff --git a/src/app/_components/Cms/CmsImage/SpecialCmsImageClient.tsx b/src/app/_components/Cms/CmsImage/SpecialCmsImageClient.tsx index f3ae1377d..443d1d515 100644 --- a/src/app/_components/Cms/CmsImage/SpecialCmsImageClient.tsx +++ b/src/app/_components/Cms/CmsImage/SpecialCmsImageClient.tsx @@ -1,7 +1,7 @@ 'use client' import CmsImageClient from './CmsImageClient' -import { readSpecialCmsImageAction } from '@/services/cms/images/actions' import useActionCall from '@/hooks/useActionCall' +import { configureAction } from '@/services/configureAction' import { useCallback } from 'react' import type { PropTypes } from './SpecialCmsImage' @@ -11,14 +11,22 @@ import type { PropTypes } from './SpecialCmsImage' * @param special - the special cms image to display * @returns */ -export default function SpecialCmsImageClient({ special, ...props }: PropTypes) { - const action = useCallback(() => readSpecialCmsImageAction(special), [special]) +export default function SpecialCmsImageClient({ + special, + updateCmsImageAction, + readSpecialCmsImageAction, + ...props +}: PropTypes) { + const action = useCallback(configureAction( + readSpecialCmsImageAction, + { params: { special } } + ), [special]) const { data: cmsImage, error } = useActionCall(action) if (error) throw new Error(`No special cms image found for ${special}`) return ( cmsImage && ( - + ) ) } diff --git a/src/app/_components/Cms/CmsLink/CmsLink.tsx b/src/app/_components/Cms/CmsLink/CmsLink.tsx index 9c0197c50..6c74e4d45 100644 --- a/src/app/_components/Cms/CmsLink/CmsLink.tsx +++ b/src/app/_components/Cms/CmsLink/CmsLink.tsx @@ -2,18 +2,20 @@ import styles from './CmsLink.module.scss' import CmsLinkEditor from './CmsLinkEditor' import Link from 'next/link' import type { CmsLink as CmsLinkT } from '@prisma/client' +import type { UpdateCmsLinkAction } from '@/cms/links/types' type PropTypes = { cmsLink: CmsLinkT className?: string color?: 'primary' | 'secondary' + updateCmsLinkAction: UpdateCmsLinkAction } -export default function CmsLink({ cmsLink, className, color = 'secondary' }: PropTypes) { +export default function CmsLink({ cmsLink, className, color = 'secondary', updateCmsLinkAction }: PropTypes) { return (
{cmsLink.text} - +
) } diff --git a/src/app/_components/Cms/CmsLink/CmsLinkEditor.tsx b/src/app/_components/Cms/CmsLink/CmsLinkEditor.tsx index a683fea17..5a5abba9e 100644 --- a/src/app/_components/Cms/CmsLink/CmsLinkEditor.tsx +++ b/src/app/_components/Cms/CmsLink/CmsLinkEditor.tsx @@ -3,17 +3,19 @@ import styles from './CmsLinkEditor.module.scss' import TextInput from '@/components/UI/TextInput' import EditOverlay from '@/cms/EditOverlay' import Form from '@/components/Form/Form' -import { updateCmsLinkAction } from '@/cms/links/actions' import PopUp from '@/components/PopUp/PopUp' import useEditing from '@/hooks/useEditing' +import { configureAction } from '@/services/configureAction' import { useRouter } from 'next/navigation' import type { CmsLink } from '@prisma/client' +import type { UpdateCmsLinkAction } from '@/cms/links/types' type PropTypes = { cmsLink: CmsLink + updateCmsLinkAction: UpdateCmsLinkAction } -export default function CmsLinkEditor({ cmsLink }: PropTypes) { +export default function CmsLinkEditor({ cmsLink, updateCmsLinkAction }: PropTypes) { const canEdit = useEditing({}) //TODO: check visibility of cmsLink for user and pass it to useEditing const { refresh } = useRouter() if (!canEdit) return null @@ -27,7 +29,12 @@ export default function CmsLinkEditor({ cmsLink }: PropTypes) { }> diff --git a/src/app/_components/Cms/CmsParagraph/CmsParagraph.tsx b/src/app/_components/Cms/CmsParagraph/CmsParagraph.tsx index a83623405..b2ee4f161 100644 --- a/src/app/_components/Cms/CmsParagraph/CmsParagraph.tsx +++ b/src/app/_components/Cms/CmsParagraph/CmsParagraph.tsx @@ -2,13 +2,15 @@ import styles from './CmsParagraph.module.scss' import ParagraphEditor from './CmsParagraphEditor' import React from 'react' import type { CmsParagraph as CmsParagraphT } from '@prisma/client' +import type { UpdateCmsParagraphAction } from '@/cms/paragraphs/types' export type PropTypes = { cmsParagraph: CmsParagraphT className?: string + updateCmsParagraphAction: UpdateCmsParagraphAction } -export default function CmsParagraph({ cmsParagraph, className }: PropTypes) { +export default function CmsParagraph({ cmsParagraph, className, updateCmsParagraphAction }: PropTypes) { return ( <>
@@ -20,7 +22,7 @@ export default function CmsParagraph({ cmsParagraph, className }: PropTypes) { ) : ( Her var det ikke noe innhold )} - +
) diff --git a/src/app/_components/Cms/CmsParagraph/CmsParagraphEditor.tsx b/src/app/_components/Cms/CmsParagraph/CmsParagraphEditor.tsx index 373f1e248..ba7e42399 100644 --- a/src/app/_components/Cms/CmsParagraph/CmsParagraphEditor.tsx +++ b/src/app/_components/Cms/CmsParagraph/CmsParagraphEditor.tsx @@ -4,13 +4,14 @@ import EditOverlay from '@/components/Cms/EditOverlay' import Form from '@/components/Form/Form' import PopUp from '@/components/PopUp/PopUp' import useEditing from '@/hooks/useEditing' -import { updateCmsParagraphAction } from '@/services/cms/paragraphs/actions' +import { configureAction } from '@/services/configureAction' import { useState } from 'react' import { useRouter } from 'next/navigation' import 'easymde/dist/easymde.min.css' import './CustomEditorClasses.scss' import dynamic from 'next/dynamic' import type { CmsParagraph } from '@prisma/client' +import type { UpdateCmsParagraphAction } from '@/cms/paragraphs/types' //needed because SimpleMDE is not SSR compatible as it access navigator object const DynamicSimpleMDEditor = dynamic( @@ -24,9 +25,10 @@ const DynamicSimpleMDEditor = dynamic( type PropTypes = { cmsParagraph: CmsParagraph editorClassName?: string + updateCmsParagraphAction: UpdateCmsParagraphAction } -export default function CmsParagraphEditor({ cmsParagraph, editorClassName }: PropTypes) { +export default function CmsParagraphEditor({ cmsParagraph, editorClassName, updateCmsParagraphAction }: PropTypes) { const canEdit = useEditing({}) //TODO: pass visibility / permissions to useEditing const { refresh } = useRouter() const [content, setContent] = useState(cmsParagraph.contentMd) @@ -37,6 +39,8 @@ export default function CmsParagraphEditor({ cmsParagraph, editorClassName }: Pr setContent(value) } + const action = configureAction(updateCmsParagraphAction, { params: { paragraphId: cmsParagraph.id } }) + return ( { refresh() diff --git a/src/app/_components/Cms/CmsParagraph/SpecialCmsParagraph.tsx b/src/app/_components/Cms/CmsParagraph/SpecialCmsParagraph.tsx index 84bf5482b..589dfa39f 100644 --- a/src/app/_components/Cms/CmsParagraph/SpecialCmsParagraph.tsx +++ b/src/app/_components/Cms/CmsParagraph/SpecialCmsParagraph.tsx @@ -1,11 +1,13 @@ import CmsParagraph from './CmsParagraph' -import { readSpecialCmsParagraphAction } from '@/services/cms/paragraphs/actions' +import { configureAction } from '@/services/configureAction' import React from 'react' import type { PropTypes as PropTypesCmsParapraph } from './CmsParagraph' import type { SpecialCmsParagraph as SpecialCmsParagraphT } from '@prisma/client' +import type { ReadSpecialCmsParagraphAction } from '@/cms/paragraphs/types' type PropTypes = Omit & { - special: SpecialCmsParagraphT + special: SpecialCmsParagraphT, + readSpecialCmsParagraphAction: ReadSpecialCmsParagraphAction } /** @@ -16,10 +18,12 @@ type PropTypes = Omit & { * A component that reads a special type of paragraph using readSpecialCmsParagraphAction * then renders it using standard CmsParagraph * @param special - the special type of the paragraph to read + * @param readSpecialCmsParagraphAction - the action to read the special paragraph - this should be the specific + * implementation of the readSpecial service. * @returns */ -export default async function SpecialCmsParagraph({ special, ...props }: PropTypes) { - const res = await readSpecialCmsParagraphAction(special) +export default async function SpecialCmsParagraph({ special, readSpecialCmsParagraphAction, ...props }: PropTypes) { + const res = await configureAction(readSpecialCmsParagraphAction, { params: { special } })() if (!res.success) return Error: {res.error && res.error[0].message} return ( diff --git a/src/app/_components/Cms/PublicArticle/PublicArticle.tsx b/src/app/_components/Cms/PublicArticle/PublicArticle.tsx new file mode 100644 index 000000000..a9ac75005 --- /dev/null +++ b/src/app/_components/Cms/PublicArticle/PublicArticle.tsx @@ -0,0 +1,66 @@ +import Article, { type PropTypes } from '@/cms/Article/Article' +import { configureAction } from '@/services/configureAction' +import { + updatePublicArticleAction, + updatePublicArticleAddSectionAction, + updatePublicArticleCmsImageAction, + updatePublicArticleCmsLinkAction, + updatePublicArticleCmsParagraphAction, + updatePublicArticleCoverImageAction, + updatePublicArticleReorderSectionsAction, + updatePublicArticleSectionAction, + updatePublicArticleSectionsAddPartAction, + updatePublicArticleSectionsRemovePartAction +} from '@/services/publicArticles/actions' +import React from 'react' + +function PublicArticle(props: Omit) { + return ( +
+ ) +} + +export default PublicArticle diff --git a/src/app/_components/CommitteeImage/CommitteeImage.tsx b/src/app/_components/CommitteeImage/CommitteeImage.tsx index 11d14840b..53f82e946 100644 --- a/src/app/_components/CommitteeImage/CommitteeImage.tsx +++ b/src/app/_components/CommitteeImage/CommitteeImage.tsx @@ -1,6 +1,8 @@ import styles from './CommitteeImage.module.scss' import CmsImage from '@/cms/CmsImage/CmsImage' import Image from '@/components/Image/Image' +import { configureAction } from '@/services/configureAction' +import { updateCommitteeArticleCoverImageAction } from '@/services/groups/committees/actions' import type { ReactNode } from 'react' import type { Image as ImageT } from '@prisma/client' import type { ExpandedCmsImage } from '@/cms/images/types' @@ -9,7 +11,8 @@ type PropTypes = { children?: ReactNode logoImage: ImageT coverImage: ExpandedCmsImage - grayScale?: boolean + grayScale?: boolean, + shortName: string } /** * A component that renders a backdrop image with a content div on top of it @@ -17,7 +20,13 @@ type PropTypes = { * @param image - The image to render as a backdrop * @param grayScale - Whether the image should be rendered in grayscale (true by default) * */ -export default function CommitteeImage({ children, logoImage, coverImage, grayScale = false }: PropTypes) { +export default function CommitteeImage({ + children, + logoImage, + coverImage, + shortName, + grayScale = false +}: PropTypes) { return (
@@ -32,6 +41,10 @@ export default function CommitteeImage({ children, logoImage, coverImage, graySc />
{asClient ? @@ -48,12 +56,15 @@ export default function Company({ className={squareLogo ? styles.logoSq : styles.logo} cmsImage={company.logo} width={logoWidth} + updateCmsImageAction={updateCmsImageAction} + /> : }
@@ -64,7 +75,7 @@ export default function Company({
- +

Linjeforeningen for Elektronisk Systemdesign og Innovasjon (MTELSYS) og Kybernetikk og @@ -15,7 +21,12 @@ function Footer() {

Org. Nr. 890 384 692

- +
@@ -39,10 +50,20 @@ function Footer() {

7491 Trondheim

- + - +
diff --git a/src/app/_components/Form/Form.tsx b/src/app/_components/Form/Form.tsx index aaac3a3d8..49ba08c99 100644 --- a/src/app/_components/Form/Form.tsx +++ b/src/app/_components/Form/Form.tsx @@ -9,7 +9,7 @@ import { useRouter } from 'next/navigation' import type { PopUpKeyType } from '@/contexts/PopUp' import type { Colors, Confirmation } from '@/components/UI/SubmitButton' import type { FormHTMLAttributes, ReactNode, DetailedHTMLProps } from 'react' -import type { Action } from '@/services/actionTypes' +import type { ActionFormData } from '@/services/actionTypes' import type { ErrorMessage } from '@/services/error' type FormType = DetailedHTMLProps, HTMLFormElement> @@ -19,7 +19,7 @@ export type PropTypes = Omit & { submitText?: string, submitColor?: Colors, confirmation?: Confirmation, - action: Action, + action: ActionFormData, successCallback?: (data?: ReturnType) => void, refreshOnSuccess?: boolean, navigateOnSuccess?: string | ((data?: ReturnType) => string | null), diff --git a/src/app/_components/Loader/Loader.tsx b/src/app/_components/Loader/Loader.tsx index 640dfcded..c1b49ffb6 100644 --- a/src/app/_components/Loader/Loader.tsx +++ b/src/app/_components/Loader/Loader.tsx @@ -1,10 +1,17 @@ import styles from './Loader.module.scss' +import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions' import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage' function Loader() { return (
- +
) } diff --git a/src/app/_components/NavBar/MobileNavBar.tsx b/src/app/_components/NavBar/MobileNavBar.tsx index 183288f58..996fd33c8 100644 --- a/src/app/_components/NavBar/MobileNavBar.tsx +++ b/src/app/_components/NavBar/MobileNavBar.tsx @@ -4,6 +4,7 @@ import Menu from './Menu' import UserNavigation from './UserNavigation' import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage' import EditModeSwitch from '@/components/EditModeSwitch/EditModeSwitch' +import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions' import Link from 'next/link' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faBars } from '@fortawesome/free-solid-svg-icons' @@ -30,7 +31,12 @@ export default async function MobileNavBar({ profile }: PropTypes) { )) }
- +
@@ -41,6 +47,8 @@ export default async function MobileNavBar({ profile }: PropTypes) { height={25} alt="log in button" className={styles.image} + readSpecialCmsImageAction={readSpecialCmsImageFrontpage} + updateCmsImageAction={updateSpecialCmsImageFrontpage} />
diff --git a/src/app/_components/NavBar/NavBar.tsx b/src/app/_components/NavBar/NavBar.tsx index d58c22838..a71f8b064 100644 --- a/src/app/_components/NavBar/NavBar.tsx +++ b/src/app/_components/NavBar/NavBar.tsx @@ -6,6 +6,7 @@ import UserNavigation from './UserNavigation' import ReportButton from './ReportButton' import EditModeSwitch from '@/components/EditModeSwitch/EditModeSwitch' import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage' +import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions' import Link from 'next/link' import type { Profile } from '@/services/users/types' @@ -34,6 +35,8 @@ export default async function NavBar({ profile }: PropTypes) { special="NAV_PRIMARY_BUTTON" width={30} alt="omega logo" + readSpecialCmsImageAction={readSpecialCmsImageFrontpage} + updateCmsImageAction={updateSpecialCmsImageFrontpage} >
@@ -58,6 +61,8 @@ export default async function NavBar({ profile }: PropTypes) { width={25} height={25} alt="log in button" + readSpecialCmsImageAction={readSpecialCmsImageFrontpage} + updateCmsImageAction={updateSpecialCmsImageFrontpage} />
diff --git a/src/app/_components/School/School.tsx b/src/app/_components/School/School.tsx index b55a62957..50af71b9a 100644 --- a/src/app/_components/School/School.tsx +++ b/src/app/_components/School/School.tsx @@ -3,6 +3,12 @@ import CmsImageClient from '@/cms/CmsImage/CmsImageClient' import CmsLink from '@/cms/CmsLink/CmsLink' import CmsImage from '@/cms/CmsImage/CmsImage' import CmsParagraph from '@/cms/CmsParagraph/CmsParagraph' +import { + updateSchoolCmsImageAction, + updateSchoolCmsLinkAction, + updateSchoolCmsParagraphContentAction +} from '@/services/education/schools/actions' +import { configureAction } from '@/services/configureAction' import type { ExpandedSchool } from '@/services/education/schools/types' type PropTypes = { @@ -11,6 +17,11 @@ type PropTypes = { } export default function School({ school, asClient = false }: PropTypes) { + const updateCmsImageAction = configureAction( + updateSchoolCmsImageAction, + { implementationParams: { shortName: school.shortName } } + ) + return (
{ @@ -20,21 +31,41 @@ export default function School({ school, asClient = false }: PropTypes) { classNameImage={styles.image} cmsImage={school.cmsImage} width={200} + updateCmsImageAction={updateCmsImageAction} /> ) : }
-

{school.name}

({school.shortname})

+

{school.name}

({school.shortName})

- - + +
) diff --git a/src/app/_components/School/SchoolListRenderer.tsx b/src/app/_components/School/SchoolListRenderer.tsx index 204cdfd90..ca8826a69 100644 --- a/src/app/_components/School/SchoolListRenderer.tsx +++ b/src/app/_components/School/SchoolListRenderer.tsx @@ -8,4 +8,4 @@ import type { ExpandedSchool } from '@/services/education/schools/types' */ // eslint-disable-next-line react/display-name export const schoolListRenderer = (asClient: boolean) => (school: ExpandedSchool) => - + diff --git a/src/app/admin/cabin-booking/[booking]/page.tsx b/src/app/admin/cabin-booking/[booking]/page.tsx index a1c2cf1e0..1e0f7453e 100644 --- a/src/app/admin/cabin-booking/[booking]/page.tsx +++ b/src/app/admin/cabin-booking/[booking]/page.tsx @@ -3,9 +3,9 @@ import PageWrapper from '@/app/_components/PageWrapper/PageWrapper' import SimpleTable from '@/app/_components/Table/SimpleTable' import { unwrapActionReturn } from '@/app/redirectToErrorPage' import { displayDate } from '@/lib/dates/displayDate' +import { formatVevenUri } from '@/lib/urlEncoding' import Link from 'next/link' import React from 'react' -import { formatVevenUri } from '@/lib/urlEncoding' function trHelper(key: string, value: React.ReactNode) { return diff --git a/src/app/admin/schools/SchoolAdminList.tsx b/src/app/admin/schools/SchoolAdminList.tsx index 7bc81de33..108ac927b 100644 --- a/src/app/admin/schools/SchoolAdminList.tsx +++ b/src/app/admin/schools/SchoolAdminList.tsx @@ -18,11 +18,11 @@ export async function SchoolAdminList({ schools }: PropTypes) { {schools.map(school => ( - + {school.id} {school.name} - {school.shortname} + {school.shortName} ))} diff --git a/src/app/admin/schools/[shortname]/UpdateSchool.tsx b/src/app/admin/schools/[shortname]/UpdateSchool.tsx index a3cdb1249..ee1709444 100644 --- a/src/app/admin/schools/[shortname]/UpdateSchool.tsx +++ b/src/app/admin/schools/[shortname]/UpdateSchool.tsx @@ -15,10 +15,10 @@ export default function UpdateSchool({ school }: PropTypes) { (data ? `/admin/schools/${data.shortname}` : '/admin/schools')} + navigateOnSuccess={data => (data ? `/admin/schools/${data.shortName}` : '/admin/schools')} > - + ) } diff --git a/src/app/admin/schools/[shortname]/page.tsx b/src/app/admin/schools/[shortname]/page.tsx index 411e11e33..0ac01b867 100644 --- a/src/app/admin/schools/[shortname]/page.tsx +++ b/src/app/admin/schools/[shortname]/page.tsx @@ -7,14 +7,14 @@ import School from '@/components/School/School' type PropTypes = { params: Promise<{ - shortname: string + shortName: string }> } export default async function SchoolAdmin({ params }: PropTypes) { - const shortname = decodeURIComponent((await params).shortname) + const shortName = decodeURIComponent((await params).shortName) - const res = await readSchoolAction(shortname) + const res = await readSchoolAction({ params: { shortName } }) if (!res.success) throw new Error(res.error?.length ? res.error[0].message : 'Unknown error') const school = res.data diff --git a/src/app/admin/schools/page.tsx b/src/app/admin/schools/page.tsx index e57c16746..fed83ad0a 100644 --- a/src/app/admin/schools/page.tsx +++ b/src/app/admin/schools/page.tsx @@ -25,7 +25,7 @@ export default async function SchoolsAdmin() { refreshOnSuccess > - + }> diff --git a/src/app/applications/[periodName]/countdown/CommitteeLogoRoll.tsx b/src/app/applications/[periodName]/countdown/CommitteeLogoRoll.tsx index c631ad008..86039f1a9 100644 --- a/src/app/applications/[periodName]/countdown/CommitteeLogoRoll.tsx +++ b/src/app/applications/[periodName]/countdown/CommitteeLogoRoll.tsx @@ -8,7 +8,7 @@ import type { Image as ImageT } from '@prisma/client' type PropTypes = { committees: { - shortname: string, + shortName: string, logo: ImageT }[], periodName: string @@ -100,7 +100,7 @@ export default function CommitteeLogoRoll({ committees, periodName }: PropTypes) ) : ( ) } @@ -115,7 +115,7 @@ export default function CommitteeLogoRoll({ committees, periodName }: PropTypes) ) : ( ) } @@ -130,7 +130,7 @@ export default function CommitteeLogoRoll({ committees, periodName }: PropTypes) ) : ( ) } @@ -141,11 +141,11 @@ export default function CommitteeLogoRoll({ committees, periodName }: PropTypes) } -function Display({ image, shortname }: { image: ImageT, shortname: string }) { +function Display({ image, shortName }: { image: ImageT, shortName: string }) { return ( <> - {shortname} + {shortName} ) } diff --git a/src/app/applications/[periodName]/countdown/Countdown.tsx b/src/app/applications/[periodName]/countdown/Countdown.tsx index 4b991fefc..090c44e8b 100644 --- a/src/app/applications/[periodName]/countdown/Countdown.tsx +++ b/src/app/applications/[periodName]/countdown/Countdown.tsx @@ -38,7 +38,7 @@ export default function Countdown({ period, defaultCommitteeLogo }: PropTypes) { {showCommitteeRoll && ( ({ - shortname: part.committee.shortName, + shortName: part.committee.shortName, logo: part.committee.logoImage.image || defaultCommitteeLogo }))} /> )} diff --git a/src/app/applications/[periodName]/page.tsx b/src/app/applications/[periodName]/page.tsx index 1e4662621..5813a4af2 100644 --- a/src/app/applications/[periodName]/page.tsx +++ b/src/app/applications/[periodName]/page.tsx @@ -18,13 +18,14 @@ import { destroyApplicationAction, readApplicationsForUserAction } from '@/services/applications/actions' -import { readCommitteesAction } from '@/services/groups/committees/actions' +import { readAllCommitteesAction, updateCommitteeParagraphAction } from '@/services/groups/committees/actions' import { destroyApplicationPeriodAction, removeAllApplicationTextsAction, readApplicationPeriodAction } from '@/services/applications/periods/actions' import { readSpecialImageAction } from '@/services/images/actions' +import { configureAction } from '@/services/configureAction' import { faVideo } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Link from 'next/link' @@ -46,7 +47,7 @@ export default async function ApplicationPeriod({ params }: PropTypes) { const applications = userId ? unwrapActionReturn( await readApplicationsForUserAction({ params: { userId, periodId: period.id } }) ) : [] - const committees = unwrapActionReturn(await readCommitteesAction()) + const committees = unwrapActionReturn(await readAllCommitteesAction()) const periodWithApplications = { ...period, @@ -162,6 +163,12 @@ export default async function ApplicationPeriod({ params }: PropTypes) {

{part.committee.name}

{ diff --git a/src/app/applications/page.tsx b/src/app/applications/page.tsx index 03080cc82..46666edd6 100644 --- a/src/app/applications/page.tsx +++ b/src/app/applications/page.tsx @@ -5,11 +5,11 @@ import { readApplicationPeriodsAction } from '@/services/applications/periods/ac import PageWrapper from '@/components/PageWrapper/PageWrapper' import Date from '@/components/Date/Date' import { AddHeaderItemPopUp } from '@/components/HeaderItems/HeaderItemPopUp' -import { readCommitteesAction } from '@/services/groups/committees/actions' +import { readAllCommitteesAction } from '@/services/groups/committees/actions' -export default async function Apllications() { +export default async function Applications() { const periods = unwrapActionReturn(await readApplicationPeriodsAction()) - const committees = unwrapActionReturn(await readCommitteesAction()) + const committees = unwrapActionReturn(await readAllCommitteesAction()) return (
  • @@ -68,7 +78,10 @@ export default function EditCategory({ category }: PropTypes) {
  • { - const res = await destroyArticleAction(id) + const res = await removeArticleFromCategoryAction({ params: { id: category.id, articleId: id } }) if (!res.success) throw new Error('could not destroy article') push(`/articles/${category.name}`) refresh() @@ -89,7 +90,7 @@ function MainListContent({ category }: { category: ExpandedArticleCategory }) { { category.articles.map(article => (
  • - + {article.name.toUpperCase()} { diff --git a/src/app/articles/[category]/[name]/page.module.scss b/src/app/articles/[category]/[nameAndId]/page.module.scss similarity index 100% rename from src/app/articles/[category]/[name]/page.module.scss rename to src/app/articles/[category]/[nameAndId]/page.module.scss diff --git a/src/app/articles/[category]/[nameAndId]/page.tsx b/src/app/articles/[category]/[nameAndId]/page.tsx new file mode 100644 index 000000000..1bb79a04d --- /dev/null +++ b/src/app/articles/[category]/[nameAndId]/page.tsx @@ -0,0 +1,100 @@ +import styles from './page.module.scss' +import Article from '@/cms/Article/Article' +import { configureAction } from '@/services/configureAction' +import { + readArticleCategoryAction, + readArticleInCategoryAction, + updateArticleCategoryArticleAction, + updateArticleCategoryArticleAddSectionAction, + updateArticleCategoryArticleCmsImageAction, + updateArticleCategoryArticleCmsLinkAction, + updateArticleCategoryArticleCmsParagraphAction, + updateArticleCategoryArticleCoverImageAction, + updateArticleCategoryArticleReorderSectionsAction, + updateArticleCategoryArticleSectionAction, + updateArticleCategoryArticleSectionsAddPartAction, + updateArticleCategoryArticleSectionsRemovePartAction +} from '@/services/articleCategories/actions' +import { decodeVevenUriHandleError } from '@/lib/urlEncoding' +import { unwrapActionReturn } from '@/app/redirectToErrorPage' + +type PropTypes = { + params: Promise<{ + category: string + nameAndId: string + }>, +} + +export default async function ArticleCategoryPage({ params }: PropTypes) { + const articleId = decodeVevenUriHandleError((await params).nameAndId) + const categoryName = decodeURIComponent((await params).category) + + const articleCategory = unwrapActionReturn( + await readArticleCategoryAction({ params: { name: categoryName } }) + ) + + const article = unwrapActionReturn( + await readArticleInCategoryAction({ + implementationParams: { + articleCategoryName: categoryName + } + }, { + params: { + articleId, + } + }) + ) + + return ( +
    +
    +
    + ) +} diff --git a/src/app/articles/[category]/[name]/page.tsx b/src/app/articles/[category]/[name]/page.tsx deleted file mode 100644 index a0104c511..000000000 --- a/src/app/articles/[category]/[name]/page.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import styles from './page.module.scss' -import Article from '@/cms/Article/Article' -import { readArticleAction } from '@/cms/articles/actions' -import { notFound } from 'next/navigation' - -type PropTypes = { - params: Promise<{ - category: string - name: string - }>, -} - -export default async function ArticleCategorArticley({ params }: PropTypes) { - //This fixes æ, ø, å and spaces in the url - const name = decodeURIComponent((await params).name) - const category = decodeURIComponent((await params).category) - const res = await readArticleAction({ - name, - category - }) - if (!res.success) return notFound() - - return ( -
    -
    -
    - ) -} diff --git a/src/app/articles/[category]/layout.tsx b/src/app/articles/[category]/layout.tsx index c3539e44c..8bbc894bd 100644 --- a/src/app/articles/[category]/layout.tsx +++ b/src/app/articles/[category]/layout.tsx @@ -1,6 +1,6 @@ import styles from './layout.module.scss' import SideBar from './SideBar' -import { readArticleCategoryAction } from '@/cms/articleCategories/actions' +import { readArticleCategoryAction } from '@/services/articleCategories/actions' import { notFound } from 'next/navigation' import type { ReactNode } from 'react' @@ -13,7 +13,7 @@ type PropTypes = { export default async function ArticleCategoryLayout({ params, children }: PropTypes) { const categoryName = decodeURIComponent((await params).category) - const res = await readArticleCategoryAction(categoryName) + const res = await readArticleCategoryAction({ params: { name: categoryName } }) if (!res.success) return notFound() const category = res.data diff --git a/src/app/articles/page.tsx b/src/app/articles/page.tsx index 6e9cc1812..6fc41e7bb 100644 --- a/src/app/articles/page.tsx +++ b/src/app/articles/page.tsx @@ -2,7 +2,7 @@ import styles from './page.module.scss' import AddCategory from './AddCategory' import { AddHeaderItemPopUp } from '@/components/HeaderItems/HeaderItemPopUp' import ImageCard from '@/components/ImageCard/ImageCard' -import { readArticleCategoriesAction } from '@/cms/articleCategories/actions' +import { readArticleCategoriesAction } from '@/services/articleCategories/actions' import PageWrapper from '@/components/PageWrapper/PageWrapper' export default async function ArticleCategoryList() { diff --git a/src/app/cabin/book/page.tsx b/src/app/cabin/book/page.tsx index e9c115055..96a2fc06e 100644 --- a/src/app/cabin/book/page.tsx +++ b/src/app/cabin/book/page.tsx @@ -2,11 +2,14 @@ import StateWrapper from './stateWrapper' import SpecialCmsParagraph from '@/app/_components/Cms/CmsParagraph/SpecialCmsParagraph' import PageWrapper from '@/components/PageWrapper/PageWrapper' import { unwrapActionReturn } from '@/app/redirectToErrorPage' +import { default as DateComponent } from '@/components/Date/Date' import { readCabinAvailabilityAction, readCabinProductsActiveAction, readPublicPricePeriodsAction, - readReleasePeriodsAction + readReleasePeriodsAction, + readSpecialCmsParagraphCabinContractAction, + updateSpecialCmsParagraphCabinContractAction } from '@/services/cabin/actions' import { displayDate } from '@/lib/dates/displayDate' import { Session } from '@/auth/session/Session' @@ -49,8 +52,8 @@ export default async function CabinBooking() { > {nextReleasePeriod &&

    - Neste slipptid er {displayDate(nextReleasePeriod.releaseTime, false)}, - da slippes bookinger fram til {displayDate(nextReleasePeriod.releaseUntil, false)} + Neste slipptid er , + da slippes bookinger fram til

    } {pricePeriods.length > 1 && @@ -67,6 +70,10 @@ export default async function CabinBooking() { pricePeriods={pricePeriods} /> - + } diff --git a/src/app/career/jobads/[nameAndId]/EditJobAd.tsx b/src/app/career/jobads/[nameAndId]/EditJobAd.tsx index 471c97b33..6f8162f92 100644 --- a/src/app/career/jobads/[nameAndId]/EditJobAd.tsx +++ b/src/app/career/jobads/[nameAndId]/EditJobAd.tsx @@ -13,10 +13,10 @@ import CompanyChooser from '@/app/career/jobads/CompanyChooser' import { destroyJobAdAction, updateJobAdAction } from '@/career/jobAds/actions' import { jobAdOptions } from '@/services/career/jobAds/constants' import { configureAction } from '@/services/configureAction' +import { formatVevenUri } from '@/lib/urlEncoding' import { v4 as uuid } from 'uuid' import { useContext, type ReactNode } from 'react' import type { ExpandedJobAd } from '@/services/career/jobAds/types' -import { formatVevenUri } from '@/lib/urlEncoding' type PropTypes = { jobAd: ExpandedJobAd diff --git a/src/app/career/jobads/[nameAndId]/page.tsx b/src/app/career/jobads/[nameAndId]/page.tsx index 8aa7198ec..5c32122a2 100644 --- a/src/app/career/jobads/[nameAndId]/page.tsx +++ b/src/app/career/jobads/[nameAndId]/page.tsx @@ -1,4 +1,3 @@ - import styles from './page.module.scss' import EditJobAd from './EditJobAd' import Article from '@/components/Cms/Article/Article' @@ -7,8 +6,22 @@ import { CompanyPagingProvider } from '@/contexts/paging/CompanyPaging' import Company from '@/components/Company/Company' import Date from '@/components/Date/Date' import { Session } from '@/auth/session/Session' -import { readJobAdAction } from '@/services/career/jobAds/actions' +import { + readJobAdAction, + updateJobAdArticleAction, + updateJobAdArticleAddSectionAction, + updateJobAdArticleCmsImageAction, + updateJobAdArticleCmsLinkAction, + updateJobAdArticleCmsParagraphAction, + updateJobAdArticleCoverImageAction, + updateJobAdArticleReorderSectionsAction, + updateJobAdArticleSectionAction, + updateJobAdArticleSectionsAddPartAction, + updateJobAdArticleSectionsRemovePartAction +} from '@/services/career/jobAds/actions' import { jobAdType } from '@/services/career/jobAds/constants' +import { decodeVevenUriHandleError } from '@/lib/urlEncoding' +import { configureAction } from '@/services/configureAction' import { notFound } from 'next/navigation' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { @@ -19,7 +32,6 @@ import { faSuitcase, faXmarkCircle } from '@fortawesome/free-solid-svg-icons' -import { decodeVevenUriHandleError } from '@/lib/urlEncoding' type PropTypes = { params: Promise<{ @@ -27,7 +39,6 @@ type PropTypes = { }> } - export default async function JobAd({ params }: PropTypes) { const nameAndId = (await params).nameAndId @@ -42,54 +53,101 @@ export default async function JobAd({ params }: PropTypes) { return (
    -
    -
      -
    • - -

      Stillingstype

      -

      {jobAdType[jobAd.type].label}

      -
    • -
    • - -

      Status

      -

      {jobAd.active ? 'Denne jobbanonsen er aktiv' : 'Denne jobbanonsen er arkivert'}

      -
    • -
    • - -

      Søknadsfrist

      -

      - { jobAd.applicationDeadline ? - : - 'Ingen søknadsfrist satt' - } -

      -
    • -
    • - -

      Publisert

      -

      - -

      -
    • -
    • - -

      Sted

      -

      {jobAd.location}

      -
    • -
    -
    -

    Arbeidsgiver

    - -
    - - } /> +
    +
      +
    • + +

      Stillingstype

      +

      {jobAdType[jobAd.type].label}

      +
    • +
    • + +

      Status

      +

      {jobAd.active ? 'Denne jobbanonsen er aktiv' : 'Denne jobbanonsen er arkivert'}

      +
    • +
    • + +

      Søknadsfrist

      +

      + { jobAd.applicationDeadline ? + : + 'Ingen søknadsfrist satt' + } +

      +
    • +
    • + +

      Publisert

      +

      + +

      +
    • +
    • + +

      Sted

      +

      {jobAd.location}

      +
    • +
    +
    +

    Arbeidsgiver

    + +
    + + } />
    : <> + className={styles.conactorLink} + cmsLink={contactorCmsLink} + updateCmsLinkAction={updateCompanySpecialCmsLinkAction} + /> : <> }>
    - + { jobAdImage ? -
    +
    ) } diff --git a/src/app/committees/[shortName]/admin/page.tsx b/src/app/committees/[shortName]/admin/page.tsx index 5c4c4dc44..ae322933e 100644 --- a/src/app/committees/[shortName]/admin/page.tsx +++ b/src/app/committees/[shortName]/admin/page.tsx @@ -1,6 +1,8 @@ import styles from './page.module.scss' import getCommittee from '@/app/committees/[shortName]/getCommittee' import CmsImage from '@/components/Cms/CmsImage/CmsImage' +import { configureAction } from '@/services/configureAction' +import { updateCommitteeLogoAction } from '@/services/groups/committees/actions' import type { PropTypes } from '@/app/committees/[shortName]/page' export default async function ComitteeAdmin({ params }: PropTypes) { @@ -8,7 +10,16 @@ export default async function ComitteeAdmin({ params }: PropTypes) { return (

    Admin

    - +
    ) } diff --git a/src/app/committees/[shortName]/layout.tsx b/src/app/committees/[shortName]/layout.tsx index 0362fee6d..6c22a7ead 100644 --- a/src/app/committees/[shortName]/layout.tsx +++ b/src/app/committees/[shortName]/layout.tsx @@ -28,7 +28,7 @@ export default async function Committee({ params, children }: PropTypes) { return ( - +
    diff --git a/src/app/committees/[shortName]/page.tsx b/src/app/committees/[shortName]/page.tsx index 99bc321ca..5c95822e0 100644 --- a/src/app/committees/[shortName]/page.tsx +++ b/src/app/committees/[shortName]/page.tsx @@ -1,8 +1,13 @@ import styles from './page.module.scss' -import { readCommitteeMembersAction, readCommitteeParagraphAction } from '@/services/groups/committees/actions' +import { + readCommitteeMembersAction, + readCommitteeParagraphAction, + updateCommitteeParagraphAction +} from '@/services/groups/committees/actions' import { unwrapActionReturn } from '@/app/redirectToErrorPage' import CmsParagraph from '@/components/Cms/CmsParagraph/CmsParagraph' import UserCard from '@/components/User/UserCard' +import { configureAction } from '@/services/configureAction' export type PropTypes = { params: Promise<{ @@ -11,12 +16,11 @@ export type PropTypes = { } export default async function Committee({ params }: PropTypes) { - const paramsAwaited = (await params) - const paragraphRes = await readCommitteeParagraphAction({ params: paramsAwaited }) - if (!paragraphRes.success) throw new Error('Kunne ikke hente komitéparagraph') + const paragraphRes = await readCommitteeParagraphAction({ params: await params }) + if (!paragraphRes.success) throw new Error('Kunne ikke hente komitéparagrafen') const members = unwrapActionReturn(await readCommitteeMembersAction({ params: { - shortName: paramsAwaited.shortName, + shortName: (await params).shortName, active: true, }, })) @@ -25,7 +29,13 @@ export default async function Committee({ params }: PropTypes) { return (
    - +

    Komitémedlemmer

    diff --git a/src/app/committees/page.tsx b/src/app/committees/page.tsx index 1a10c1aaf..901b0edb2 100644 --- a/src/app/committees/page.tsx +++ b/src/app/committees/page.tsx @@ -1,10 +1,10 @@ import styles from './page.module.scss' import CommitteeCard from '@/components/CommitteeCard/CommitteeCard' -import { readCommitteesAction } from '@/services/groups/committees/actions' +import { readAllCommitteesAction } from '@/services/groups/committees/actions' import { readSpecialImageAction } from '@/services/images/actions' export default async function Committees() { - const res = await readCommitteesAction() + const res = await readAllCommitteesAction() if (!res.success) throw new Error(`Kunne ikke hente komiteer - ${res.errorCode}`) const committees = res.data diff --git a/src/app/error.tsx b/src/app/error.tsx index caf8380c1..830eea3fe 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -2,6 +2,7 @@ import styles from './error.module.scss' import Button from '@/components/UI/Button' import SpecialCmsImageClient from '@/components/Cms/CmsImage/SpecialCmsImageClient' +import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions' /** * note that passing custom error type to next error boundary is not supported @@ -13,7 +14,13 @@ export default function ErrorBoundary({ error, reset }: {error: unknown, reset:
    - +
    { error instanceof Error ? ( diff --git a/src/app/events/CreateOrUpdateEventForm.tsx b/src/app/events/CreateOrUpdateEventForm.tsx index 58f6b22fd..0bbed89c3 100644 --- a/src/app/events/CreateOrUpdateEventForm.tsx +++ b/src/app/events/CreateOrUpdateEventForm.tsx @@ -12,10 +12,10 @@ import { createEventAction, updateEventAction } from '@/services/events/actions' import { eventCanBeViewdByOptions } from '@/services/events/constants' import { FIELD_IS_PRESENT_VALUE } from '@/lib/fields/constants' import { configureAction } from '@/services/configureAction' +import { formatVevenUri } from '@/lib/urlEncoding' import { useState } from 'react' import type { Event, EventTag as EventTagT } from '@prisma/client' import type { ChangeEvent } from 'react' -import { formatVevenUri } from '@/lib/urlEncoding' type PropTypes = { event?: Event & { tags: EventTagT[] } diff --git a/src/app/events/[nameAndId]/page.tsx b/src/app/events/[nameAndId]/page.tsx index bf9cb04e5..c47ab9619 100644 --- a/src/app/events/[nameAndId]/page.tsx +++ b/src/app/events/[nameAndId]/page.tsx @@ -13,12 +13,17 @@ import { SettingsHeaderItemPopUp, UsersHeaderItemPopUp } from '@/components/Head import { QueryParams } from '@/lib/queryParams/queryParams' import { unwrapActionReturn } from '@/app/redirectToErrorPage' import { readEventTagsAction } from '@/services/events/tags/actions' -import { destroyEventAction, readEventAction } from '@/services/events/actions' +import { + destroyEventAction, + readEventAction, + updateEventCmsCoverImageAction, + updateEventParagraphContentAction +} from '@/services/events/actions' import { configureAction } from '@/services/configureAction' +import { decodeVevenUriHandleError } from '@/lib/urlEncoding' import Link from 'next/link' import { faCalendar, faExclamation, faLocationDot, faUsers } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { decodeVevenUriHandleError } from '@/lib/urlEncoding' type PropTypes = { params: Promise<{ @@ -40,7 +45,15 @@ export default async function Event({ params }: PropTypes) { return (
    - +
      @@ -106,7 +119,15 @@ export default async function Event({ params }: PropTypes) {
      - +
      {event.takesRegistration && ( diff --git a/src/app/interest-groups/InterestGroup.tsx b/src/app/interest-groups/InterestGroup.tsx index e58e29e66..f418b36e1 100644 --- a/src/app/interest-groups/InterestGroup.tsx +++ b/src/app/interest-groups/InterestGroup.tsx @@ -3,8 +3,18 @@ import Form from '@/components/Form/Form' import TextInput from '@/components/UI/TextInput' import ArticleSection from '@/components/Cms/ArticleSection/ArticleSection' import { SettingsHeaderItemPopUp } from '@/components/HeaderItems/HeaderItemPopUp' -import { updateInterestGroupAction, destroyInterestGroupAction } from '@/services/groups/interestGroups/actions' +import { + updateInterestGroupAction, + destroyInterestGroupAction, + updateInterestGroupArticleSectionAction, + addPartToInterestGroupArticleSectionAction, + removePartFromInterestGroupArticleSectionAction, + updateInterestGroupCmsImageAction, + updateInterestGroupCmsParagraphAction, + updateInterestGroupCmsLinkAction +} from '@/services/groups/interestGroups/actions' import { interestGroupAuth } from '@/services/groups/interestGroups/auth' +import { configureAction } from '@/services/configureAction' import type { SessionMaybeUser } from '@/auth/session/Session' import type { ExpandedInterestGroup } from '@/services/groups/interestGroups/types' @@ -19,6 +29,8 @@ export default function InterestGroup({ interestGroup, session }: PropTypes) { const PopUpKey = `Update interest group ${interestGroup.name}` + const cmsArticleActionConfig = { implementationParams: { interestGroupId: interestGroup.id } } + return (

      {interestGroup.name}

      @@ -73,7 +85,30 @@ export default function InterestGroup({ interestGroup, session }: PropTypes) { ) : <> }
      - +
    ) } diff --git a/src/app/interest-groups/page.tsx b/src/app/interest-groups/page.tsx index 76726d238..5b9edbd89 100644 --- a/src/app/interest-groups/page.tsx +++ b/src/app/interest-groups/page.tsx @@ -5,12 +5,16 @@ import PageWrapper from '@/components/PageWrapper/PageWrapper' import { AddHeaderItemPopUp } from '@/components/HeaderItems/HeaderItemPopUp' import { Session } from '@/auth/session/Session' import { interestGroupAuth } from '@/services/groups/interestGroups/auth' -import { readInterestGroupsAction } from '@/services/groups/interestGroups/actions' +import { + readInterestGroupsAction, + readSpecialCmsParagraphGeneralInfoAction, + updateSpecialCmsParagraphContentGeneralInfoAction +} from '@/services/groups/interestGroups/actions' export default async function InterestGroups() { const session = await Session.fromNextAuth() const interestGroupsRes = await readInterestGroupsAction() - if (!interestGroupsRes.success) return
    Failed to load interest groups
    //TODO: Change to unwrap + if (!interestGroupsRes.success) return
    Failed to load interest groups
    //TODO: Change to unwrap? const interestGroups = interestGroupsRes.data const canCreate = interestGroupAuth.create.dynamicFields({}).auth(session) @@ -23,7 +27,11 @@ export default async function InterestGroups() { ) }> - +
    { interestGroups.map(interestGroup => ( diff --git a/src/app/news/CurrentNews.tsx b/src/app/news/CurrentNews.tsx index cba9ac01c..d82f2cb84 100644 --- a/src/app/news/CurrentNews.tsx +++ b/src/app/news/CurrentNews.tsx @@ -8,6 +8,7 @@ type PropTypes = { /** * @param not - pass it not: a id of a news to exclude from the list + * WARNING: This component must be server-side rendered */ export default async function CurrentNews({ not }: PropTypes) { const res = await readNewsCurrentAction() diff --git a/src/app/news/[nameAndId]/EditNews.tsx b/src/app/news/[nameAndId]/EditNews.tsx index 1b387f300..2c96ffda5 100644 --- a/src/app/news/[nameAndId]/EditNews.tsx +++ b/src/app/news/[nameAndId]/EditNews.tsx @@ -6,10 +6,11 @@ import Textarea from '@/components/UI/Textarea' import DateInput from '@/components/UI/DateInput' import useEditing from '@/hooks/useEditing' import { destroyNewsAction, updateNewsAction } from '@/services/news/actions' +import { formatVevenUri } from '@/lib/urlEncoding' +import { configureAction } from '@/services/configureAction' import { useRouter } from 'next/navigation' import type { ExpandedNewsArticle } from '@/services/news/types' import type { ReactNode } from 'react' -import { formatVevenUri } from '@/lib/urlEncoding' type PropTypes = { news: ExpandedNewsArticle @@ -28,7 +29,10 @@ export default function EditNews({ news, children }: PropTypes) { // TODO: VISINILITY ADMIN - const updateAction = updateNewsAction.bind(null, news.id) + const updateAction = configureAction( + updateNewsAction, + { params: { id: news.id } } + ) return (
    @@ -53,7 +57,12 @@ export default function EditNews({ news, children }: PropTypes) {