diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/FeedbackLog.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/FeedbackLog.tsx new file mode 100644 index 0000000000..c43db35f42 --- /dev/null +++ b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/FeedbackLog.tsx @@ -0,0 +1,80 @@ +import Container from "@mui/material/Container"; +import Table from "@mui/material/Table"; +import TableBody from "@mui/material/TableBody"; +import TableCell from "@mui/material/TableCell"; +import TableHead from "@mui/material/TableHead"; +import TableRow from "@mui/material/TableRow"; +import Typography from "@mui/material/Typography"; +import React from "react"; +import { Feedback } from "routes/feedback"; +import SettingsSection from "ui/editor/SettingsSection"; +import ErrorSummary from "ui/shared/ErrorSummary/ErrorSummary"; + +import { CollapsibleRow } from "./components/CollapsibleRow"; +import { Feed } from "./styled"; + +interface Props { + feedback: Feedback[]; +} + +export const FeedbackLog: React.FC = ({ feedback }) => { + const displayFeedbackItems = [ + "userComment", + "address", + "projectType", + "where", + "browserPlatform", + ]; + + return ( + + + + Feedback log + + + Feedback from users about this service. + + + + {feedback.length === 0 ? ( + + ) : ( + + + + *": { borderBottomColor: "black !important" } }} + > + + Type + + + Date + + + Comment + + + + + + {feedback.map((item) => ( + + ))} + +
+
+ )} +
+
+ ); +}; diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackPage.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx similarity index 61% rename from editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackPage.tsx rename to editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx index a07dccf763..ba8ff68f2d 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackPage.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx @@ -8,79 +8,21 @@ import RuleIcon from "@mui/icons-material/Rule"; import WarningIcon from "@mui/icons-material/Warning"; import Box from "@mui/material/Box"; import Collapse from "@mui/material/Collapse"; -import Container from "@mui/material/Container"; import IconButton from "@mui/material/IconButton"; -import { styled } from "@mui/material/styles"; -import Table from "@mui/material/Table"; -import TableBody from "@mui/material/TableBody"; import TableCell from "@mui/material/TableCell"; -import TableContainer from "@mui/material/TableContainer"; -import TableHead from "@mui/material/TableHead"; import TableRow from "@mui/material/TableRow"; -import Typography from "@mui/material/Typography"; -import { SummaryListTable } from "@planx/components/shared/Preview/SummaryList"; import { format } from "date-fns"; -import gql from "graphql-tag"; import { client } from "lib/graphql"; import React, { useState } from "react"; import { Feedback } from "routes/feedback"; -import SettingsSection from "ui/editor/SettingsSection"; -import ErrorSummary from "ui/shared/ErrorSummary/ErrorSummary"; import ReactMarkdownOrHtml from "ui/shared/ReactMarkdownOrHtml/ReactMarkdownOrHtml"; -interface Props { - feedback: Feedback[]; -} - -const Feed = styled(TableContainer)(() => ({ - maxHeight: "60vh", - overflow: "auto", - display: "flex", - flexDirection: "column-reverse", - readingOrder: "flex-visual", -})); - -const DetailedFeedback = styled(Box)(({ theme }) => ({ - fontSize: "1em", - margin: 1, - maxWidth: "100%", - padding: theme.spacing(2, 1), -})); +import { GET_FEEDBACK_BY_ID_QUERY } from "../queries/getFeedbackById"; +import { DetailedFeedback, StyledSummaryListTable } from "../styled"; -const StyledSummaryListTable = styled(SummaryListTable)(() => ({ - "& p": { - margin: 0, - }, -})); - -const GET_FEEDBACK_BY_ID_QUERY = gql` - query GetFeedbackById($feedbackId: Int!) { - feedback: feedback_summary(where: { feedback_id: { _eq: $feedbackId } }) { - address - createdAt: created_at - platform: device(path: "platform.type") - browser: device(path: "browser.name") - feedbackId: feedback_id - type: feedback_type - helpDefinition: help_definition - helpSources: help_sources - helpText: help_text - intersectingConstraints: intersecting_constraints - nodeData: node_data - nodeId: node_id - nodeText: node_text - nodeTitle: node_title - nodeType: node_type - projectType: project_type - serviceSlug: service_slug - teamSlug: team_slug - status - uprn - userComment: user_comment - userContext: user_context - } - } -`; +interface CollapsibleRowProps extends Feedback { + displayFeedbackItems: string[]; +} const getDetailedFeedback = async (feedbackId: number) => { const { @@ -144,73 +86,7 @@ const feedbackTypeIcon = (type: FeedbackType) => { } }; -export const FeedbackPage: React.FC = ({ feedback }) => { - const displayFeedbackItems = [ - "userComment", - "address", - "projectType", - "where", - "browserPlatform", - ]; - - return ( - - - - Feedback log - - - Feedback from users about this service. - - - - {feedback.length === 0 ? ( - - ) : ( - - - - *": { borderBottomColor: "black !important" } }} - > - - Type - - - Date - - - Comment - - - - - - {feedback.map((item) => ( - - ))} - -
-
- )} -
-
- ); -}; - -interface CollapsibleRowProps extends Feedback { - displayFeedbackItems: string[]; -} - -const CollapsibleRow: React.FC = (item) => { +export const CollapsibleRow: React.FC = (item) => { const [open, setOpen] = useState(false); const [detailedFeedback, setDetailedFeedback] = useState< Record | undefined diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/queries/getFeedbackById.ts b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/queries/getFeedbackById.ts new file mode 100644 index 0000000000..015c4109e6 --- /dev/null +++ b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/queries/getFeedbackById.ts @@ -0,0 +1,30 @@ +import gql from "graphql-tag"; + +export const GET_FEEDBACK_BY_ID_QUERY = gql` + query GetFeedbackById($feedbackId: Int!) { + feedback: feedback_summary(where: { feedback_id: { _eq: $feedbackId } }) { + address + createdAt: created_at + platform: device(path: "platform.type") + browser: device(path: "browser.name") + feedbackId: feedback_id + type: feedback_type + helpDefinition: help_definition + helpSources: help_sources + helpText: help_text + intersectingConstraints: intersecting_constraints + nodeData: node_data + nodeId: node_id + nodeText: node_text + nodeTitle: node_title + nodeType: node_type + projectType: project_type + serviceSlug: service_slug + teamSlug: team_slug + status + uprn + userComment: user_comment + userContext: user_context + } + } +`; diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/styled.ts b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/styled.ts new file mode 100644 index 0000000000..b4518cf904 --- /dev/null +++ b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/styled.ts @@ -0,0 +1,25 @@ +import Box from "@mui/material/Box"; +import { styled } from "@mui/material/styles"; +import TableContainer from "@mui/material/TableContainer"; +import { SummaryListTable } from "@planx/components/shared/Preview/SummaryList"; + +export const Feed = styled(TableContainer)(() => ({ + maxHeight: "60vh", + overflow: "auto", + display: "flex", + flexDirection: "column-reverse", + readingOrder: "flex-visual", +})); + +export const DetailedFeedback = styled(Box)(({ theme }) => ({ + fontSize: "1em", + margin: 1, + maxWidth: "100%", + padding: theme.spacing(2, 1), +})); + +export const StyledSummaryListTable = styled(SummaryListTable)(() => ({ + "& p": { + margin: 0, + }, +})); diff --git a/editor.planx.uk/src/routes/feedback.tsx b/editor.planx.uk/src/routes/feedback.tsx index 36d4453738..3ae0ceb63e 100644 --- a/editor.planx.uk/src/routes/feedback.tsx +++ b/editor.planx.uk/src/routes/feedback.tsx @@ -3,7 +3,7 @@ import { Sentiment } from "components/Feedback/MoreInfoFeedback/MoreInfoFeedback import { FeedbackCategory } from "components/Feedback/types"; import gql from "graphql-tag"; import { compose, mount, NotFoundError, route, withData } from "navi"; -import { FeedbackPage } from "pages/FlowEditor/components/Flow/FeedbackPage"; +import { FeedbackLog } from "pages/FlowEditor/components/Flow/FeedbackLog/FeedbackLog"; import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; @@ -67,7 +67,7 @@ const feedbackRoutes = compose( return { title: makeTitle("Flow Feedback"), - view: , + view: , }; }), }),