Skip to content

Commit d8d03f2

Browse files
committed
feat(characters): update game code type to enum instead of string
1 parent 138d37a commit d8d03f2

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

electron/renderer/components/sidebar/characters/modal-add-character.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ import sortBy from 'lodash-es/sortBy.js';
1010
import { useCallback, useEffect, useMemo } from 'react';
1111
import type { ReactNode } from 'react';
1212
import { Controller, useForm } from 'react-hook-form';
13+
import type { GameCode } from '../../../../common/game/types.js';
1314
import { useListAccounts } from '../../../hooks/accounts.jsx';
1415
import { runInBackground } from '../../../lib/async/run-in-background.js';
1516
import { GameCodeSelectOptions } from '../../../lib/game/game-code-labels.js';
1617

1718
export interface ModalAddCharacterInitialData {
1819
accountName?: string;
1920
characterName?: string;
20-
gameCode?: string;
21+
gameCode?: GameCode;
2122
}
2223

2324
export interface ModalAddCharacterConfirmData {
2425
accountName: string;
2526
characterName: string;
26-
gameCode: string;
27+
gameCode: GameCode;
2728
}
2829

2930
export interface ModalAddCharacterProps {

electron/renderer/components/sidebar/characters/modal-edit-character.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ import sortBy from 'lodash-es/sortBy.js';
1010
import { useCallback, useEffect, useMemo } from 'react';
1111
import type { ReactNode } from 'react';
1212
import { Controller, useForm } from 'react-hook-form';
13+
import type { GameCode } from '../../../../common/game/types.js';
1314
import { useListAccounts } from '../../../hooks/accounts.jsx';
1415
import { runInBackground } from '../../../lib/async/run-in-background.js';
1516
import { GameCodeSelectOptions } from '../../../lib/game/game-code-labels.js';
1617

1718
export interface ModalEditCharacterInitialData {
1819
accountName: string;
1920
characterName: string;
20-
gameCode: string;
21+
gameCode: GameCode;
2122
}
2223

2324
export interface ModalEditCharacterConfirmData {
2425
accountName: string;
2526
characterName: string;
26-
gameCode: string;
27+
gameCode: GameCode;
2728
}
2829

2930
export interface ModalEditCharacterProps {

electron/renderer/components/sidebar/characters/modal-remove-character.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { EuiCode, EuiConfirmModal } from '@elastic/eui';
22
import type { ReactNode } from 'react';
33
import { useCallback } from 'react';
4+
import type { GameCode } from '../../../../common/game/types.js';
45

56
export interface ModalRemoveCharacterInitialData {
67
accountName: string;
78
characterName: string;
8-
gameCode: string;
9+
gameCode: GameCode;
910
}
1011

1112
export interface ModalRemoveCharacterConfirmData {
1213
accountName: string;
1314
characterName: string;
14-
gameCode: string;
15+
gameCode: GameCode;
1516
}
1617

1718
export interface ModalRemoveCharacterProps {

electron/renderer/lib/game/game-code-labels.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { GameCode } from '../../../common/game/types.js';
12
import { GameCodeMetaMap } from '../../../common/game/types.js';
23

34
/**
@@ -13,11 +14,11 @@ export const GameCodeSelectOptions: Array<{
1314
* Game code for the game instance.
1415
* Example: 'DR'
1516
*/
16-
value: string;
17-
}> = Object.entries(GameCodeMetaMap).map(([gameCode, gameMeta]) => {
18-
const { name } = gameMeta;
17+
value: GameCode;
18+
}> = Object.values(GameCodeMetaMap).map((gameMeta) => {
19+
const { name, code } = gameMeta;
1920
return {
2021
label: name,
21-
value: gameCode,
22+
value: code,
2223
};
2324
});

0 commit comments

Comments
 (0)