Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

875 B
Raw Blame
"use server";

import * as z from "zod/v4";
import { onboardingStepCache } from "../api/workspaces/onboarding-step-cache";
import { ONBOARDING_STEPS } from "../onboarding/types";
import { authUserActionClient } from "./safe-action";

// Generate a new client secret for an integration
export const setOnboardingProgress = authUserActionClient
  .inputSchema(
    z.object({
      onboardingStep: z.enum(ONBOARDING_STEPS).nullable(),
    }),
  )
  .action(async ({ ctx, parsedInput }) => {
    const { onboardingStep } = parsedInput;

    try {
      if (onboardingStep) {
        await onboardingStepCache.set({
          userId: ctx.user.id,
          step: onboardingStep,
        });
      }
    } catch (e) {
      console.error("Failed to update onboarding step", e);
      throw new Error("Failed to update onboarding step");
    }

    return { success: true };
  });