Feat: Alter Item to TransferListItemType #3221 (#5986)

### What problem does this PR solve?

Feat: Alter Item to TransferListItemType #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu 2025-03-12 18:54:41 +08:00 committed by GitHub
parent 6e13922bdc
commit 80389ae61e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,15 +10,19 @@ import {
} from 'lucide-react';
import React from 'react';
type Item = {
export type TransferListItemType = {
key: string;
label: string;
selected?: boolean;
};
export default function TransferList({ items }: { items: Item[] }) {
const [leftList, setLeftList] = React.useState<Item[]>(items);
const [rightList, setRightList] = React.useState<Item[]>([]);
export default function TransferList({
items,
}: {
items: TransferListItemType[];
}) {
const [leftList, setLeftList] = React.useState<TransferListItemType[]>(items);
const [rightList, setRightList] = React.useState<TransferListItemType[]>([]);
const [leftSearch, setLeftSearch] = React.useState('');
const [rightSearch, setRightSearch] = React.useState('');
@ -35,8 +39,8 @@ export default function TransferList({ items }: { items: Item[] }) {
};
const toggleSelection = (
list: Item[],
setList: React.Dispatch<React.SetStateAction<Item[]>>,
list: TransferListItemType[],
setList: React.Dispatch<React.SetStateAction<TransferListItemType[]>>,
key: string,
) => {
const updatedList = list.map((item) => {