import { Draggable } from '@hello-pangea/dnd';
|
import { Box, Card, Typography } from '@mui/material';
|
import { ReferenceField, useRedirect } from 'react-admin';
|
|
export const MissionCard = ({ mission, index }) => {
|
if (!mission) return null;
|
|
return (
|
<Draggable draggableId={String(mission.id)} index={index}>
|
{(provided, snapshot) => (
|
<MissionCardContent
|
provided={provided}
|
snapshot={snapshot}
|
mission={mission}
|
/>
|
)}
|
</Draggable>
|
);
|
};
|
|
export const MissionCardContent = ({ provided, snapshot, mission, }) => {
|
const redirect = useRedirect();
|
const handleClick = () => {
|
redirect(`/mission/${mission.id}/show`, undefined, undefined, undefined, {
|
_scrollToTop: false,
|
});
|
};
|
|
return (
|
<Box
|
sx={{ marginBottom: 1, cursor: 'pointer' }}
|
{...provided?.draggableProps}
|
{...provided?.dragHandleProps}
|
ref={provided?.innerRef}
|
onClick={handleClick}
|
>
|
<Card
|
style={{
|
opacity: snapshot?.isDragging ? 0.9 : 1,
|
transform: snapshot?.isDragging ? 'rotate(-2deg)' : '',
|
}}
|
elevation={snapshot?.isDragging ? 3 : 1}
|
>
|
<Box padding={1} display="flex">
|
<ReferenceField
|
source="company_id"
|
record={mission}
|
reference="companies"
|
link={false}
|
>
|
</ReferenceField>
|
<Box sx={{ marginLeft: 1 }}>
|
<Typography variant="body2" gutterBottom>
|
{mission.groupNo}
|
</Typography>
|
<Typography variant="caption" color="textSecondary">
|
{mission.posType}
|
</Typography>
|
</Box>
|
</Box>
|
</Card>
|
</Box>
|
);
|
};
|