Skip to content

Commit

Permalink
added onboarding overview
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorpfiz committed Dec 6, 2023
1 parent a7881a7 commit a8645ed
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import {
} from "@acme/ui/form";
import { useToast } from "@acme/ui/use-toast";

import { useStepStatusUpdater } from "~/components/ui/steps";
import { api } from "~/trpc/react";
import { uploadTestPdf } from "./upload-test";

export function ConsentForm(props: { onSuccess?: () => void }) {
const router = useRouter();
const toaster = useToast();
const updater = useStepStatusUpdater();

const mutation = api.canvas.submitConsent.useMutation({
onSuccess: (data) => {
Expand All @@ -37,6 +38,8 @@ export function ConsentForm(props: { onSuccess?: () => void }) {
),
});

updater.updateStepStatus("consent", "complete");

// Call the passed onSuccess prop if it exists
if (props.onSuccess) {
props.onSuccess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Button } from "@acme/ui/button";
import { Form } from "@acme/ui/form";
import { useToast } from "@acme/ui/use-toast";

import { useStepStatusUpdater } from "~/components/ui/steps";
import { useZodForm } from "~/lib/zod-form";
import { api } from "~/trpc/react";
import { CheckboxQuestion } from "./checkbox-question";
Expand All @@ -27,8 +28,8 @@ interface QuestionnaireProps {
export function QuestionnaireForm(props: QuestionnaireProps) {
const { questionnaireId, onSuccess } = props;

const router = useRouter();
const toaster = useToast();
const updater = useStepStatusUpdater();

const { isLoading, isError, data, error } =
api.canvas.getQuestionnaire.useQuery({
Expand All @@ -46,6 +47,8 @@ export function QuestionnaireForm(props: QuestionnaireProps) {
),
});

updater.updateStepStatus("questionnaire", "complete");

// Call the passed onSuccess prop if it exists
if (onSuccess) {
onSuccess();
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/src/components/ui/steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { atomWithStorage } from "jotai/utils";

import { cn } from "@acme/ui";

type StepId = "welcome" | "coverage" | "consent" | "questionnaire";
type StepStatus = "complete" | "current" | "upcoming";

const initialSteps = [
Expand Down Expand Up @@ -50,7 +51,7 @@ export const stepsAtom = atomWithStorage(
export const useStepStatusUpdater = () => {
const [steps, setSteps] = useAtom(stepsAtom);

const updateStepStatus = (stepId: string, newStatus: StepStatus) => {
const updateStepStatus = (stepId: StepId, newStatus: StepStatus) => {
const stepIndex = steps.findIndex((step) => step.id === stepId);
if (stepIndex === -1) return; // Step not found

Expand Down
3 changes: 1 addition & 2 deletions packages/api/src/canvas/canvas-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ export const api = createApiClient(async (method, url, params) => {
url += `?${queryParams}`;
}
}

// console.log(method, url, params, "parameters");

return fetch(url, options).then((res) => res.json());
}, env.FUMAGE_BASE_URL);

4 changes: 2 additions & 2 deletions packages/api/src/canvas/canvas-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
bundleSchema,
careTeamSchema,
ResourceSchema,
scheduleBundleSchema,
slotBundleSchema
scheduleBundleSchema,
slotBundleSchema,
} from "../validators";

export type post_GetAnOauthToken = typeof post_GetAnOauthToken;
Expand Down

0 comments on commit a8645ed

Please sign in to comment.