diff --git a/apps/app-frontend/src/App.vue b/apps/app-frontend/src/App.vue index de2038604a..9efe0f30c9 100644 --- a/apps/app-frontend/src/App.vue +++ b/apps/app-frontend/src/App.vue @@ -40,7 +40,6 @@ import { OverflowMenu, PopupNotificationPanel, ProgressSpinner, - provideAuth, provideModalBehavior, provideModrinthClient, provideNotificationManager, @@ -58,7 +57,7 @@ import { openUrl } from '@tauri-apps/plugin-opener' import { type } from '@tauri-apps/plugin-os' import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state' import { $fetch } from 'ofetch' -import { computed, onMounted, onUnmounted, provide, reactive, ref, watch, watchEffect } from 'vue' +import { computed, onMounted, onUnmounted, provide, ref, watch } from 'vue' import { RouterView, useRoute, useRouter } from 'vue-router' import ModrinthAppLogo from '@/assets/modrinth_app.svg?component' @@ -107,6 +106,7 @@ import { } from '@/providers/download-progress.ts' import { createServerInstall, provideServerInstall } from '@/providers/server-install' import { setupProviders } from '@/providers/setup' +import { setupAuthProvider } from '@/providers/setup/auth' import { useError } from '@/store/error.js' import { useLoading, useTheming } from '@/store/state' @@ -455,21 +455,10 @@ const credentials = ref() const modrinthLoginFlowWaitModal = ref() -const authProvider = reactive({ - session_token: null, - user: null, - requestSignIn: async (_redirectPath) => { - await signIn() - }, +setupAuthProvider(credentials, async (_redirectPath) => { + await signIn() }) -watchEffect(() => { - authProvider.session_token = credentials.value?.session ?? null - authProvider.user = credentials.value?.user ?? null -}) - -provideAuth(authProvider) - async function fetchCredentials() { const creds = await getCreds().catch(handleError) if (creds && creds.user_id) { diff --git a/apps/app-frontend/src/providers/setup/auth.ts b/apps/app-frontend/src/providers/setup/auth.ts new file mode 100644 index 0000000000..bf522c59a3 --- /dev/null +++ b/apps/app-frontend/src/providers/setup/auth.ts @@ -0,0 +1,29 @@ +import type { Labrinth } from '@modrinth/api-client' +import { type AuthProvider, provideAuth } from '@modrinth/ui' +import { type Ref, ref, watchEffect } from 'vue' + +type AppCredentials = { + session?: string | null + user?: Labrinth.Users.v2.User | null +} + +export function setupAuthProvider( + credentials: Ref, + requestSignIn: (redirectPath: string) => void | Promise, +) { + const sessionToken = ref(null) + const user = ref(null) + + const authProvider: AuthProvider = { + session_token: sessionToken, + user, + requestSignIn, + } + + watchEffect(() => { + sessionToken.value = credentials.value?.session ?? null + user.value = credentials.value?.user ?? null + }) + + provideAuth(authProvider) +} diff --git a/apps/frontend/src/providers/setup/auth.ts b/apps/frontend/src/providers/setup/auth.ts index 3681f6e4f1..ae717324b0 100644 --- a/apps/frontend/src/providers/setup/auth.ts +++ b/apps/frontend/src/providers/setup/auth.ts @@ -1,12 +1,15 @@ import type { Labrinth } from '@modrinth/api-client' import { type AuthProvider, provideAuth } from '@modrinth/ui' -import { reactive, watchEffect } from 'vue' +import { ref, watchEffect } from 'vue' export function setupAuthProvider(auth: Awaited>) { const router = useRouter() - const authProvider = reactive({ - session_token: null, - user: null, + const sessionToken = ref(null) + const user = ref(null) + + const authProvider: AuthProvider = { + session_token: sessionToken, + user, requestSignIn: async (redirectPath: string) => { await router.push({ path: '/auth/sign-in', @@ -15,11 +18,11 @@ export function setupAuthProvider(auth: Awaited>) { }, }) }, - }) + } watchEffect(() => { - authProvider.session_token = auth.value.token || null - authProvider.user = (auth.value.user as Labrinth.Users.v2.User | null) ?? null + sessionToken.value = auth.value.token || null + user.value = (auth.value.user as Labrinth.Users.v2.User | null) ?? null }) provideAuth(authProvider) diff --git a/packages/ui/src/components/billing/ModalBasedServerPlan.vue b/packages/ui/src/components/billing/ModalBasedServerPlan.vue deleted file mode 100644 index ce363cccca..0000000000 --- a/packages/ui/src/components/billing/ModalBasedServerPlan.vue +++ /dev/null @@ -1,149 +0,0 @@ - - - diff --git a/packages/ui/src/components/billing/ModrinthServersPurchaseModal.vue b/packages/ui/src/components/billing/ModrinthServersPurchaseModal.vue index 323d9f3df4..487f3e4f9d 100644 --- a/packages/ui/src/components/billing/ModrinthServersPurchaseModal.vue +++ b/packages/ui/src/components/billing/ModrinthServersPurchaseModal.vue @@ -283,6 +283,10 @@ function handleChooseCustom() { selectedPlan.value = undefined } +function handleProceed() { + setStep(nextStep.value) +} + // When the user explicitly wants to change or add a payment method from Review // we must disable the auto-skip behavior, clear any selected method, and // navigate to the Payment step so Stripe Elements can mount. @@ -328,7 +332,7 @@ function goToBreadcrumbStep(id: string) { -
+
- +