Skip to content

Commit

Permalink
chore(reasonings): cleanup
Browse files Browse the repository at this point in the history
Co-Authored-By: Spencer Peace <[email protected]>
  • Loading branch information
chohner and Spencer6497 committed Dec 9, 2024
1 parent 3bd06cf commit 0f31a94
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
11 changes: 2 additions & 9 deletions app/routes/shared/result.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
fetchMeta,
fetchTranslations,
} from "~/services/cms/index.server";
import type { StrapiContentComponent } from "~/services/cms/models/StrapiContentComponent";
import { isStrapiInfoBoxItem } from "~/services/cms/models/StrapiElementWithId";
import { buildFlowController } from "~/services/flow/server/buildFlowController";
import { getSessionData } from "~/services/session.server";
import { updateMainSession } from "~/services/session.server/updateSessionInHeader";
Expand Down Expand Up @@ -61,13 +59,8 @@ export const loader = async ({ request, context }: LoaderFunctionArgs) => {
stepId,
});

const documents = (cmsContent.documents.data?.attributes.element.filter(
(el) => !isStrapiInfoBoxItem(el),
) ?? []) as StrapiContentComponent[];

const nextSteps = (cmsContent.nextSteps.data?.attributes.element.filter(
(el) => !isStrapiInfoBoxItem(el),
) ?? []) as StrapiContentComponent[];
const documents = cmsContent.documents.data?.attributes.element ?? [];
const nextSteps = cmsContent.nextSteps.data?.attributes.element ?? [];

const cmsData = { ...cmsContent, nextSteps, documents };

Expand Down
12 changes: 1 addition & 11 deletions app/services/cms/models/StrapiElementWithId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@ import { z } from "zod";
import { HasStrapiLocaleSchema } from "./HasStrapiLocale";
import { HasStrapiTimestampsSchema } from "./HasStrapiTimestamps";
import { StrapiContentComponentSchema } from "./StrapiContentComponent";
import { StrapiInfoBoxItemComponentSchema } from "./StrapiInfoBoxItem";

const elementSchema = StrapiContentComponentSchema.or(
StrapiInfoBoxItemComponentSchema,
);

export const StrapiElementWithIdSchema = z
.object({
elementId: z.string(),
element: z.array(elementSchema),
element: z.array(StrapiContentComponentSchema),
})
.merge(HasStrapiLocaleSchema)
.merge(HasStrapiTimestampsSchema);

export type StrapiElementWithId = z.infer<typeof StrapiElementWithIdSchema>;

export const isStrapiInfoBoxItem = (
element: z.infer<typeof elementSchema>,
): element is z.infer<typeof StrapiInfoBoxItemComponentSchema> =>
element.__component === "page.info-box-item";
4 changes: 0 additions & 4 deletions app/services/cms/models/StrapiInfoBoxItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export const StrapiInfoBoxItemSchema = z
.merge(HasOptionalStrapiIdSchema)
.merge(OptionalStrapiLinkIdentifierSchema);

export const StrapiInfoBoxItemComponentSchema = StrapiInfoBoxItemSchema.extend({
__component: z.literal("page.info-box-item"),
});

type StrapiInfoBoxItem = z.infer<typeof StrapiInfoBoxItemSchema>;

export const getInfoBoxItemProps = (
Expand Down

0 comments on commit 0f31a94

Please sign in to comment.