fix error2

This commit is contained in:
2025-10-31 18:16:53 +03:30
parent 33d4edae67
commit 4b0a110371
6 changed files with 12 additions and 4 deletions

View File

@@ -70,7 +70,7 @@ export default function DevicesPage() {
// فراخوانی API برای بررسی دستگاه
const device = await api.CheckDevice(currentDeviceName.trim(), currentPassword.trim())
if (device) {
if (device !=undefined) {
setSelected(device)
} else {
setError('دستگاه یافت نشد یا رمز عبور نادرست است')

View File

@@ -58,7 +58,7 @@ async function http<T>(url: string, init?: RequestInit): Promise<T> {
}
export const api = {
CheckDevice: (deviceName: string, password: string) => http<boolean>(`${API_BASE}/api/devices/CheckDevice?deviceName=${deviceName}&password=${password}`),
CheckDevice: (deviceName: string, password: string) => http<DeviceDto>(`${API_BASE}/api/devices/CheckDevice?deviceName=${deviceName}&password=${password}`),
listDevices: () => http<DeviceDto[]>(`${API_BASE}/api/devices`),
createDevice: (dto: DeviceDto) => http<number>(`${API_BASE}/api/devices`, { method: 'POST', body: JSON.stringify(dto) }),
listTelemetry: (q: { deviceId?: number; startUtc?: string; endUtc?: string; page?: number; pageSize?: number }) => {