Skip to content

Commit

Permalink
fix: Tighten types to match planx-core changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 25, 2023
1 parent b8747e0 commit 335b6fe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
10 changes: 6 additions & 4 deletions api.planx.uk/admin/session/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export const getHTMLExport: HTMLExportHandler = async (req, res, next) => {
if (!session) throw Error(`Unable to find session ${req.params.sessionId}`);

const responses = await $api.export.csvData(req.params.sessionId);
const boundingBox =
session.data.passport.data["property.boundary.site.buffered"];
const boundingBox = session.data.passport.data[
"property.boundary.site.buffered"
] as unknown as GeoJSON.Feature;

const html = generateApplicationHTML({
planXExportData: responses as PlanXExportData[],
Expand Down Expand Up @@ -66,8 +67,9 @@ export const getRedactedHTMLExport: HTMLExportHandler = async (
const redactedResponses = await $api.export.csvDataRedacted(
req.params.sessionId,
);
const boundingBox =
session.data.passport.data["property.boundary.site.buffered"];
const boundingBox = session.data.passport.data[
"property.boundary.site.buffered"
] as unknown as GeoJSON.Feature;

const html = generateApplicationHTML({
planXExportData: redactedResponses as PlanXExportData[],
Expand Down
6 changes: 4 additions & 2 deletions api.planx.uk/inviteToPay/createPaymentSendEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ const createPaymentSendEvents = async (
if (destinations.includes(Destination.Uniform)) {
// Bucks has 3 instances of Uniform for 4 legacy councils, set teamSlug to pre-merger council name
if (teamSlug === "buckinghamshire") {
teamSlug = session.data?.passport?.data?.[
const localAuthorities: string[] = session.data?.passport?.data?.[
"property.localAuthorityDistrict"
]
] as string[];

teamSlug = localAuthorities
?.filter((name: string) => name !== "Buckinghamshire")[0]
?.toLowerCase()
?.replace(/\W+/g, "-");
Expand Down
7 changes: 6 additions & 1 deletion editor.planx.uk/src/@planx/components/Result/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import { TYPES } from "../types";
import { ICONS } from "../ui";
import type { Result } from "./model";

const flags = groupBy(flatFlags, (f) => f.category);
type FlagWithValue = Flag & { value: NonNullable<Flag["value"]> };

const flagsWithValues = flatFlags.filter((flag): flag is FlagWithValue =>
Boolean(flag.value),
);
const flags = groupBy(flagsWithValues, (f) => f.category);

interface FormData {
flagSet: FlagSet;
Expand Down
4 changes: 3 additions & 1 deletion editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export const previewStore: StateCreator<
const possibleFlags = flatFlags.filter(
(f) => f.category === DEFAULT_FLAG_CATEGORY,
);
const flagKeys: string[] = possibleFlags.map((f) => f.value);
const flagKeys: string[] = possibleFlags
.map((flag) => flag.value)
.filter((value): value is string => Boolean(value));

const breadcrumbIds = Object.keys(breadcrumbs);

Expand Down

0 comments on commit 335b6fe

Please sign in to comment.