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

View File

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

View File

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

View File

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

View File

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

View File

@ -75,7 +75,10 @@ export function SimFeatureToggles({
if (nt !== initial.nt) featurePayload.networkType = nt; if (nt !== initial.nt) featurePayload.networkType = nt;
if (Object.keys(featurePayload).length > 0) { 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"); setSuccess("Changes submitted successfully");

View File

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

View File

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