diff --git a/backend/sql/03_create_content_tables.sql b/backend/sql/03_create_content_tables.sql index 1de8fa1..e31f77d 100644 --- a/backend/sql/03_create_content_tables.sql +++ b/backend/sql/03_create_content_tables.sql @@ -49,3 +49,20 @@ create policy select_answer for select to candymat_anonymous, candymat_person -- maybe change to candymat_person only in the future using (true); + +drop table if exists candymat_data.user_app_info; +create table candymat_data.user_app_info +( + row_id character varying(50) primary key, + title character varying(300) NOT NULL, + content character varying(15000) +); +grant select on table candymat_data.user_app_info to candymat_anonymous, candymat_person; +grant insert, update, delete on table candymat_data.user_app_info to candymat_editor; +delete from candymat_data.user_app_info where row_id = 'about_page'; +insert into candymat_data.user_app_info (row_id, title, content) values +('about_page', 'About Candymat', '

Wer steckt eigentlich hinter dem Kandimat?

Der Kandimat wurde von den ehrenamtlichen Mitgliedern des Netzbegrünung e.V. entwickelt. Eure Geschäftsstelle und die Kandidat*innen haben die redaktionelle Arbeit für die Inhalte des Kandimats geleistet.

'); +insert into candymat_data.user_app_info (row_id, title, content) values +('contact_page', 'Contact Candymat', '

Kontakt

Kontakt Infos

'); +insert into candymat_data.user_app_info (row_id, title, content) values +('legal_page', 'Legal Candymat', '

Impressum

Impressum Infos

'); diff --git a/redaktions-app/src/backend/queries/page_info.ts b/redaktions-app/src/backend/queries/page_info.ts new file mode 100644 index 0000000..06ec5f2 --- /dev/null +++ b/redaktions-app/src/backend/queries/page_info.ts @@ -0,0 +1,26 @@ +import { gql } from "@apollo/client"; + +export const GET_ALL_PAGE_INFO = gql` + query AllInfos { + allUserAppInfos { + nodes { + id + rowId + title + content + } + } + } +`; + +export interface GetAllPageInfoResponse { + allUserAppInfos: { + nodes: Array<{ + id: string; + rowId: string; + title: string; + content: string; + }>; + __typename: "UserAppInfosConnection"; + }; +} diff --git a/redaktions-app/src/components/EditInformation.tsx b/redaktions-app/src/components/EditInformation.tsx index 3baa207..fab7d52 100644 --- a/redaktions-app/src/components/EditInformation.tsx +++ b/redaktions-app/src/components/EditInformation.tsx @@ -2,7 +2,10 @@ import React from "react"; import { Paper, Typography } from "@material-ui/core"; import { makeStyles } from "@material-ui/core/styles"; import { useQuery } from "@apollo/client"; -import { BasicPersonResponse } from "../backend/queries/person"; +import { + GET_ALL_PAGE_INFO, + GetAllPageInfoResponse, +} from "../backend/queries/page_info"; const useStyles = makeStyles((theme) => ({ root: { @@ -27,6 +30,11 @@ interface EditInformationProps { export function EditInformation( props: EditInformationProps ): React.ReactElement { + const infos = + useQuery(GET_ALL_PAGE_INFO).data + ?.allUserAppInfos.nodes || []; + const about = infos.find((info) => info.rowId === "about_page"); + const legal = infos.find((info) => info.rowId === "legal_page"); const classes = useStyles(); return ( @@ -37,26 +45,20 @@ export function EditInformation( {/* eslint-disable-next-line react/no-unescaped-entities */} - Der "Über Uns" Text: + {about?.title || ""}
-
{/* eslint-disable-next-line react/no-unescaped-entities */} - Der "Impressum" Text: + {legal?.title || ""}
-