mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 19:21:39 +10:00
chore: clean
This commit is contained in:
@ -72,7 +72,6 @@ export const OrganisationEmailCreateDialog = ({
|
|||||||
const { mutateAsync: createOrganisationEmail, isPending } =
|
const { mutateAsync: createOrganisationEmail, isPending } =
|
||||||
trpc.enterprise.organisation.email.create.useMutation();
|
trpc.enterprise.organisation.email.create.useMutation();
|
||||||
|
|
||||||
// Reset state when dialog closes
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
form.reset();
|
form.reset();
|
||||||
|
|||||||
@ -171,9 +171,7 @@ export const SuggestedRecipientsForm = ({
|
|||||||
try {
|
try {
|
||||||
await onSubmit(normalizedRecipients);
|
await onSubmit(normalizedRecipients);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Log for debugging
|
|
||||||
console.error('Failed to submit recipients:', error);
|
console.error('Failed to submit recipients:', error);
|
||||||
// Form level errors are surfaced via toasts in the parent. Keep the dialog open.
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -194,9 +192,7 @@ export const SuggestedRecipientsForm = ({
|
|||||||
try {
|
try {
|
||||||
await onAutoAddFields(normalizedRecipients);
|
await onAutoAddFields(normalizedRecipients);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Log for debugging
|
|
||||||
console.error('Failed to auto-add fields:', error);
|
console.error('Failed to auto-add fields:', error);
|
||||||
// Form level errors are surfaced via toasts in the parent. Keep the dialog open.
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,6 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@documenso/ui/primitive
|
|||||||
import { useConfigureDocument } from './configure-document-context';
|
import { useConfigureDocument } from './configure-document-context';
|
||||||
import type { TConfigureEmbedFormSchema } from './configure-document-view.types';
|
import type { TConfigureEmbedFormSchema } from './configure-document-view.types';
|
||||||
|
|
||||||
// Define a type for signer items
|
|
||||||
type SignerItem = TConfigureEmbedFormSchema['signers'][number];
|
type SignerItem = TConfigureEmbedFormSchema['signers'][number];
|
||||||
|
|
||||||
export interface ConfigureDocumentRecipientsProps {
|
export interface ConfigureDocumentRecipientsProps {
|
||||||
@ -97,18 +96,15 @@ export const ConfigureDocumentRecipients = ({
|
|||||||
const currentSigners = getValues('signers') || [...signers];
|
const currentSigners = getValues('signers') || [...signers];
|
||||||
const signer = currentSigners[index];
|
const signer = currentSigners[index];
|
||||||
|
|
||||||
// Remove signer from current position and insert at new position
|
|
||||||
const remainingSigners = currentSigners.filter((_: unknown, idx: number) => idx !== index);
|
const remainingSigners = currentSigners.filter((_: unknown, idx: number) => idx !== index);
|
||||||
const newPosition = Math.min(Math.max(0, newOrder - 1), currentSigners.length - 1);
|
const newPosition = Math.min(Math.max(0, newOrder - 1), currentSigners.length - 1);
|
||||||
remainingSigners.splice(newPosition, 0, signer);
|
remainingSigners.splice(newPosition, 0, signer);
|
||||||
|
|
||||||
// Update signing order for each item
|
|
||||||
const updatedSigners = remainingSigners.map((s: SignerItem, idx: number) => ({
|
const updatedSigners = remainingSigners.map((s: SignerItem, idx: number) => ({
|
||||||
...s,
|
...s,
|
||||||
signingOrder: signingOrder === DocumentSigningOrder.SEQUENTIAL ? idx + 1 : undefined,
|
signingOrder: signingOrder === DocumentSigningOrder.SEQUENTIAL ? idx + 1 : undefined,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Update the form
|
|
||||||
replace(updatedSigners);
|
replace(updatedSigners);
|
||||||
},
|
},
|
||||||
[signers, replace, getValues],
|
[signers, replace, getValues],
|
||||||
@ -118,17 +114,14 @@ export const ConfigureDocumentRecipients = ({
|
|||||||
(result: DropResult) => {
|
(result: DropResult) => {
|
||||||
if (!result.destination) return;
|
if (!result.destination) return;
|
||||||
|
|
||||||
// Use the move function from useFieldArray which preserves input values
|
|
||||||
move(result.source.index, result.destination.index);
|
move(result.source.index, result.destination.index);
|
||||||
|
|
||||||
// Update signing orders after move
|
|
||||||
const currentSigners = getValues('signers');
|
const currentSigners = getValues('signers');
|
||||||
const updatedSigners = currentSigners.map((signer: SignerItem, index: number) => ({
|
const updatedSigners = currentSigners.map((signer: SignerItem, index: number) => ({
|
||||||
...signer,
|
...signer,
|
||||||
signingOrder: signingOrder === DocumentSigningOrder.SEQUENTIAL ? index + 1 : undefined,
|
signingOrder: signingOrder === DocumentSigningOrder.SEQUENTIAL ? index + 1 : undefined,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Update the form with new ordering
|
|
||||||
replace(updatedSigners);
|
replace(updatedSigners);
|
||||||
},
|
},
|
||||||
[move, replace, getValues],
|
[move, replace, getValues],
|
||||||
|
|||||||
@ -187,18 +187,12 @@ export default function EnvelopeEditorFieldsPageRenderer() {
|
|||||||
* Initialize the Konva page canvas and all fields and interactions.
|
* Initialize the Konva page canvas and all fields and interactions.
|
||||||
*/
|
*/
|
||||||
const createPageCanvas = (currentStage: Konva.Stage, currentPageLayer: Konva.Layer) => {
|
const createPageCanvas = (currentStage: Konva.Stage, currentPageLayer: Konva.Layer) => {
|
||||||
// Initialize snap guides layer
|
|
||||||
// snapGuideLayer.current = initializeSnapGuides(stage.current);
|
|
||||||
|
|
||||||
// Add transformer for resizing and rotating.
|
|
||||||
interactiveTransformer.current = createInteractiveTransformer(currentStage, currentPageLayer);
|
interactiveTransformer.current = createInteractiveTransformer(currentStage, currentPageLayer);
|
||||||
|
|
||||||
// Render the fields.
|
|
||||||
for (const field of localPageFields) {
|
for (const field of localPageFields) {
|
||||||
renderFieldOnLayer(field);
|
renderFieldOnLayer(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle stage click to deselect.
|
|
||||||
currentStage.on('mousedown', (e) => {
|
currentStage.on('mousedown', (e) => {
|
||||||
removePendingField();
|
removePendingField();
|
||||||
|
|
||||||
@ -292,7 +286,6 @@ export default function EnvelopeEditorFieldsPageRenderer() {
|
|||||||
let y2: number;
|
let y2: number;
|
||||||
|
|
||||||
currentStage.on('mousedown touchstart', (e) => {
|
currentStage.on('mousedown touchstart', (e) => {
|
||||||
// do nothing if we mousedown on any shape
|
|
||||||
if (e.target !== currentStage) {
|
if (e.target !== currentStage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -318,7 +311,6 @@ export default function EnvelopeEditorFieldsPageRenderer() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
currentStage.on('mousemove touchmove', () => {
|
currentStage.on('mousemove touchmove', () => {
|
||||||
// do nothing if we didn't start selection
|
|
||||||
if (!selectionRectangle.visible()) {
|
if (!selectionRectangle.visible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -343,7 +335,6 @@ export default function EnvelopeEditorFieldsPageRenderer() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
currentStage.on('mouseup touchend', () => {
|
currentStage.on('mouseup touchend', () => {
|
||||||
// do nothing if we didn't start selection
|
|
||||||
if (!selectionRectangle.visible()) {
|
if (!selectionRectangle.visible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -397,34 +388,25 @@ export default function EnvelopeEditorFieldsPageRenderer() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If empty area clicked, remove all selections
|
|
||||||
if (e.target === stage.current) {
|
if (e.target === stage.current) {
|
||||||
setSelectedFields([]);
|
setSelectedFields([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do nothing if field not clicked, or if field is not editable
|
|
||||||
if (!e.target.hasName('field-group') || e.target.draggable() === false) {
|
if (!e.target.hasName('field-group') || e.target.draggable() === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do we pressed shift or ctrl?
|
|
||||||
const metaPressed = e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey;
|
const metaPressed = e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey;
|
||||||
const isSelected = transformer.nodes().indexOf(e.target) >= 0;
|
const isSelected = transformer.nodes().indexOf(e.target) >= 0;
|
||||||
|
|
||||||
if (!metaPressed && !isSelected) {
|
if (!metaPressed && !isSelected) {
|
||||||
// if no key pressed and the node is not selected
|
|
||||||
// select just one
|
|
||||||
setSelectedFields([e.target]);
|
setSelectedFields([e.target]);
|
||||||
} else if (metaPressed && isSelected) {
|
} else if (metaPressed && isSelected) {
|
||||||
// if we pressed keys and node was selected
|
const nodes = transformer.nodes().slice();
|
||||||
// we need to remove it from selection:
|
|
||||||
const nodes = transformer.nodes().slice(); // use slice to have new copy of array
|
|
||||||
// remove node from array
|
|
||||||
nodes.splice(nodes.indexOf(e.target), 1);
|
nodes.splice(nodes.indexOf(e.target), 1);
|
||||||
setSelectedFields(nodes);
|
setSelectedFields(nodes);
|
||||||
} else if (metaPressed && !isSelected) {
|
} else if (metaPressed && !isSelected) {
|
||||||
// add the node into selection
|
|
||||||
const nodes = transformer.nodes().concat([e.target]);
|
const nodes = transformer.nodes().concat([e.target]);
|
||||||
setSelectedFields(nodes);
|
setSelectedFields(nodes);
|
||||||
}
|
}
|
||||||
@ -451,12 +433,10 @@ export default function EnvelopeEditorFieldsPageRenderer() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If it exists, rerender.
|
|
||||||
localPageFields.forEach((field) => {
|
localPageFields.forEach((field) => {
|
||||||
renderFieldOnLayer(field);
|
renderFieldOnLayer(field);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Rerender the transformer
|
|
||||||
interactiveTransformer.current?.forceUpdate();
|
interactiveTransformer.current?.forceUpdate();
|
||||||
|
|
||||||
pageLayer.current.batchDraw();
|
pageLayer.current.batchDraw();
|
||||||
|
|||||||
@ -173,7 +173,6 @@ export const EnvelopeEditorUploadPage = () => {
|
|||||||
fields: envelope.fields.filter((field) => field.envelopeItemId !== envelopeItemId),
|
fields: envelope.fields.filter((field) => field.envelopeItemId !== envelopeItemId),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset editor fields.
|
|
||||||
editorFields.resetForm(fieldsWithoutDeletedItem);
|
editorFields.resetForm(fieldsWithoutDeletedItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -120,13 +120,11 @@ export const EnvelopeDropZoneWrapper = ({
|
|||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show AI prompt dialog for documents
|
|
||||||
setUploadedDocumentId(id);
|
setUploadedDocumentId(id);
|
||||||
setPendingRecipients(null);
|
setPendingRecipients(null);
|
||||||
setShouldNavigateAfterPromptClose(true);
|
setShouldNavigateAfterPromptClose(true);
|
||||||
setShowExtractionPrompt(true);
|
setShowExtractionPrompt(true);
|
||||||
} else {
|
} else {
|
||||||
// Templates - navigate immediately
|
|
||||||
const pathPrefix = formatTemplatesPath(team.url);
|
const pathPrefix = formatTemplatesPath(team.url);
|
||||||
await navigate(`${pathPrefix}/${id}/edit`);
|
await navigate(`${pathPrefix}/${id}/edit`);
|
||||||
}
|
}
|
||||||
@ -175,7 +173,6 @@ export const EnvelopeDropZoneWrapper = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since users can only upload only one file (no multi-upload), we only handle the first file rejection
|
|
||||||
const { file, errors } = fileRejections[0];
|
const { file, errors } = fileRejections[0];
|
||||||
|
|
||||||
if (!errors.length) {
|
if (!errors.length) {
|
||||||
|
|||||||
@ -42,9 +42,6 @@ export type EnvelopeUploadButtonProps = {
|
|||||||
folderId?: string;
|
folderId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Upload an envelope
|
|
||||||
*/
|
|
||||||
export const EnvelopeUploadButton = ({ className, type, folderId }: EnvelopeUploadButtonProps) => {
|
export const EnvelopeUploadButton = ({ className, type, folderId }: EnvelopeUploadButtonProps) => {
|
||||||
const { t } = useLingui();
|
const { t } = useLingui();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|||||||
@ -163,7 +163,6 @@ const authorizeDocumentAccess = async (envelopeId: string, userId: number) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the first document data from the envelope
|
|
||||||
const documentData = envelope.envelopeItems[0]?.documentData;
|
const documentData = envelope.envelopeItems[0]?.documentData;
|
||||||
|
|
||||||
if (!documentData) {
|
if (!documentData) {
|
||||||
@ -193,7 +192,6 @@ export const aiRoute = new Hono<HonoEnv>()
|
|||||||
|
|
||||||
const { envelopeId } = parsed.data;
|
const { envelopeId } = parsed.data;
|
||||||
|
|
||||||
// Use shared authorization function
|
|
||||||
const documentData = await authorizeDocumentAccess(envelopeId, user.id);
|
const documentData = await authorizeDocumentAccess(envelopeId, user.id);
|
||||||
|
|
||||||
const envelopeRecipients = await prisma.recipient.findMany({
|
const envelopeRecipients = await prisma.recipient.findMany({
|
||||||
@ -410,7 +408,6 @@ export const aiRoute = new Hono<HonoEnv>()
|
|||||||
|
|
||||||
const { envelopeId } = parsed.data;
|
const { envelopeId } = parsed.data;
|
||||||
|
|
||||||
// Use shared authorization function
|
|
||||||
const documentData = await authorizeDocumentAccess(envelopeId, user.id);
|
const documentData = await authorizeDocumentAccess(envelopeId, user.id);
|
||||||
|
|
||||||
const pdfBytes = await getFileServerSide({
|
const pdfBytes = await getFileServerSide({
|
||||||
@ -420,7 +417,6 @@ export const aiRoute = new Hono<HonoEnv>()
|
|||||||
|
|
||||||
const renderedPages = await renderPdfToImage(pdfBytes);
|
const renderedPages = await renderPdfToImage(pdfBytes);
|
||||||
|
|
||||||
// Only analyze first few pages for performance
|
|
||||||
const pagesToAnalyze = renderedPages.slice(0, MAX_PAGES_FOR_RECIPIENT_ANALYSIS);
|
const pagesToAnalyze = renderedPages.slice(0, MAX_PAGES_FOR_RECIPIENT_ANALYSIS);
|
||||||
|
|
||||||
const results = await Promise.allSettled(
|
const results = await Promise.allSettled(
|
||||||
|
|||||||
Reference in New Issue
Block a user