Skip to content

Commit

Permalink
fix: update subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
bepyan committed Aug 23, 2024
1 parent e43261f commit d205dc6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/editor/sidebar/sidebar-settings-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useForm } from "@tanstack/react-form";
import { useMutation } from "@tanstack/react-query";
import { LinkIcon } from "lucide-react";
import { useRouter } from "next/navigation";
import { useMemo } from "react";
import { toast } from "sonner";
import { useEditor } from "~/components/editor/provider";
Expand Down Expand Up @@ -41,6 +42,7 @@ export default function SidebarSettingsTab(props: Props) {

function CustomDomainSection() {
const { editor, dispatch } = useEditor();
const router = useRouter();

const updateSubdomainMutation = useMutation({
mutationFn: async (subdomain: string) => {
Expand All @@ -55,19 +57,19 @@ function CustomDomainSection() {
eventUrl: subdomain,
});

return subdomain;
},
onSuccess: (subdomain) => {
dispatch({
type: "UPDATE_CONFIG",
payload: {
invitationSubdomain: subdomain,
},
});

return subdomain;
},
onSuccess: (subdomain) => {
toast.success("도메인이 변경되었습니다.", {
description: `https://${subdomain}.invi.my`,
});
router.replace(`/i/${subdomain}/edit`);
},
onError: () => {
toast.error("도메인 변경에 실패했습니다.");
Expand Down

0 comments on commit d205dc6

Please sign in to comment.