From 974b3fb923c696b81aa76ff4b621ef28feaa8ce9 Mon Sep 17 00:00:00 2001
From: Will Franklin <will@willpf.co.uk>
Date: Fri, 10 May 2024 12:15:11 +0100
Subject: [PATCH] Redirect in parent window when embedded

---
 src/pages/join/index.vue | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/pages/join/index.vue b/src/pages/join/index.vue
index bd678a50f..5ad8583f5 100644
--- a/src/pages/join/index.vue
+++ b/src/pages/join/index.vue
@@ -68,7 +68,7 @@ import AuthBox from '@components/AuthBox.vue';
 import { fetchContent } from '@utils/api/content';
 import { signUp, completeUrl } from '@utils/api/signup';
 
-import { generalContent } from '@store';
+import { generalContent, isEmbed } from '@store';
 
 import type { ContentJoin } from '@type';
 
@@ -97,12 +97,17 @@ const { signUpData, signUpDescription } = useJoin(joinContent);
 
 async function submitSignUp() {
   const data = await signUp(signUpData);
+  const topWindow = window.top || window;
   if (data.redirectUrl) {
-    (window.top || window).location.href = data.redirectUrl;
+    topWindow.location.href = data.redirectUrl;
   } else if (data.clientSecret) {
     stripeClientSecret.value = data.clientSecret;
   } else {
-    router.push({ path: '/join/confirm-email' });
+    if (isEmbed) {
+      topWindow.location.href = '/join/confirm-email';
+    } else {
+      router.push({ path: '/join/confirm-email' });
+    }
   }
 }