Adds delete and restore for a creator's page
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import {useClient} from "@/plugins/api.js";
|
||||
import {useSessionStorage} from "@vueuse/core";
|
||||
import {ref, watch} from "vue";
|
||||
import {useRoute} from "vue-router";
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
|
||||
export const useBrandingStore = defineStore(
|
||||
'branding',
|
||||
@@ -17,6 +17,7 @@ export const useBrandingStore = defineStore(
|
||||
{writeDefaults: false})
|
||||
|
||||
const presentationInfos = ref([])
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
watch(
|
||||
() => route.params.creator,
|
||||
@@ -49,7 +50,7 @@ export const useBrandingStore = defineStore(
|
||||
const response = await client.get(`/api/creators/@${creatorAlias}`)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
console.error(`Error fetching content: ${error}`)
|
||||
await router.push('/');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export const useCreatorProfileStore = defineStore(
|
||||
if (newValue) {
|
||||
await fetchCreatorProfile();
|
||||
if (value.value && value.value.name !== undefined) {
|
||||
await router.push(`/@${value.value.name}`);
|
||||
await router.push(`/@${value.value.slug}`);
|
||||
} else {
|
||||
await router.push('/');
|
||||
}
|
||||
@@ -56,9 +56,31 @@ export const useCreatorProfileStore = defineStore(
|
||||
}
|
||||
}
|
||||
|
||||
async function removeCreatorPage() {
|
||||
try {
|
||||
await client.delete(`/api/creators/@${value.value.slug}`)
|
||||
await fetchCreatorProfile();
|
||||
}
|
||||
catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function restoreCreatorPage() {
|
||||
try {
|
||||
await client.put(`/api/creators/@${value.value.slug}/restore`, {})
|
||||
await fetchCreatorProfile();
|
||||
}
|
||||
catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
creator: value,
|
||||
hasCreator,
|
||||
removeCreatorPage,
|
||||
restoreCreatorPage,
|
||||
fetchCreatorProfile
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user