import './Appoint.scss';
import { View } from '@tarojs/components';
import AppointmentCard from '../components/AppointmentCard';
import useAppointList from '../hooks/useAppointList';
import NoDataIcon from '@/components/NoDataIcon/NoDataIcon';
import { useEffect } from '@tarojs/taro';

const WashingMachineAppoint = (props: {
  getRef: (name: string, fun: Function) => void;
  startHandle: (code: string) => void;
}) => {
  const [list, refreshList] = useAppointList(0);

  useEffect(() => {
    props.getRef('Home', refreshList);
  }, []);

  return (
    <View className='WashingMachineAppoint'>
      {list && list.length ? (
        list.map(order => (
          <AppointmentCard
            key={order.orderCode}
            data={order}
            startHandle={props.startHandle}
          />
        ))
      ) : (
        <NoDataIcon text='暂无预约记录~' />
      )}
    </View>
  );
};

export default WashingMachineAppoint;
