Replace entire codebase with homarr-labs/homarr
This commit is contained in:
36
packages/api/src/router/onboard/onboard-router.ts
Normal file
36
packages/api/src/router/onboard/onboard-router.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { onboarding } from "@homarr/db/schema";
|
||||
import { onboardingSteps } from "@homarr/definitions";
|
||||
import { zodEnumFromArray } from "@homarr/validation/enums";
|
||||
|
||||
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
||||
import { getOnboardingOrFallbackAsync, nextOnboardingStepAsync } from "./onboard-queries";
|
||||
|
||||
export const onboardRouter = createTRPCRouter({
|
||||
currentStep: publicProcedure.query(async ({ ctx }) => {
|
||||
return await getOnboardingOrFallbackAsync(ctx.db);
|
||||
}),
|
||||
nextStep: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
// Preferred step is only needed for 'preferred' conditions
|
||||
preferredStep: zodEnumFromArray(onboardingSteps).optional(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
await nextOnboardingStepAsync(ctx.db, input.preferredStep);
|
||||
}),
|
||||
previousStep: publicProcedure.mutation(async ({ ctx }) => {
|
||||
const { previous } = await getOnboardingOrFallbackAsync(ctx.db);
|
||||
|
||||
if (previous !== "start") {
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.db.update(onboarding).set({
|
||||
previousStep: null,
|
||||
step: "start",
|
||||
});
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user