diff --git a/frontend/src/stores/brandingStore.js b/frontend/src/stores/brandingStore.js index ab8c88c..9e71f9f 100644 --- a/frontend/src/stores/brandingStore.js +++ b/frontend/src/stores/brandingStore.js @@ -10,6 +10,8 @@ export const useBrandingStore = defineStore( const currentBrand = ref(undefined) const loading = ref(false) + const error = ref(null) + const notFound = ref(false) const value = useSessionStorage( 'branding', @@ -30,12 +32,28 @@ export const useBrandingStore = defineStore( async function updateBrand(newBrand) { loading.value = true + error.value = null + notFound.value = false if (newBrand !== currentBrand.value) { if (newBrand !== undefined) { - value.value = await fetchCreatorData(newBrand) - currentBrand.value = newBrand - presentationInfos.value = value.value?.presentationInfos + const result = await fetchCreatorData(newBrand) + if (result.success) { + value.value = result.data + currentBrand.value = newBrand + presentationInfos.value = result.data?.presentationInfos + } else { + // Handle different error types + if (result.status === 404) { + notFound.value = true + error.value = 'Creator not found' + } else { + error.value = result.error || 'Failed to load creator' + } + value.value = {} + currentBrand.value = undefined + presentationInfos.value = [] + } } else { value.value = {} currentBrand.value = undefined @@ -50,15 +68,29 @@ export const useBrandingStore = defineStore( try { const client = useClient() const response = await client.get(`/api/creators/@${creatorAlias}`) - return response.data + return { success: true, data: response.data } } catch (error) { - await router.push('/'); + console.error('Error fetching creator data:', error) + + if (error.response?.status === 404) { + return { success: false, status: 404, error: 'Creator not found' } + } + + return { + success: false, + status: error.response?.status || 500, + error: error.message || 'Unknown error occurred' + } } } return { currentBrand, value, - loading, updateBrand, presentationInfos + loading, + error, + notFound, + updateBrand, + presentationInfos } }) diff --git a/frontend/src/views/creators/CreatorLayout.vue b/frontend/src/views/creators/CreatorLayout.vue index 8cf96c3..47a9e55 100644 --- a/frontend/src/views/creators/CreatorLayout.vue +++ b/frontend/src/views/creators/CreatorLayout.vue @@ -1,72 +1,166 @@ + + + + - + + + + 404 + {{ t('creator.notFound.title') }} + {{ t('creator.notFound.message', { creator: creatorName }) }} - - + + + {{ t('creator.notFound.goHome') }} + + + + {{ t('creator.notFound.goBack') }} + + + + + + + + + ⚠️ + {{ t('creator.error.title') }} + {{ t('creator.error.message') }} + + + {{ t('creator.error.goHome') }} + + + + + + + + {{ t('creator.layout.deletion.pending') }} + + + + + + - - - - {{ t('creator.layout.deletion.pending') }} - - - - - - - - - { - "en": { - "creator": { - "layout": { - "deletion": { - "pending": "This creator page is pending deletion" + "en": { + "creator": { + "layout": { + "deletion": { + "pending": "This creator page is pending deletion" + } + }, + "notFound": { + "title": "Creator Not Found", + "message": "The creator '{creator}' doesn't exist or may have been removed.", + "goHome": "Go to Home", + "goBack": "Go Back" + }, + "error": { + "title": "Something Went Wrong", + "message": "We're having trouble loading this creator page. Please try again later.", + "goHome": "Go to Home" + } } - } - } - }, - "fr": { - "creator": { - "layout": { - "deletion": { - "pending": "Cette page créateur est en attente de suppression" + }, + "fr": { + "creator": { + "layout": { + "deletion": { + "pending": "Cette page créateur est en attente de suppression" + } + }, + "notFound": { + "title": "Créateur Introuvable", + "message": "Le créateur '{creator}' n'existe pas ou a peut-être été supprimé.", + "goHome": "Aller à l'accueil", + "goBack": "Retour" + }, + "error": { + "title": "Quelque chose s'est mal passé", + "message": "Nous avons des difficultés à charger cette page créateur. Veuillez réessayer plus tard.", + "goHome": "Aller à l'accueil" + } } - } - } - }, - "es": { - "creator": { - "layout": { - "deletion": { - "pending": "Esta página de creador está pendiente de eliminación" + }, + "es": { + "creator": { + "layout": { + "deletion": { + "pending": "Esta página de creador está pendiente de eliminación" + } + }, + "notFound": { + "title": "Creador No Encontrado", + "message": "El creador '{creator}' no existe o puede haber sido eliminado.", + "goHome": "Ir al Inicio", + "goBack": "Volver" + }, + "error": { + "title": "Algo Salió Mal", + "message": "Tenemos problemas para cargar esta página de creador. Por favor, inténtalo de nuevo más tarde.", + "goHome": "Ir al Inicio" + } } - } } - } }
{{ t('creator.notFound.message', { creator: creatorName }) }}
{{ t('creator.error.message') }}