refactor(hunt): replace admin middleware with auth and implement membership state
- Change middleware from 'admin' to 'auth' on hunt and quest admin pages - Add global hunt store to track current hunt ID and membership status - Use hunt store membership state to conditionally display admin UI elements - Handle fetch errors gracefully with alerts and back navigation buttons - Update admin UI logic to depend on membership state instead of user role - Add membership state update after API calls in hunt, quest, teams, and admin pages - Refactor UI templates to show error messages when fetch fails - Centralize membership logic for better authorization control in frontend
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { parseError } from '#imports';
|
||||
import TeamAddModal from '~/components/TeamAddModal.vue';
|
||||
import { useHuntStore } from '~/stores/hunt';
|
||||
import { useSettingsStore } from '~/stores/settings';
|
||||
import { useTitleStore } from '~/stores/title';
|
||||
import { fullDate } from '~~/server/utils/date';
|
||||
@@ -15,9 +16,12 @@ const { init } = useToast();
|
||||
const { name, id } = app.$slugData.huntSlug!;
|
||||
|
||||
const titleStore = useTitleStore();
|
||||
const huntStore = useHuntStore();
|
||||
|
||||
const { data, pending, refresh, error } = await useFetch(`/api/hunt/${id}`);
|
||||
|
||||
huntStore.setMembership(id, data.value?.isMember ?? false);
|
||||
|
||||
const settings = useSettingsStore();
|
||||
|
||||
useHead({
|
||||
|
||||
Reference in New Issue
Block a user