Rename a few components

This commit is contained in:
2024-04-30 20:43:01 -05:00
parent 9bb28e7b39
commit 45df75d68f
3 changed files with 25 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { Client, setContextClient, queryStore } from "@urql/svelte"; import { Client, setContextClient, queryStore } from "@urql/svelte";
import { graphql } from "./gql"; import { graphql } from "./gql";
import OapApplicationFormStep from "./components/OapApplicationFormStep.svelte"; import ApplicationFormStep from "./components/ApplicationFormStep.svelte";
import step from "./lib/stores/step"; import step from "./lib/stores/step";
export let antiForgeryToken: string | null; export let antiForgeryToken: string | null;
@@ -34,7 +34,7 @@
}); });
function handleSubmit(event: SubmitEvent) { function handleSubmit(event: SubmitEvent) {
step.update(x => x + 1); step.update((x) => x + 1);
} }
</script> </script>
@@ -56,10 +56,11 @@
{/if} {/if}
{#each oapApplicationForm?.list?.contentItems ?? [] as contentItem, index} {#each oapApplicationForm?.list?.contentItems ?? [] as contentItem, index}
{#if contentItem?.__typename === "OapApplicationFormStep" && $step === index} {#if contentItem?.__typename === "OapApplicationFormStep" && $step === index}
<OapApplicationFormStep <ApplicationFormStep
onSubmit={handleSubmit} onSubmit={handleSubmit}
{antiForgeryToken} {antiForgeryToken}
fragment={contentItem} /> fragment={contentItem}
/>
{/if} {/if}
{/each} {/each}
{/each} {/each}

View File

@@ -1,7 +1,7 @@
<script context="module" lang="ts"> <script context="module" lang="ts">
import { graphql } from "../gql"; import { graphql } from "../gql";
export const OapApplicationFormStepFragment = graphql(/* GraphQL */ ` export const ApplicationFormStepFragment = graphql(/* GraphQL */ `
fragment OapApplicationFormStep on OapApplicationFormStep { fragment OapApplicationFormStep on OapApplicationFormStep {
displayText displayText
contentItemId contentItemId
@@ -24,11 +24,14 @@
import Form from "./Form.svelte"; import Form from "./Form.svelte";
import type { EventHandler } from "svelte/elements"; import type { EventHandler } from "svelte/elements";
export let onSubmit: EventHandler<SubmitEvent, HTMLFormElement> | undefined | null; export let onSubmit:
| EventHandler<SubmitEvent, HTMLFormElement>
| undefined
| null;
export let antiForgeryToken: string | null; export let antiForgeryToken: string | null;
export let fragment: FragmentType<typeof OapApplicationFormStepFragment>; export let fragment: FragmentType<typeof ApplicationFormStepFragment>;
const content = useFragment(OapApplicationFormStepFragment, fragment); const content = useFragment(ApplicationFormStepFragment, fragment);
</script> </script>
<h2 class="text-lg font-bold">{content.displayText}</h2> <h2 class="text-lg font-bold">{content.displayText}</h2>
@@ -39,10 +42,8 @@
</div> </div>
{/if} {/if}
{#if content.flow} {#each content.flow?.widgets ?? [] as widget}
{#each content.flow.widgets ?? [] as widget}
{#if widget?.__typename === "Form"} {#if widget?.__typename === "Form"}
<Form {onSubmit} {antiForgeryToken} fragment={widget} /> <Form {onSubmit} {antiForgeryToken} fragment={widget} />
{/if} {/if}
{/each} {/each}
{/if}

View File

@@ -1,6 +1,6 @@
import { cacheExchange, Client, fetchExchange } from "@urql/svelte"; import { cacheExchange, Client, fetchExchange } from "@urql/svelte";
import "./app.css"; import "./app.css";
import OapApplicationForm from "./OapApplicationForm.svelte"; import ApplicationForm from "./ApplicationForm.svelte";
const client = new Client({ const client = new Client({
url: "https://localhost:5001/oap/api/graphql", url: "https://localhost:5001/oap/api/graphql",
@@ -8,19 +8,19 @@ const client = new Client({
}); });
var antiForgeryToken = document.getElementsByName("__RequestVerificationToken"); var antiForgeryToken = document.getElementsByName("__RequestVerificationToken");
var oapApplicationForms = document.getElementsByClassName("OapApplicationForm"); var applicationFormElements = document.getElementsByClassName("OapApplicationForm");
let oapApplicationForm: OapApplicationForm; let applicationForm: ApplicationForm;
if (oapApplicationForms.length === 1) { if (applicationFormElements.length === 1) {
oapApplicationForm = new OapApplicationForm({ applicationForm = new ApplicationForm({
target: oapApplicationForms[0], target: applicationFormElements[0],
props: { props: {
antiForgeryToken: antiForgeryToken[0]?.getAttribute("value") ?? null, antiForgeryToken: antiForgeryToken[0]?.getAttribute("value") ?? null,
contentItemId: oapApplicationForms[0].id, contentItemId: applicationFormElements[0].id,
client, client,
}, },
}); });
} }
export { oapApplicationForm }; export { applicationForm as oapApplicationForm };