Skip to content

Commit

Permalink
remove slugify and adjust guild creation to backend (#1569)
Browse files Browse the repository at this point in the history
* chore: remove slugify

* chore: remove urlName field from request body

* chore: remove email constraint on contact

* chore: remove contacts, test defaults

* chore: remove test defaults
  • Loading branch information
dominik-stumpf authored Nov 27, 2024
1 parent cbd03d1 commit 1fce6dc
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"remark-gfm": "^4.0.0",
"remark-textr": "^6.1.0",
"server-only": "^0.0.1",
"slugify": "^1.6.6",
"sonner": "^1.7.0",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { CheckCircle, XCircle } from "@phosphor-icons/react/dist/ssr";
import { useMutation } from "@tanstack/react-query";
import { useRouter } from "next/navigation";
import { useFormContext } from "react-hook-form";
import slugify from "slugify";
import { toast } from "sonner";

const CreateGuildButton = () => {
Expand All @@ -30,12 +29,6 @@ const CreateGuildButton = () => {
const guild = {
...data,
contact: undefined,
// TODO: I think we should do it on the backend
urlName: slugify(data.name, {
replacement: "-",
lower: true,
strict: true,
}),
};

return fetcher<Guild>(`${env.NEXT_PUBLIC_API}/guild`, {
Expand All @@ -52,7 +45,7 @@ const CreateGuildButton = () => {
toast("An error occurred", {
icon: <XCircle weight="fill" className="text-icon-error" />,
});
console.error(error);
console.warn(error);
},
onSuccess: (res) => {
confetti.current();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import { FormProvider, useForm } from "react-hook-form";
const defaultValues = {
name: "",
imageUrl: "",
urlName: "test",
contact: "",
description: "",
} satisfies CreateGuildForm;

const CreateGuildFormProvider = ({ children }: PropsWithChildren) => {
const methods = useForm<CreateGuildForm>({
mode: "onTouched",
resolver: zodResolver(CreateGuildSchema),
resolver: zodResolver(CreateGuildSchema.omit({ urlName: true })),
defaultValues,
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/schemas/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const CreateGuildSchema = z.object({
urlName: z.string().max(255).optional(),
imageUrl: ImageUrlSchema.optional(),
description: z.string().optional(),
contact: z.string().email(),
contact: z.string().min(1, "You must specify a contact for your guild"),
});

export type CreateGuildForm = z.infer<typeof CreateGuildSchema>;
Expand Down

0 comments on commit 1fce6dc

Please sign in to comment.