Skip to content

Commit

Permalink
chore: Tidy up types
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Feb 16, 2024
1 parent f9771c0 commit f66e4bd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
1 change: 0 additions & 1 deletion api.planx.uk/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export interface UserData {
data?: Record<string, any>;
auto?: boolean;
override?: Record<string, any>;
feedback?: string;
}

export type Breadcrumb = Record<string, UserData>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const Responses = ({

const Result: React.FC<Props> = ({
allowChanges = false,
handleSubmit,
headingColor,
headingTitle = "",
description = "",
Expand All @@ -103,7 +104,7 @@ const Result: React.FC<Props> = ({
description={description}
color={headingColor}
/>
<Card>
<Card handleSubmit={handleSubmit}>
<Box mt={4} mb={3}>
<Typography variant="h2" gutterBottom>
{reasonsTitle}
Expand Down
1 change: 0 additions & 1 deletion editor.planx.uk/src/pages/FlowEditor/lib/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export declare namespace Store {
data?: Record<string, any>;
auto?: boolean;
override?: Record<string, any>;
feedback?: string;
};
export type breadcrumbs = Record<nodeId, userData>;
export type cachedBreadcrumbs = Record<nodeId, userData> | undefined;
Expand Down
9 changes: 1 addition & 8 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,10 @@ export const previewStore: StateCreator<

if (userData) {
// add breadcrumb
const {
answers = [],
data = {},
auto = false,
override,
feedback,
} = userData;
const { answers = [], data = {}, auto = false, override } = userData;

const breadcrumb: Store.userData = { auto: Boolean(auto) };
if (answers?.length > 0) breadcrumb.answers = answers;
if (feedback) breadcrumb.feedback = feedback;

const filteredData = objectWithoutNullishValues(data);
if (Object.keys(filteredData).length > 0) breadcrumb.data = filteredData;
Expand Down
7 changes: 3 additions & 4 deletions editor.planx.uk/src/pages/Preview/Questions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,16 @@ const Questions = ({ previewEnvironment }: QuestionsProps) => {
data = undefined,
answers = [],
auto = false,
feedback = undefined,
} = (() => {
try {
const { answers = [], data, auto, feedback } = userData as any;
return { answers: answers.filter(Boolean), data, auto, feedback };
const { answers = [], data, auto } = userData as any;
return { answers: answers.filter(Boolean), data, auto };
} catch (err) {
return {};
}
})();

record(id, { answers, data, auto, feedback });
record(id, { answers, data, auto });
};

const goBack = useCallback(() => {
Expand Down

0 comments on commit f66e4bd

Please sign in to comment.