vincentlu
2025-02-05 9d79b8c8d34077ebf782a7b61d54ee4e1debdba1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
import {
    useRecordContext,
} from 'react-admin';
import { Box, Typography, Card, Stack } from '@mui/material';
import { useTheme } from '@mui/material/styles';
 
const MyField = ({ source, onClick }) => {
    const record = useRecordContext();
    const theme = useTheme();
    
    return record ? (
        <Box
            onClick={(event) => {
                onClick && onClick(event, record, record[source]);
            }}
        >
            <Typography
                variant="body2"
                sx={{
                    color: theme.palette.primary.main,
                    textDecoration: 'underline',
                    cursor: 'pointer'
                }}
            >
                {record[source]}
            </Typography >
        </Box>
    ) : null;
}
 
export default MyField;