This commit is contained in:
2025-02-07 15:44:59 -05:00
parent 2b30479263
commit 009368ca8f
38 changed files with 1815 additions and 945 deletions

View File

@@ -24,6 +24,7 @@ export const useAuthStore = defineStore(
const refreshToken = useSessionStorage('auth-refreshToken', undefined)
const isAuthenticated = computed(() => !!accessToken.value)
const userId = computed(() => {
const claims = getClaimsFromToken(accessToken.value)
return claims.sub;
@@ -98,5 +99,4 @@ export const useAuthStore = defineStore(
}
return {accessToken, refreshToken, isAuthenticated, userId, login, loginWithGoogle, logout}
})
})

View File

@@ -41,8 +41,8 @@ export const useBrandingStore = defineStore(
if (newCreator !== undefined) {
value.value = await fetchCreatorData(newCreator)
currentBrand.value = newCreator
colors.value = value.value.colors
presentationInfos.value = value.value.presentationInfos
colors.value = value.value?.colors
presentationInfos.value = value.value?.presentationInfos
} else {
value.value = {}
currentBrand.value = undefined

View File

@@ -1,67 +1,70 @@
import { useClient } from '@/plugins/api.js';
import { useAuthStore } from '@/stores/authStore.js';
import { useSessionStorage } from '@vueuse/core';
import { defineStore } from 'pinia';
import { computed, watch } from 'vue';
import { useRouter } from 'vue-router';
import {useClient} from '@/plugins/api.js';
import {useAuthStore} from '@/stores/authStore.js';
import {useSessionStorage} from '@vueuse/core';
import {defineStore} from 'pinia';
import {computed, watch} from 'vue';
import {useRouter} from 'vue-router';
export const useCreatorProfileStore = defineStore('creator-profile', () => {
const router = useRouter();
const authStore = useAuthStore();
watch(
() => authStore.isAuthenticated,
async (newValue) => {
if (newValue) {
await fetchCurrentCreatorProfile();
if (value.value === undefined) {
await router.push('/');
} else {
await router.push(`/@${value.value.name}`);
}
} else {
value.value = undefined;
}
}
);
const value = useSessionStorage(
export const useCreatorProfileStore = defineStore(
'creator-profile',
undefined,
{ writeDefaults: false }
);
() => {
const router = useRouter();
const authStore = useAuthStore();
watch(
() => authStore.isAuthenticated,
async (newValue) => {
if (newValue) {
await fetchCurrentCreatorProfile();
if (value.value === undefined) {
await router.push('/');
} else {
await router.push(`/@${value.value.name}`);
}
} else {
value.value = undefined;
}
}
);
const hasCreator = computed(
() => value.value && Object.getOwnPropertyNames(value.value).length >= 1
);
const value = useSessionStorage(
'creator-profile',
{},
{writeDefaults: false}
);
const client = useClient();
const hasCreator = computed(
() => value.value && Object.getOwnPropertyNames(value.value).length >= 1
);
async function fetchCurrentCreatorProfile() {
try {
const creatorResponse = await client.get(`/api/creators/profile`);
value.value = creatorResponse.data;
// TODO: no cache-busting ???
} catch (error) {
value.value = undefined;
}
}
const client = useClient();
async function ConfigureStripeAccount() {
try {
await client.post(`/api/membership/stripe-account`);
return true;
} catch (error) {
return false;
}
}
async function fetchCurrentCreatorProfile() {
try {
const creatorResponse = await client.get(`/api/creators/profile`);
console.log('creatorProfile');
console.dir(creatorResponse.data)
value.value = creatorResponse.data;
console.dir(value.value);
// TODO: no cache-busting ???
} catch (error) {
console.log(`!!!`)
value.value = undefined;
}
}
return {
creator: value,
hasCreator,
fetchCurrentCreatorProfile,
ConfigureStripeAccount,
};
});
async function ConfigureStripeAccount() {
try {
await client.post(`/api/membership/stripe-account`);
return true;
} catch (error) {
return false;
}
}
return {
creator: value,
hasCreator,
fetchCurrentCreatorProfile,
ConfigureStripeAccount,
};
});