✨ Add BaseModal import and simplify useAsyncState calls in ApiKeyManager and GamemasterManager views
This commit is contained in:
@@ -160,6 +160,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import ChallongeApiKeyGuide from '../components/ChallongeApiKeyGuide.vue';
|
import ChallongeApiKeyGuide from '../components/ChallongeApiKeyGuide.vue';
|
||||||
|
import { BaseModal } from '../components/shared/index.js';
|
||||||
import { useChallongeApiKey } from '../composables/useChallongeApiKey.js';
|
import { useChallongeApiKey } from '../composables/useChallongeApiKey.js';
|
||||||
|
|
||||||
const { saveApiKey, clearApiKey, maskedKey, isKeyStored } =
|
const { saveApiKey, clearApiKey, maskedKey, isKeyStored } =
|
||||||
|
|||||||
@@ -203,13 +203,10 @@ const {
|
|||||||
data: serverStatus,
|
data: serverStatus,
|
||||||
loading: statusLoading,
|
loading: statusLoading,
|
||||||
error: statusError
|
error: statusError
|
||||||
} = useAsyncState(
|
} = useAsyncState(async () => {
|
||||||
async () => {
|
const response = await apiClient.get('/api/gamemaster/status');
|
||||||
const response = await apiClient.get('/api/gamemaster/status');
|
return response;
|
||||||
return response;
|
}, null);
|
||||||
},
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
// Fetch gamemaster state
|
// Fetch gamemaster state
|
||||||
const {
|
const {
|
||||||
@@ -218,13 +215,10 @@ const {
|
|||||||
loading: gamemasterLoading,
|
loading: gamemasterLoading,
|
||||||
error: gamemasterError,
|
error: gamemasterError,
|
||||||
reset: resetGamemaster
|
reset: resetGamemaster
|
||||||
} = useAsyncState(
|
} = useAsyncState(async () => {
|
||||||
async () => {
|
const data = await fetchLatestGamemaster();
|
||||||
const data = await fetchLatestGamemaster();
|
return data;
|
||||||
return data;
|
}, null);
|
||||||
},
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
// Save to server state
|
// Save to server state
|
||||||
const {
|
const {
|
||||||
@@ -232,22 +226,21 @@ const {
|
|||||||
loading: saving,
|
loading: saving,
|
||||||
error: saveError,
|
error: saveError,
|
||||||
reset: resetSave
|
reset: resetSave
|
||||||
} = useAsyncState(
|
} = useAsyncState(async () => {
|
||||||
async () => {
|
const result = await apiClient.post('/api/gamemaster/process', {});
|
||||||
const result = await apiClient.post('/api/gamemaster/process', {});
|
// Reload server status after save
|
||||||
// Reload server status after save
|
await loadServerStatus();
|
||||||
await loadServerStatus();
|
return result;
|
||||||
return result;
|
}, null);
|
||||||
},
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
// Process gamemaster data
|
// Process gamemaster data
|
||||||
const processedData = ref(null);
|
const processedData = ref(null);
|
||||||
const saveSuccess = ref(false);
|
const saveSuccess = ref(false);
|
||||||
|
|
||||||
// Combine error states for template
|
// Combine error states for template
|
||||||
const error = computed(() => gamemasterError.value || statusError.value || saveError.value);
|
const error = computed(
|
||||||
|
() => gamemasterError.value || statusError.value || saveError.value
|
||||||
|
);
|
||||||
|
|
||||||
const stats = computed(() => {
|
const stats = computed(() => {
|
||||||
if (!processedData.value) return null;
|
if (!processedData.value) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user