Skip to content

Commit 30cf0fd

Browse files
committed
fix: handle Java API response shapes
1 parent d8bbeae commit 30cf0fd

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎src/actions/tmgr/cursor.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export async function getGitHubBranches(taskId: number, search?: string): Promis
1616

1717
export async function getCursorAgents(taskId: number): Promise<CursorAgent[]> {
1818
const response = await $axios.get(`/tasks/${taskId}/cursor-agent`);
19-
return response.data.agents;
19+
const body = response.data;
20+
if (Array.isArray(body)) return body as CursorAgent[];
21+
return (body?.agents ?? body?.data ?? []) as CursorAgent[];
2022
}
2123

2224
export async function stopCursorAgent(taskId: number, agentId: number): Promise<void> {

‎src/components/dailyRoutine/EventBlock.vue‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<script setup lang="ts">
4848
import { computed } from 'vue';
4949
import DRIcon from './DRIcon.vue';
50-
import { hexAlpha } from '@/utils/dailyRoutines/categoryMap';
50+
import { hexAlpha, resolveCategory } from '@/utils/dailyRoutines/categoryMap';
5151
import { fmtTime } from '@/utils/dailyRoutines/dateHelpers';
5252
import type { RoutineEntry } from '@/types/dailyRoutine';
5353
@@ -86,7 +86,10 @@
8686
const isShort = computed(() => height.value < 38);
8787
8888
const blockStyle = computed(() => {
89-
const cat = props.entry.routine_category;
89+
const raw = props.entry.routine_category as unknown;
90+
const cat = typeof raw === 'string' || raw == null
91+
? resolveCategory(raw as string | null | undefined)
92+
: (raw as { color: string });
9093
const padY = isShort.value ? '2px' : props.mode === 'full' ? '6px' : '4px';
9194
const padX = props.mode === 'full' ? '10px' : '6px';
9295
return {

‎src/pages/Profile.vue‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@
6464
methods: {
6565
async saveUser() {
6666
try {
67-
this.user = updateUser(this.user);
67+
const updated = await updateUser(this.user);
68+
if (updated && typeof updated === 'object') this.user = { ...this.user, ...updated };
6869
this.showAlert('Saved', 'User data saved');
6970
} catch (error) {
70-
this.errors = error.response.data.errors;
71+
this.errors = error.response?.data?.errors ?? {};
7172
}
7273
},
7374
},

0 commit comments

Comments
 (0)