Browse Source

feat: add profile-based redirection in Intro component

master
mortezaei 2 months ago
parent
commit
a36f0f6b75
  1. 12
      src/app/intro/page.tsx

12
src/app/intro/page.tsx

@ -1,7 +1,7 @@
"use client"; "use client";
import Image from "next/image"; import Image from "next/image";
import { useState } from "react";
import { useEffect, useState } from "react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import Button from "@/components/ui/button"; import Button from "@/components/ui/button";
import NavigationButton from "@/components/ui/navigation-button"; import NavigationButton from "@/components/ui/navigation-button";
@ -39,11 +39,19 @@ export default function Intro() {
const router = useRouter(); const router = useRouter();
const { dictionary: t, locale } = useI18n(); const { dictionary: t, locale } = useI18n();
const { data: profile, refetch } = useMarriageProfileQuery({ const { data: profile, refetch } = useMarriageProfileQuery({
enabled: authBridge.isAuthenticated(),
retry: false,
}); });
const [isReportSheetOpen, setIsReportSheetOpen] = useState(false); const [isReportSheetOpen, setIsReportSheetOpen] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false);
useEffect(() => {
if (!profile) {
return;
}
router.replace(localizePath(getSubmitPath(profile), locale));
}, [locale, profile, router]);
const handleSubmit = async () => { const handleSubmit = async () => {
if (isSubmitting) { if (isSubmitting) {
return; return;

Loading…
Cancel
Save