fix: resolve type errors in devices pages
This commit is contained in:
@@ -108,7 +108,7 @@ export const listDeviceSessions = query(async (deviceId: string) => {
|
|||||||
return sessions;
|
return sessions;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const listSessionSteps = query(async (deviceId: string, sessionId: string) => {
|
export const listSessionSteps = query(async ({ deviceId, sessionId }: { deviceId: string; sessionId: string }) => {
|
||||||
const { locals } = getRequestEvent();
|
const { locals } = getRequestEvent();
|
||||||
if (!locals.user) return [];
|
if (!locals.user) return [];
|
||||||
|
|
||||||
|
|||||||
@@ -4,22 +4,37 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import DeviceCard from '$lib/components/DeviceCard.svelte';
|
import DeviceCard from '$lib/components/DeviceCard.svelte';
|
||||||
|
|
||||||
|
interface DeviceEntry {
|
||||||
|
deviceId: string;
|
||||||
|
name: string;
|
||||||
|
status: 'online' | 'offline';
|
||||||
|
model: string | null;
|
||||||
|
manufacturer: string | null;
|
||||||
|
androidVersion: string | null;
|
||||||
|
screenWidth: number | null;
|
||||||
|
screenHeight: number | null;
|
||||||
|
batteryLevel: number | null;
|
||||||
|
isCharging: boolean;
|
||||||
|
lastSeen: string;
|
||||||
|
lastGoal: { goal: string; status: string; startedAt: string } | null;
|
||||||
|
}
|
||||||
|
|
||||||
const initialDevices = await listDevices();
|
const initialDevices = await listDevices();
|
||||||
|
|
||||||
let devices = $state(
|
let devices = $state<DeviceEntry[]>(
|
||||||
initialDevices.map((d) => ({
|
initialDevices.map((d) => ({
|
||||||
deviceId: d.deviceId,
|
deviceId: d.deviceId,
|
||||||
name: d.name,
|
name: d.name,
|
||||||
status: d.status as 'online' | 'offline',
|
status: d.status as 'online' | 'offline',
|
||||||
model: d.model,
|
model: d.model as string | null,
|
||||||
manufacturer: d.manufacturer,
|
manufacturer: d.manufacturer as string | null,
|
||||||
androidVersion: d.androidVersion,
|
androidVersion: d.androidVersion as string | null,
|
||||||
screenWidth: d.screenWidth,
|
screenWidth: d.screenWidth as number | null,
|
||||||
screenHeight: d.screenHeight,
|
screenHeight: d.screenHeight as number | null,
|
||||||
batteryLevel: d.batteryLevel,
|
batteryLevel: d.batteryLevel as number | null,
|
||||||
isCharging: d.isCharging,
|
isCharging: d.isCharging as boolean,
|
||||||
lastSeen: d.lastSeen,
|
lastSeen: d.lastSeen,
|
||||||
lastGoal: d.lastGoal
|
lastGoal: d.lastGoal as DeviceEntry['lastGoal']
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,12 @@
|
|||||||
const deviceData = allDevices.find((d) => d.deviceId === deviceId);
|
const deviceData = allDevices.find((d) => d.deviceId === deviceId);
|
||||||
|
|
||||||
// Device stats
|
// Device stats
|
||||||
const stats = await getDeviceStats(deviceId);
|
const stats = (await getDeviceStats(deviceId)) as {
|
||||||
|
totalSessions: number;
|
||||||
|
successRate: number;
|
||||||
|
avgSteps: number;
|
||||||
|
lastGoal: { goal: string; status: string; startedAt: Date } | null;
|
||||||
|
} | null;
|
||||||
|
|
||||||
// Session history
|
// Session history
|
||||||
interface Session {
|
interface Session {
|
||||||
@@ -59,7 +64,7 @@
|
|||||||
}
|
}
|
||||||
expandedSession = sessionId;
|
expandedSession = sessionId;
|
||||||
if (!sessionSteps.has(sessionId)) {
|
if (!sessionSteps.has(sessionId)) {
|
||||||
const loadedSteps = await listSessionSteps(deviceId, sessionId);
|
const loadedSteps = await listSessionSteps({ deviceId, sessionId });
|
||||||
sessionSteps.set(sessionId, loadedSteps as Step[]);
|
sessionSteps.set(sessionId, loadedSteps as Step[]);
|
||||||
sessionSteps = new Map(sessionSteps);
|
sessionSteps = new Map(sessionSteps);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user