import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import { ListDateGroup } from '../list-date-group';
import { AccountHolderSearchListProps, AdditionalServiceCategory } from '../../model/types'

export const AccountHolderSearchList = ({
    listItems,
    mid
}: AccountHolderSearchListProps) => {
    const { navigate } = useNavigate();

    const getListDateGroup = () => {
        let rs = [];
        for (const [key, value] of Object.entries(listItems)) {
            rs.push(
                <ListDateGroup
                    additionalServiceCategory={AdditionalServiceCategory.AccountHolderSearch}
                    key={key}
                    date={key}
                    items={value}
                    mid={mid}
                ></ListDateGroup>
            );
        }
        return rs;
    };

    const onClickToNavigate = () => {
        navigate(PATHS.additionalService.accountHolderSearch.request)
    };

    return (
        <>
            <div className="transaction-list">
                {getListDateGroup()}
                <div className="apply-row">
                    <button
                        className="btn-50 btn-blue flex-1"
                        onClick={() => onClickToNavigate()}
                    >조회 신청</button>
                </div>
            </div>
        </>
    );
}