Skip to content

Commit

Permalink
Use capitlize type utility
Browse files Browse the repository at this point in the history
  • Loading branch information
jamdelion committed Nov 11, 2024
1 parent aa19903 commit 72f3da8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, { ReactElement } from "react";

interface FaceBoxProps {
icon: string;
label: string;
label: Capitalize<string>;
altText: string;
testId?: string;
value: string;
Expand Down
2 changes: 1 addition & 1 deletion editor.planx.uk/src/@planx/components/Feedback/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export const parseFeedback = (
ratingQuestion: data?.ratingQuestion || defaultContent.ratingQuestion,
freeformQuestion: data?.freeformQuestion || defaultContent.freeformQuestion,
disclaimer: data?.disclaimer || defaultContent.disclaimer,
feedbackRequired: data?.feedbackRequired || false,
feedbackRequired: data?.feedbackRequired || defaultContent.feedbackRequired,
...parseBaseNodeData(data),
});
10 changes: 5 additions & 5 deletions editor.planx.uk/src/@planx/components/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export const makeData = <T>(
value: T,
overwriteKey?: string,
): Record<string, never> | { data: Record<string, T> } => {
return isEmpty(value)
? {}
: {
data: { [overwriteKey ?? fnOrDefaultPassportKey(props)]: value },
};
if (isEmpty(value)) return {};

return {
data: { [overwriteKey ?? fnOrDefaultPassportKey(props)]: value },
};
};

export const getPreviouslySubmittedData = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ 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";
import { FeedbackLogProps } from "./types";

interface Props {
feedback: Feedback[];
}

export const FeedbackLog: React.FC<Props> = ({ feedback }) => {
export const FeedbackLog: React.FC<FeedbackLogProps> = ({ feedback }) => {
const displayFeedbackItems = [
"userComment",
"address",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ import TableRow from "@mui/material/TableRow";
import { format } from "date-fns";
import { client } from "lib/graphql";
import React, { useState } from "react";
import { Feedback } from "routes/feedback";
import ReactMarkdownOrHtml from "ui/shared/ReactMarkdownOrHtml/ReactMarkdownOrHtml";

import { GET_FEEDBACK_BY_ID_QUERY } from "../queries/getFeedbackById";
import { DetailedFeedback, StyledSummaryListTable } from "../styled";

interface CollapsibleRowProps extends Feedback {
displayFeedbackItems: string[];
}
import { CollapsibleRowProps, FeedbackType, FeedbackTypeIcon } from "../types";

const getDetailedFeedback = async (feedbackId: number) => {
const {
Expand Down Expand Up @@ -56,16 +52,7 @@ const getDetailedFeedback = async (feedbackId: number) => {
};
};

type FeedbackType =
| "issue"
| "idea"
| "comment"
| "inaccuracy"
| "helpful"
| "unhelpful"
| "component";

const feedbackTypeIcon = (type: FeedbackType) => {
const feedbackTypeIcon = (type: FeedbackType): FeedbackTypeIcon => {
switch (type) {
case "issue":
return { icon: <WarningIcon />, title: "Issue" };
Expand All @@ -86,7 +73,7 @@ const feedbackTypeIcon = (type: FeedbackType) => {
case "component":
return { icon: <RateReviewIcon />, title: "From feedback component" };
default:
return { icon: <RuleIcon />, title: "inaccuracy" };
return { icon: <RuleIcon />, title: "Inaccuracy" };
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Feedback } from "routes/feedback";

export type FeedbackType =
| "issue"
| "idea"
| "comment"
| "inaccuracy"
| "helpful"
| "unhelpful"
| "component";

export interface FeedbackTypeIcon {
icon: React.ReactElement;
title: Capitalize<string>;
}
export interface CollapsibleRowProps extends Feedback {
displayFeedbackItems: string[];
}
export interface FeedbackLogProps {
feedback: Feedback[];
}

0 comments on commit 72f3da8

Please sign in to comment.