Skip to content

Commit

Permalink
chore: remove feedback fish submission logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Heneghan committed Feb 9, 2024
1 parent 0dd3aee commit 2e9d196
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -218,13 +217,6 @@ export function PlanningConstraintsContent(
feedback: previousFeedback || "",
},
onSubmit: (values) => {
if (values.feedback) {
submitFeedback(
values.feedback,
"Inaccurate planning constraints",
constraints,
);
}
handleSubmit?.(values);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
},
});
Expand Down
4 changes: 0 additions & 4 deletions editor.planx.uk/src/@planx/components/Result/Public/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -104,9 +103,6 @@ const Result: React.FC<Props> = ({
},
onSubmit: (values, { resetForm }) => {
if (values.feedback) {
submitFeedback(values.feedback, "Inaccurate Result", {
responses: responses,
});
resetForm();
}
handleSubmit?.({ feedback: values.feedback });
Expand Down
50 changes: 0 additions & 50 deletions editor.planx.uk/src/lib/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> be passed as metadata
metadata: {
...standardMetadata,
"component-metadata": JSON.stringify(componentMetadata),
},
}),
}).catch((err) => console.error(err));
};

export const getFeedbackMetadata = (): Record<string, string> => {
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;
Expand Down

0 comments on commit 2e9d196

Please sign in to comment.