Fix QR code creation

Change-Id: Ib6bbd1be6d4dca1f617043c3c2338924b2321ea3
This commit is contained in:
Michael Albert 2020-04-14 13:06:55 +02:00 committed by Manuel Stahl
parent bf7867f106
commit d2a3f07a59
5 changed files with 48 additions and 5 deletions

View file

@ -0,0 +1,32 @@
import React, { useCallback } from "react";
import { SaveButton, useCreate, useRedirect, useNotify } from "react-admin";
const SaveQrButton = props => {
const [create] = useCreate('users');
const redirectTo = useRedirect();
const notify = useNotify();
const { basePath } = props;
const handleSave = useCallback(
(values, redirect) => {
create(
{
payload: { data: { ...values } },
},
{
onSuccess: ({ data: newRecord }) => {
notify('ra.notification.created', 'info', {
smart_count: 1,
});
redirectTo(redirect, basePath, newRecord.id, { password: values.password, ...newRecord });
},
}
);
},
[create, notify, redirectTo, basePath]
);
return <SaveButton {...props} onSave={handleSave} />;
};
export default SaveQrButton;