Lint fixes

This commit is contained in:
tema 2025-09-09 16:13:17 +09:00
parent 5f7fb483d7
commit f21db44611
8 changed files with 27 additions and 15 deletions

View File

@ -152,7 +152,7 @@ export class FreebititService {
T extends {
resultCode: string | number;
status?: { message?: string; statusCode?: string | number };
}
},
>(endpoint: string, data: unknown): Promise<T> {
const authKey = await this.getAuthKey();
const requestData = { ...(data as Record<string, unknown>), authKey };
@ -320,7 +320,11 @@ export class FreebititService {
};
const datas = response.responseDatas as unknown;
const list = Array.isArray(datas) ? (datas as AcctDetailItem[]) : datas ? [datas as AcctDetailItem] : [];
const list = Array.isArray(datas)
? (datas as AcctDetailItem[])
: datas
? [datas as AcctDetailItem]
: [];
if (!list.length) {
throw new BadRequestException("No SIM details found for this account");
}
@ -525,7 +529,9 @@ export class FreebititService {
return history;
} catch (error: unknown) {
const message = error instanceof Error ? error.message : String(error);
this.logger.error(`Failed to get SIM top-up history for account ${account}`, { error: message });
this.logger.error(`Failed to get SIM top-up history for account ${account}`, {
error: message,
});
throw error as Error;
}
}

View File

@ -1,6 +1,6 @@
#!/usr/bin/env node
/* eslint-env node */
/* eslint-disable no-console */
// Ensure dev-time Next.js manifests exist to avoid noisy ENOENT errors
import { mkdirSync, existsSync, writeFileSync } from "fs";
import { join } from "path";

View File

@ -79,7 +79,7 @@ export default function SimChangePlanPage() {
</div>
)}
<form onSubmit={(e) => void submit(e)} className="space-y-6">
<form onSubmit={e => void submit(e)} className="space-y-6">
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">New Plan</label>
<select

View File

@ -83,7 +83,7 @@ export default function SimTopUpPage() {
</div>
)}
<form onSubmit={(e) => void handleSubmit(e)} className="space-y-6">
<form onSubmit={e => void handleSubmit(e)} className="space-y-6">
{/* Amount Input */}
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">Amount (GB)</label>

View File

@ -1,6 +1,6 @@
"use client";
import { useState, useEffect, useMemo } from "react";
import { useState, useEffect } from "react";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import { useAuthStore } from "@/lib/auth/store";
@ -224,7 +224,7 @@ function computeNavigation(activeSubscriptions?: Subscription[]): NavigationItem
// Inject dynamic submenu under Subscriptions
const subIdx = nav.findIndex(n => n.name === "Subscriptions");
if (subIdx >= 0) {
const baseChildren = nav[subIdx].children ?? [];
// Keep existing children, and inject dynamic subscription links below
const dynamicChildren: NavigationChild[] = (activeSubscriptions || []).map(sub => {
const hrefBase = `/subscriptions/${sub.id}`;

View File

@ -75,7 +75,10 @@ export function SimFeatureToggles({
if (nt !== initial.nt) featurePayload.networkType = nt;
if (Object.keys(featurePayload).length > 0) {
await authenticatedApi.post(`/subscriptions/${subscriptionId}/sim/features`, featurePayload);
await authenticatedApi.post(
`/subscriptions/${subscriptionId}/sim/features`,
featurePayload
);
}
setSuccess("Changes submitted successfully");

View File

@ -1,6 +1,6 @@
"use client";
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useCallback } from "react";
import {
DevicePhoneMobileIcon,
ExclamationTriangleIcon,
@ -26,7 +26,7 @@ export function SimManagementSection({ subscriptionId }: SimManagementSectionPro
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const fetchSimInfo = async () => {
const fetchSimInfo = useCallback(async () => {
try {
setError(null);
@ -38,7 +38,10 @@ export function SimManagementSection({ subscriptionId }: SimManagementSectionPro
setSimInfo(data);
} catch (err: unknown) {
const hasStatus = (v: unknown): v is { status: number } =>
typeof v === 'object' && v !== null && 'status' in v && typeof (v as { status: unknown }).status === 'number';
typeof v === "object" &&
v !== null &&
"status" in v &&
typeof (v as { status: unknown }).status === "number";
if (hasStatus(err) && err.status === 400) {
// Not a SIM subscription - this component shouldn't be shown
setError("This subscription is not a SIM service");
@ -48,11 +51,11 @@ export function SimManagementSection({ subscriptionId }: SimManagementSectionPro
} finally {
setLoading(false);
}
};
}, [subscriptionId]);
useEffect(() => {
void fetchSimInfo();
}, [subscriptionId]);
}, [fetchSimInfo]);
const handleRefresh = () => {
setLoading(true);

View File

@ -87,7 +87,7 @@ export function TopUpModal({ subscriptionId, onClose, onSuccess, onError }: TopU
</button>
</div>
<form onSubmit={(e) => void handleSubmit(e)}>
<form onSubmit={e => void handleSubmit(e)}>
{/* Amount Input */}
<div className="mb-6">
<label className="block text-sm font-medium text-gray-700 mb-2">Amount (GB)</label>