Fix QR code creation
Change-Id: Ib6bbd1be6d4dca1f617043c3c2338924b2321ea3
This commit is contained in:
parent
bf7867f106
commit
d2a3f07a59
@ -26,7 +26,7 @@
|
|||||||
"qrcode.react": "^1.0.0",
|
"qrcode.react": "^1.0.0",
|
||||||
"ra-language-german": "^2.1.2",
|
"ra-language-german": "^2.1.2",
|
||||||
"react": "^16.12.0",
|
"react": "^16.12.0",
|
||||||
"react-admin": "^3.1.3",
|
"react-admin": "^3.4",
|
||||||
"react-dom": "^16.12.0",
|
"react-dom": "^16.12.0",
|
||||||
"react-scripts": "^3.3.0"
|
"react-scripts": "^3.3.0"
|
||||||
},
|
},
|
||||||
|
32
src/components/SaveQrButton.js
Normal file
32
src/components/SaveQrButton.js
Normal 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;
|
@ -47,7 +47,6 @@ const ShowUserPdf = props => {
|
|||||||
marginTop: 15,
|
marginTop: 15,
|
||||||
},
|
},
|
||||||
logo: {
|
logo: {
|
||||||
height: 90,
|
|
||||||
width: 90,
|
width: 90,
|
||||||
marginTop: 20,
|
marginTop: 20,
|
||||||
marginRight: 32,
|
marginRight: 32,
|
||||||
|
@ -17,6 +17,7 @@ import {
|
|||||||
Toolbar,
|
Toolbar,
|
||||||
regex,
|
regex,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
|
import SaveQrButton from "./SaveQrButton";
|
||||||
|
|
||||||
const UserFilter = props => (
|
const UserFilter = props => (
|
||||||
<Filter {...props}>
|
<Filter {...props}>
|
||||||
@ -117,7 +118,7 @@ const redirect = (basePath, id, data) => {
|
|||||||
|
|
||||||
const UserCreateToolbar = props => (
|
const UserCreateToolbar = props => (
|
||||||
<Toolbar {...props}>
|
<Toolbar {...props}>
|
||||||
<SaveButton
|
<SaveQrButton
|
||||||
label="synapseadmin.action.save_and_show"
|
label="synapseadmin.action.save_and_show"
|
||||||
redirect={redirect}
|
redirect={redirect}
|
||||||
submitOnEnter={true}
|
submitOnEnter={true}
|
||||||
|
@ -8,8 +8,8 @@ export default {
|
|||||||
welcome: "Willkommen bei Synapse-admin",
|
welcome: "Willkommen bei Synapse-admin",
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
save_and_show: "QR Code erzeugen",
|
save_and_show: "Speichern und QR Code erzeugen",
|
||||||
save_only: "Speichern",
|
save_only: "Nur speichern",
|
||||||
download_pdf: "PDF speichern",
|
download_pdf: "PDF speichern",
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
@ -44,4 +44,15 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ra: {
|
||||||
|
...germanMessages.ra,
|
||||||
|
input: {
|
||||||
|
...germanMessages.ra.input,
|
||||||
|
password: {
|
||||||
|
...germanMessages.ra.input.password,
|
||||||
|
toggle_hidden: "Anzeigen",
|
||||||
|
toggle_visible: "Verstecken",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user