mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-25 03:09:24 -06:00
fix: validation error in profile update input (#937)
This commit is contained in:
@@ -41,7 +41,11 @@ const Objective: React.FC<ObjectiveProps> = ({ next, skip, formbricksResponseId,
|
||||
if (selectedObjective) {
|
||||
try {
|
||||
setIsProfileUpdating(true);
|
||||
const updatedProfile = { ...profile, objective: selectedObjective.id };
|
||||
const updatedProfile = {
|
||||
...profile,
|
||||
objective: selectedObjective.id,
|
||||
name: profile.name ?? undefined,
|
||||
};
|
||||
await updateProfileAction(updatedProfile);
|
||||
setIsProfileUpdating(false);
|
||||
} catch (e) {
|
||||
|
||||
@@ -4,7 +4,12 @@ import { prisma } from "@formbricks/database";
|
||||
import { ZId } from "@formbricks/types/v1/environment";
|
||||
import { DatabaseError, ResourceNotFoundError } from "@formbricks/types/v1/errors";
|
||||
import { TMembership, TMembershipRole, ZMembershipRole } from "@formbricks/types/v1/memberships";
|
||||
import { TProfile, TProfileUpdateInput, ZProfileUpdateInput } from "@formbricks/types/v1/profile";
|
||||
import {
|
||||
TProfile,
|
||||
TProfileCreateInput,
|
||||
TProfileUpdateInput,
|
||||
ZProfileUpdateInput,
|
||||
} from "@formbricks/types/v1/profile";
|
||||
import { MembershipRole, Prisma } from "@prisma/client";
|
||||
import { unstable_cache, revalidateTag } from "next/cache";
|
||||
import { validateInputs } from "../utils/validate";
|
||||
@@ -149,7 +154,7 @@ const deleteUser = async (userId: string): Promise<TProfile> => {
|
||||
return profile;
|
||||
};
|
||||
|
||||
export const createProfile = async (data: TProfileUpdateInput): Promise<TProfile> => {
|
||||
export const createProfile = async (data: TProfileCreateInput): Promise<TProfile> => {
|
||||
validateInputs([data, ZProfileUpdateInput]);
|
||||
const profile = await prisma.user.create({
|
||||
data: data,
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ZProfile = z.object({
|
||||
export type TProfile = z.infer<typeof ZProfile>;
|
||||
|
||||
export const ZProfileUpdateInput = z.object({
|
||||
name: z.string().optional(),
|
||||
name: z.string().nullish(),
|
||||
email: z.string().optional(),
|
||||
onboardingCompleted: z.boolean().optional(),
|
||||
role: ZRole.optional(),
|
||||
@@ -29,3 +29,13 @@ export const ZProfileUpdateInput = z.object({
|
||||
});
|
||||
|
||||
export type TProfileUpdateInput = z.infer<typeof ZProfileUpdateInput>;
|
||||
|
||||
export const ZProfileCreateInput = z.object({
|
||||
name: z.string().optional(),
|
||||
email: z.string(),
|
||||
onboardingCompleted: z.boolean().optional(),
|
||||
role: ZRole.optional(),
|
||||
objective: ZObjective.optional(),
|
||||
});
|
||||
|
||||
export type TProfileCreateInput = z.infer<typeof ZProfileCreateInput>;
|
||||
|
||||
Reference in New Issue
Block a user