import React, { ReactNode } from 'react'; import { Machine } from '../../models/machine'; import { useTranslation } from 'react-i18next'; import { Loader } from '../base/loader'; interface MachineCardProps { machine: Machine, onShowMachine: (machine: Machine) => void, onReserveMachine: (machine: Machine) => void, } /** * This component is a box showing the picture of the given machine and two buttons: one to start the reservation process * and another to redirect the user to the machine description page. */ const MachineCardComponent: React.FC = ({ machine, onShowMachine, onReserveMachine }) => { const { t } = useTranslation('public'); /** * Callback triggered when the user clicks on the 'reserve' button. * We handle the training verification process here, before redirecting the user to the reservation calendar. */ const handleReserveMachine = (): void => { onReserveMachine(machine); } /** * Callback triggered when the user clicks on the 'view' button */ const handleShowMachine = (): void => { onShowMachine(machine); } const machinePicture = (): ReactNode => { if (!machine.machine_image) { return (
{machine.name}
); } return (
) } return (
{machinePicture()}
{machine.name}
{!machine.disabled && }
); } export const MachineCard: React.FC = ({ machine, onShowMachine, onReserveMachine }) => { return ( ); }