💬 🐛 Fix regression add on move, improved texts

This commit is contained in:
Timur Ercan
2023-02-28 18:56:30 +01:00
parent 2f1d262b1b
commit fc93f80a8b
3 changed files with 13 additions and 4 deletions

View File

@ -26,6 +26,9 @@ export default function FieldTypeSelector(props: any) {
onChange={(e: any) => {
setSelectedFieldType(e);
}}
onMouseDown={() => {
props.setAdding(true);
}}
>
<div className="space-y-4">
{fieldTypes.map((fieldType) => (

View File

@ -20,6 +20,7 @@ export default function PDFEditor(props: any) {
const [selectedRecipient, setSelectedRecipient]: any = useState();
const [selectedFieldType, setSelectedFieldType] = useState();
const noRecipients = props?.document.Recipient.length === 0;
const [adding, setAdding] = useState(false);
function onPositionChangedHandler(position: any, id: any) {
if (!position) return;
@ -58,7 +59,11 @@ export default function PDFEditor(props: any) {
onMouseUp={(e: any, page: number) => {
e.preventDefault();
e.stopPropagation();
addField(e, page);
console.log(adding);
if (adding) {
addField(e, page);
setAdding(false);
}
}}
onMouseDown={(e: any, page: number) => {
addField(e, page);
@ -74,6 +79,7 @@ export default function PDFEditor(props: any) {
/>
<hr className="m-3 border-slate-300"></hr>
<FieldTypeSelector
setAdding={setAdding}
selectedRecipient={selectedRecipient}
onChange={setSelectedFieldType}
/>

View File

@ -19,9 +19,9 @@ export const createOrUpdateField = async (
return res.json();
}),
{
loading: "Adding...",
success: "Added.",
error: "Could not add :/",
loading: field?.id !== -1 ? "Saving..." : "Adding...",
success: field?.id !== -1 ? "Saved." : "Added.",
error: field?.id !== -1 ? "Could not save :/" : "Could not add :/",
},
{
id: "saving field",