Added datastructure and gql queries, added dynamic info
This commit is contained in:
parent
56691a3135
commit
ee23820cce
|
@ -49,3 +49,20 @@ create policy select_answer
|
||||||
for select
|
for select
|
||||||
to candymat_anonymous, candymat_person -- maybe change to candymat_person only in the future
|
to candymat_anonymous, candymat_person -- maybe change to candymat_person only in the future
|
||||||
using (true);
|
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', '<h1>Wer steckt eigentlich hinter dem Kandimat?</h1><p>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.</p>');
|
||||||
|
insert into candymat_data.user_app_info (row_id, title, content) values
|
||||||
|
('contact_page', 'Contact Candymat', '<h1>Kontakt</h1><p>Kontakt Infos</p>');
|
||||||
|
insert into candymat_data.user_app_info (row_id, title, content) values
|
||||||
|
('legal_page', 'Legal Candymat', '<h1>Impressum</h1><p>Impressum Infos</p>');
|
||||||
|
|
26
redaktions-app/src/backend/queries/page_info.ts
Normal file
26
redaktions-app/src/backend/queries/page_info.ts
Normal file
|
@ -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";
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,7 +2,10 @@ import React from "react";
|
||||||
import { Paper, Typography } from "@material-ui/core";
|
import { Paper, Typography } from "@material-ui/core";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import { useQuery } from "@apollo/client";
|
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) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
|
@ -27,6 +30,11 @@ interface EditInformationProps {
|
||||||
export function EditInformation(
|
export function EditInformation(
|
||||||
props: EditInformationProps
|
props: EditInformationProps
|
||||||
): React.ReactElement {
|
): React.ReactElement {
|
||||||
|
const infos =
|
||||||
|
useQuery<GetAllPageInfoResponse, null>(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();
|
const classes = useStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -37,26 +45,20 @@ export function EditInformation(
|
||||||
<Paper className={classes.root}>
|
<Paper className={classes.root}>
|
||||||
<Typography component={"h2"} variant="h6" color="primary" gutterBottom>
|
<Typography component={"h2"} variant="h6" color="primary" gutterBottom>
|
||||||
{/* eslint-disable-next-line react/no-unescaped-entities */}
|
{/* eslint-disable-next-line react/no-unescaped-entities */}
|
||||||
Der "Über Uns" Text:
|
{about?.title || ""}
|
||||||
</Typography>
|
</Typography>
|
||||||
<form>
|
<form>
|
||||||
<textarea
|
<textarea className={classes.textArea} value={about?.content || ""}>
|
||||||
className={classes.textArea}
|
|
||||||
value="Hier muss der Über Uns Text rein"
|
|
||||||
>
|
|
||||||
{/*Hier kommt der Inhalt aus der Datenbank*/}
|
{/*Hier kommt der Inhalt aus der Datenbank*/}
|
||||||
</textarea>
|
</textarea>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<Typography component={"h2"} variant="h6" color="primary" gutterBottom>
|
<Typography component={"h2"} variant="h6" color="primary" gutterBottom>
|
||||||
{/* eslint-disable-next-line react/no-unescaped-entities */}
|
{/* eslint-disable-next-line react/no-unescaped-entities */}
|
||||||
Der "Impressum" Text:
|
{legal?.title || ""}
|
||||||
</Typography>
|
</Typography>
|
||||||
<form>
|
<form>
|
||||||
<textarea
|
<textarea className={classes.textArea} value={legal?.content || ""}>
|
||||||
className={classes.textArea}
|
|
||||||
value="Hier muss der Impressum Text rein"
|
|
||||||
>
|
|
||||||
{/*Hier kommt der Inhalt aus der Datenbank*/}
|
{/*Hier kommt der Inhalt aus der Datenbank*/}
|
||||||
</textarea>
|
</textarea>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue