Просмотр исходного кода

Refactor PlaymateBankApply and PlaymateIdentityApply pages to simplify ID handling

- Removed the objectIdToRowKey function and updated rowKey to directly use record.id for both PlaymateBankApplyPage and PlaymateIdentityApplyPage, streamlining ID management.
- Updated PlaymateBankApplyAdminDTO and PlaymateIdentityApplyAdminDTO interfaces to change the id type from ObjectIdLike to string for consistency and clarity.
- Removed ObjectIdLike type definition from related API type files, simplifying type management across the application.
0es 1 месяц назад
Родитель
Сommit
6bdc48e00b

+ 1 - 11
src/app/(dashboard)/playmate/bank-apply/page.tsx

@@ -30,22 +30,12 @@ import {
   getPlaymateBankApplyPage,
 } from "@/services/playmateBankApply";
 import type {
-  ObjectIdLike,
   PagerPlaymateBankApplyAdminDTO,
   PlaymateBankApplyAdminDTO,
   PlaymateBankApplyAdminQuery,
 } from "@/types/api/playmateBankApply";
 import { formatTimestamp } from "@/utils/date";
 
-function objectIdToRowKey(id: ObjectIdLike): string {
-  if (typeof id === "string") return id;
-  try {
-    return JSON.stringify(id);
-  } catch {
-    return String(id?.timestamp ?? "") + String(id?.date ?? "");
-  }
-}
-
 const PlaymateBankApplyPage: React.FC = () => {
   const { message } = App.useApp();
   const [searchForm] = Form.useForm();
@@ -356,7 +346,7 @@ const PlaymateBankApplyPage: React.FC = () => {
         <Table
           columns={columns}
           dataSource={dataSource}
-          rowKey={(record) => objectIdToRowKey(record.id)}
+          rowKey={(record) => record.id}
           loading={loading}
           pagination={{
             current: queryParams.pageIndex,

+ 1 - 11
src/app/(dashboard)/playmate/identity-apply/page.tsx

@@ -30,22 +30,12 @@ import {
   getPlaymateIdentityApplyPage,
 } from "@/services/playmateIdentityApply";
 import type {
-  ObjectIdLike,
   PagerPlaymateIdentityApplyAdminDTO,
   PlaymateIdentityApplyAdminDTO,
   PlaymateIdentityApplyAdminQuery,
 } from "@/types/api/playmateIdentityApply";
 import { formatTimestamp } from "@/utils/date";
 
-function objectIdToRowKey(id: ObjectIdLike): string {
-  if (typeof id === "string") return id;
-  try {
-    return JSON.stringify(id);
-  } catch {
-    return String(id?.timestamp ?? "") + String(id?.date ?? "");
-  }
-}
-
 const PlaymateIdentityApplyPage: React.FC = () => {
   const { message } = App.useApp();
   const [searchForm] = Form.useForm();
@@ -348,7 +338,7 @@ const PlaymateIdentityApplyPage: React.FC = () => {
         <Table
           columns={columns}
           dataSource={dataSource}
-          rowKey={(record) => objectIdToRowKey(record.id)}
+          rowKey={(record) => record.id}
           loading={loading}
           pagination={{
             current: queryParams.pageIndex,

+ 3 - 8
src/types/api/playmateBankApply.ts

@@ -1,14 +1,9 @@
 /**
  * Playmate bank apply (real-name bank binding verification) related API type definitions
- *
- * Note:
- * - Backend ObjectId may be returned as string or { timestamp, date } object.
  */
 
 import type { QuerySort } from "./common";
 
-export type ObjectIdLike = string | { timestamp?: number; date?: string };
-
 // ============================
 // Query / Pager
 // ============================
@@ -30,9 +25,9 @@ export interface PlaymateBankApplyAdminQuery {
 
 export interface PlaymateBankApplyAdminDTO {
   /**
-   * Record id (ObjectId)
+   * Record id
    */
-  id: ObjectIdLike;
+  id: string;
   createdAt?: number;
   updatedAt?: number;
   userNo?: string;
@@ -67,7 +62,7 @@ export interface PagerPlaymateBankApplyAdminDTO {
 // ============================
 
 export interface PlaymateBankApprovalAdminDTO {
-  id: ObjectIdLike;
+  id: string;
   /**
    * 1: approved, 2: rejected
    */

+ 3 - 8
src/types/api/playmateIdentityApply.ts

@@ -1,14 +1,9 @@
 /**
  * Playmate identity apply (real-name verification) related API type definitions
- *
- * Note:
- * - Backend ObjectId may be returned as string or { timestamp, date } object.
  */
 
 import type { QuerySort } from "./common";
 
-export type ObjectIdLike = string | { timestamp?: number; date?: string };
-
 // ============================
 // Query / Pager
 // ============================
@@ -30,9 +25,9 @@ export interface PlaymateIdentityApplyAdminQuery {
 
 export interface PlaymateIdentityApplyAdminDTO {
   /**
-   * Record id (ObjectId)
+   * Record id
    */
-  id: ObjectIdLike;
+  id: string;
   createdAt?: number;
   updatedAt?: number;
   userNo?: string;
@@ -61,7 +56,7 @@ export interface PagerPlaymateIdentityApplyAdminDTO {
 // ============================
 
 export interface PlaymateIdentityApprovalAdminDTO {
-  id: ObjectIdLike;
+  id: string;
   /**
    * 1: approved, 2: rejected
    */

+ 4 - 9
src/types/api/userWithdraw.ts

@@ -1,14 +1,9 @@
 /**
  * User withdraw apply related API type definitions
- *
- * Note:
- * - Backend ObjectId is already converted to string by middleware
  */
 
 import type { QuerySort } from "./common";
 
-export type ObjectIdLike = string;
-
 // ============================
 // Query / Pager
 // ============================
@@ -42,13 +37,13 @@ export interface UserWithdrawBeanApplyAdminQuery {
 
 export interface UserWithdrawBeanApplyAdminDTO {
   /**
-   * Record id (converted to string)
+   * Record id
    */
-  id: ObjectIdLike;
+  id: string;
   /**
-   * User id (converted to string)
+   * User id
    */
-  userId?: ObjectIdLike;
+  userId?: string;
   /**
    * Order number
    */