From aa19903b14306645c665603dfeee2f1f4b2f2054 Mon Sep 17 00:00:00 2001 From: Jo Humphrey <31373245+jamdelion@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:02:40 +0000 Subject: [PATCH] Change feedback field to userComment --- .../Feedback/Public/Feedback.stories.tsx | 9 +-------- .../@planx/components/Feedback/Public/Public.tsx | 14 +++++--------- .../src/@planx/components/Feedback/model.ts | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Feedback/Public/Feedback.stories.tsx b/editor.planx.uk/src/@planx/components/Feedback/Public/Feedback.stories.tsx index fba313af2a..e8f0b3d8bb 100644 --- a/editor.planx.uk/src/@planx/components/Feedback/Public/Feedback.stories.tsx +++ b/editor.planx.uk/src/@planx/components/Feedback/Public/Feedback.stories.tsx @@ -13,12 +13,5 @@ type Story = StoryObj; export default meta; export const Basic = { - args: { - title: defaultContent.title, - feedbackRequired: false, - description: defaultContent.description, - freeformQuestion: defaultContent.freeformQuestion, - ratingQuestion: defaultContent.ratingQuestion, - disclaimer: defaultContent.disclaimer, - }, + args: defaultContent, } satisfies Story; diff --git a/editor.planx.uk/src/@planx/components/Feedback/Public/Public.tsx b/editor.planx.uk/src/@planx/components/Feedback/Public/Public.tsx index 897d0df543..1f9991fbe8 100644 --- a/editor.planx.uk/src/@planx/components/Feedback/Public/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Feedback/Public/Public.tsx @@ -30,13 +30,9 @@ export const PASSPORT_FEEDBACK_KEY = "_feedback"; const FeedbackComponent = (props: PublicProps): FCReturn => { const handleSubmitFeedback = async (values: FormProps) => { const metadata = await getInternalFeedbackMetadata(); - const feedback = { - userComment: values.feedback, - feedbackScore: values.feedbackScore, - }; const data = { ...metadata, - ...feedback, + ...values, feedbackType: "component" as FeedbackView, }; const submitFeedbackResult = await insertFeedbackMutation(data).catch( @@ -53,7 +49,7 @@ const FeedbackComponent = (props: PublicProps): FCReturn => { const formik = useFormik({ initialValues: getPreviouslySubmittedData(props) ?? { feedbackScore: "", - feedback: "", + userComment: "", }, onSubmit: handleSubmitFeedback, }); @@ -152,11 +148,11 @@ const FeedbackComponent = (props: PublicProps): FCReturn => { {props.disclaimer && } diff --git a/editor.planx.uk/src/@planx/components/Feedback/model.ts b/editor.planx.uk/src/@planx/components/Feedback/model.ts index 11ebaaa4b3..7dc41176c2 100644 --- a/editor.planx.uk/src/@planx/components/Feedback/model.ts +++ b/editor.planx.uk/src/@planx/components/Feedback/model.ts @@ -10,7 +10,7 @@ export interface Feedback extends BaseNodeData { } export interface FormProps { feedbackScore: string; - feedback: string; + userComment: string; } export const parseFeedback = (