From 2e9d196bdc260297805e3baf6704ab2cb0f32aea Mon Sep 17 00:00:00 2001 From: Mike Heneghan Date: Fri, 9 Feb 2024 17:09:57 +0000 Subject: [PATCH] chore: remove feedback fish submission logic --- .../components/PlanningConstraints/Public.tsx | 8 --- .../components/PropertyInformation/Public.tsx | 8 --- .../@planx/components/Result/Public/index.tsx | 4 -- editor.planx.uk/src/lib/feedback.ts | 50 ------------------- 4 files changed, 70 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/PlanningConstraints/Public.tsx b/editor.planx.uk/src/@planx/components/PlanningConstraints/Public.tsx index bbb2c4e980..10f5b16322 100644 --- a/editor.planx.uk/src/@planx/components/PlanningConstraints/Public.tsx +++ b/editor.planx.uk/src/@planx/components/PlanningConstraints/Public.tsx @@ -10,7 +10,6 @@ import QuestionHeader from "@planx/components/shared/Preview/QuestionHeader"; import type { PublicProps } from "@planx/components/ui"; import DelayedLoadingIndicator from "components/DelayedLoadingIndicator"; import { useFormik } from "formik"; -import { submitFeedback } from "lib/feedback"; import capitalize from "lodash/capitalize"; import { useStore } from "pages/FlowEditor/lib/store"; import { handleSubmit } from "pages/Preview/Node"; @@ -218,13 +217,6 @@ export function PlanningConstraintsContent( feedback: previousFeedback || "", }, onSubmit: (values) => { - if (values.feedback) { - submitFeedback( - values.feedback, - "Inaccurate planning constraints", - constraints, - ); - } handleSubmit?.(values); }, }); diff --git a/editor.planx.uk/src/@planx/components/PropertyInformation/Public.tsx b/editor.planx.uk/src/@planx/components/PropertyInformation/Public.tsx index dce0573409..021906f9b5 100644 --- a/editor.planx.uk/src/@planx/components/PropertyInformation/Public.tsx +++ b/editor.planx.uk/src/@planx/components/PropertyInformation/Public.tsx @@ -9,7 +9,6 @@ import QuestionHeader from "@planx/components/shared/Preview/QuestionHeader"; import type { PublicProps } from "@planx/components/ui"; import { Feature } from "@turf/helpers"; import { useFormik } from "formik"; -import { submitFeedback } from "lib/feedback"; import { publicClient } from "lib/graphql"; import find from "lodash/find"; import { useAnalyticsTracking } from "pages/FlowEditor/lib/analyticsProvider"; @@ -115,13 +114,6 @@ export function Presentational(props: PresentationalProps) { feedback: previousFeedback || "", }, onSubmit: (values) => { - if (values.feedback) { - submitFeedback( - values.feedback, - "Inaccurate property details", - propertyDetails, - ); - } handleSubmit?.(values); }, }); diff --git a/editor.planx.uk/src/@planx/components/Result/Public/index.tsx b/editor.planx.uk/src/@planx/components/Result/Public/index.tsx index d93e70c246..07e626e8a5 100644 --- a/editor.planx.uk/src/@planx/components/Result/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/Result/Public/index.tsx @@ -7,7 +7,6 @@ import Card from "@planx/components/shared/Preview/Card"; import SimpleExpand from "@planx/components/shared/Preview/SimpleExpand"; import { WarningContainer } from "@planx/components/shared/Preview/WarningContainer"; import { useFormik } from "formik"; -import { submitFeedback } from "lib/feedback"; import { Store, useStore } from "pages/FlowEditor/lib/store"; import type { handleSubmit } from "pages/Preview/Node"; import React, { useEffect, useState } from "react"; @@ -104,9 +103,6 @@ const Result: React.FC = ({ }, onSubmit: (values, { resetForm }) => { if (values.feedback) { - submitFeedback(values.feedback, "Inaccurate Result", { - responses: responses, - }); resetForm(); } handleSubmit?.({ feedback: values.feedback }); diff --git a/editor.planx.uk/src/lib/feedback.ts b/editor.planx.uk/src/lib/feedback.ts index b90bd96e5e..53a4ddbe40 100644 --- a/editor.planx.uk/src/lib/feedback.ts +++ b/editor.planx.uk/src/lib/feedback.ts @@ -5,56 +5,6 @@ import { Store, useStore } from "pages/FlowEditor/lib/store"; import { publicClient } from "./graphql"; -export const submitFeedback = ( - text: string, - reason: string, - componentMetadata?: { [key: string]: any }, -) => { - const standardMetadata = getFeedbackMetadata(); - fetch("https://api.feedback.fish/feedback", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - projectId: process.env.REACT_APP_FEEDBACK_FISH_ID, - text, - reason, - // FeedbackFish requires that Record be passed as metadata - metadata: { - ...standardMetadata, - "component-metadata": JSON.stringify(componentMetadata), - }, - }), - }).catch((err) => console.error(err)); -}; - -export const getFeedbackMetadata = (): Record => { - const { currentCard, computePassport, breadcrumbs } = useStore.getState(); - - const passportData = computePassport().data; - const nodeData = currentCard()?.data; - - const [team, service] = window.location.pathname - .split("/") - .map((value) => value.replaceAll("-", " ")) - .slice(1, 3); - - const feedbackMetadata = { - address: - passportData?._address?.single_line_address || - passportData?._address?.title, - uprn: passportData?._address?.uprn, - "project-type": passportData?.proposal?.projectType, - title: nodeData?.title || nodeData?.text, - data: JSON.stringify(nodeData), - breadcrumbs: JSON.stringify(breadcrumbs), - service, - team, - }; - return feedbackMetadata; -}; - type UserData = { breadcrumbs: Store.breadcrumbs; passport: Store.passport;