Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function PaginationActions({
classes: classesOverride,
page,
rowsPerPage,
count,
onChangePage,
}) {
const classes = useStyles({ classes: classesOverride });
const translate = useTranslate();
/**
* Warning: material-ui's page is 0-based
*/
const range = () => {
const nbPages = Math.ceil(count / rowsPerPage) || 1;
if (isNaN(page) || nbPages === 1) {
return [];
}
const input = [];
// display page links around the current page
if (page > 1) {
input.push(1);
}
if (page === 3) {
input.push(2);
}
function ResettableTextField({
classes: classesOverride,
clearAlwaysVisible,
InputProps,
value,
resettable,
disabled,
variant = 'filled',
margin = 'dense',
...props
}) {
const classes = useStyles({ classes: classesOverride });
const translate = useTranslate();
const { onChange, onFocus, onBlur } = props;
const handleClickClearButton = useCallback(
event => {
event.preventDefault();
onChange('');
},
[onChange]
);
const handleFocus = useCallback(
event => {
onFocus && onFocus(event);
},
[onFocus]
);
const RefreshIconButton = ({
label = 'ra.action.refresh',
icon = defaultIcon,
onClick,
className,
...rest
}) => {
const dispatch = useDispatch();
const translate = useTranslate();
const handleClick = useCallback(
event => {
event.preventDefault();
dispatch(refreshView());
if (typeof onClick === 'function') {
onClick();
}
},
[dispatch, onClick]
);
return (
> = ({ classes: classesOverride, ...props }) => {
const translate = useTranslate();
const classes = useStyles({ classes: classesOverride });
return (
),
}}
className={classes.input}
const InputHelperText: FunctionComponent = ({
helperText,
touched,
error,
}) => {
const translate = useTranslate();
return touched && error ? (
) : helperText ? (
<>{translate(helperText, { _: helperText })}
) : null;
};
const ExpandRowButton = ({ classes, expanded, expandContentId, ...props }) => {
const translate = useTranslate();
return (
const Error = ({
error,
errorInfo,
classes: classesOverride,
className,
title,
...rest
}) => {
const classes = useStyles({ classes: classesOverride });
const translate = useTranslate();
return (
<title>
<div className={classnames(classes.container, className)} {...rest}>
<h1 className={classes.title} role="alert">
<ErrorIcon className={classes.icon} />
{translate('ra.page.error')}
</h1>
<div>{translate('ra.message.error')}</div>
{process.env.NODE_ENV !== 'production' && (
<ExpansionPanel className={classes.panel}>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
{translate('ra.message.details')}
</ExpansionPanelSummary>
<ExpansionPanelDetails className={classes.panelDetails}>
<div></title>
> = ({
className,
classes: classesOverride,
source,
record = {},
valueLabelTrue,
valueLabelFalse,
...rest
}) => {
const classes = useStyles({ classes: classesOverride });
const translate = useTranslate();
const value = get(record, source);
let ariaLabel = value ? valueLabelTrue : valueLabelFalse;
if (!ariaLabel) {
ariaLabel = value === false ? 'ra.boolean.false' : 'ra.boolean.true';
}
if (value === false) {
return (
<span></span>
export const SelectField: SFC = ({
className,
source,
record,
choices,
optionValue,
optionText,
translateChoice,
...rest
}) => {
const translate = useTranslate();
const value = get(record, source);
const choice = choices.find(c => c[optionValue] === value);
if (!choice) {
return null;
}
let choiceIsElement = false;
let choiceName;
if (React.isValidElement(optionText)) {
choiceIsElement = true;
choiceName = React.cloneElement(optionText, { record: choice });
} else {
choiceName =
typeof optionText === 'function'
? optionText(choice)
: choice[optionText];
}
const LoginForm: FunctionComponent = ({ redirectTo }) => {
const [loading, setLoading] = useSafeSetState(false);
const login = useLogin();
const translate = useTranslate();
const notify = useNotify();
const classes = useStyles({});
const validate = (values: FormData) => {
const errors = { username: undefined, password: undefined };
if (!values.username) {
errors.username = translate('ra.validation.required');
}
if (!values.password) {
errors.password = translate('ra.validation.required');
}
return errors;
};
const submit = values => {