feat: add returnUrl params
This commit is contained in:
@@ -102,7 +102,7 @@ export default function Dashboard({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasLoaded && availableWorkspaces.length === 0) {
|
if (hasLoaded && availableWorkspaces.length === 0) {
|
||||||
if (env("NEXT_PUBLIC_KAN_ENV") === "cloud") {
|
if (env("NEXT_PUBLIC_KAN_ENV") === "cloud") {
|
||||||
router.push("/onboarding/select-plan");
|
router.push(`/onboarding/select-plan?returnUrl=${encodeURIComponent(window.location.pathname)}`);
|
||||||
} else {
|
} else {
|
||||||
openModal("NEW_WORKSPACE", undefined, undefined, false);
|
openModal("NEW_WORKSPACE", undefined, undefined, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export default function WorkspaceMenu({
|
|||||||
<button
|
<button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
env("NEXT_PUBLIC_KAN_ENV") === "cloud"
|
env("NEXT_PUBLIC_KAN_ENV") === "cloud"
|
||||||
? router.push("/onboarding/select-plan")
|
? router.push(`/onboarding/select-plan?returnUrl=${encodeURIComponent(window.location.pathname)}`)
|
||||||
: openModal("NEW_WORKSPACE")
|
: openModal("NEW_WORKSPACE")
|
||||||
}
|
}
|
||||||
className="flex w-full items-center justify-between rounded-[5px] px-3 py-2 text-left text-xs text-neutral-900 hover:bg-light-200 dark:text-dark-1000 dark:hover:bg-dark-400"
|
className="flex w-full items-center justify-between rounded-[5px] px-3 py-2 text-left text-xs text-neutral-900 hover:bg-light-200 dark:text-dark-1000 dark:hover:bg-dark-400"
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export default function SelectPlanView() {
|
|||||||
const [billing, setBilling] = useState<Billing>(
|
const [billing, setBilling] = useState<Billing>(
|
||||||
(searchParams.get("billing") as Billing | null) ?? "annual",
|
(searchParams.get("billing") as Billing | null) ?? "annual",
|
||||||
);
|
);
|
||||||
|
const returnUrl = searchParams.get("returnUrl") ?? "/boards";
|
||||||
const { data: workspaces } = api.workspace.all.useQuery();
|
const { data: workspaces } = api.workspace.all.useQuery();
|
||||||
const { data: session } = authClient.useSession();
|
const { data: session } = authClient.useSession();
|
||||||
const { data: user } = api.user.getUser.useQuery(undefined, {
|
const { data: user } = api.user.getUser.useQuery(undefined, {
|
||||||
@@ -97,24 +98,18 @@ export default function SelectPlanView() {
|
|||||||
|
|
||||||
const handleSelectPlan = (plan: PlanId) => {
|
const handleSelectPlan = (plan: PlanId) => {
|
||||||
setSelected(plan);
|
setSelected(plan);
|
||||||
router.replace(`/onboarding/select-plan?plan=${plan}&billing=${billing}`);
|
router.replace(`/onboarding/select-plan?plan=${plan}&billing=${billing}&returnUrl=${encodeURIComponent(returnUrl)}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSetBilling = (b: Billing) => {
|
const handleSetBilling = (b: Billing) => {
|
||||||
setBilling(b);
|
setBilling(b);
|
||||||
router.replace(`/onboarding/select-plan?plan=${selected}&billing=${b}`);
|
router.replace(`/onboarding/select-plan?plan=${selected}&billing=${b}&returnUrl=${encodeURIComponent(returnUrl)}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleContinue = () =>
|
const handleContinue = () =>
|
||||||
router.push(`/onboarding/workspace?plan=${selected}&billing=${billing}`);
|
router.push(`/onboarding/workspace?plan=${selected}&billing=${billing}&returnUrl=${encodeURIComponent(returnUrl)}`);
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => router.push(returnUrl);
|
||||||
if (window.history.length > 1) {
|
|
||||||
router.back();
|
|
||||||
} else {
|
|
||||||
router.push("/boards");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen flex-col items-center justify-center gap-4 bg-light-100 px-4 py-8 dark:bg-dark-50 md:px-6">
|
<div className="flex min-h-screen flex-col items-center justify-center gap-4 bg-light-100 px-4 py-8 dark:bg-dark-50 md:px-6">
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export default function WorkspaceNameView() {
|
|||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const plan = searchParams.get("plan") ?? "solo";
|
const plan = searchParams.get("plan") ?? "solo";
|
||||||
const billing = searchParams.get("billing") ?? "annual";
|
const billing = searchParams.get("billing") ?? "annual";
|
||||||
|
const returnUrl = searchParams.get("returnUrl") ?? "/boards";
|
||||||
const { showPopup } = usePopup();
|
const { showPopup } = usePopup();
|
||||||
const [isProToggle, setIsProToggle] = useState(plan === "pro");
|
const [isProToggle, setIsProToggle] = useState(plan === "pro");
|
||||||
|
|
||||||
@@ -266,8 +267,8 @@ export default function WorkspaceNameView() {
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
router.push(
|
router.replace(
|
||||||
`/onboarding/select-plan?plan=${plan}&billing=${billing}`,
|
`/onboarding/select-plan?plan=${plan}&billing=${billing}&returnUrl=${encodeURIComponent(returnUrl)}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user