fix: change randomId generator

This commit is contained in:
prafull-opensignlabs
2024-03-07 13:20:26 +05:30
parent 9bda7dee7f
commit f57fcd25c9
3 changed files with 12 additions and 11 deletions
@@ -1,17 +1,12 @@
import React, { useState } from "react";
import { themeColor } from "../../constant/const";
import ModalUi from "../../primitives/ModalUi";
import { randomId } from "../../constant/Utils";
function PlaceholderCopy(props) {
const copyType = ["All pages", "All pages but last", "All pages but first"];
const [selectCopyType, setSelectCopyType] = useState("");
//get RandomKey Id
const randomKey = () => {
const randomId = Math.floor(1000 + Math.random() * 9000);
return randomId;
};
//function for get copy placeholder position
const getCopyPlaceholderPosition = (
type,
@@ -88,7 +83,7 @@ function PlaceholderCopy(props) {
);
for (let i = 0; i < props.allPages; i++) {
const newId = randomKey();
const newId = randomId();
currentPlaceholder.key = newId;
//get exist placeholder position for particular page
const existPlaceholder = filterSignerPosition[0].placeHolder.filter(
@@ -156,7 +151,7 @@ function PlaceholderCopy(props) {
const existPlaceholderPosition =
existPlaceholder[0] && existPlaceholder[0].pos;
const newId = randomKey();
const newId = randomId();
currentPlaceholder.key = newId;
//function for get copy to requested location of placeholder position
const getPlaceholderObj = getCopyPlaceholderPosition(
+6 -1
View File
@@ -479,7 +479,12 @@ export const signPdfFun = async (
return response;
};
export const randomId = () => Math.floor(1000 + Math.random() * 9000);
export const randomId = () => {
const randomBytes = crypto.getRandomValues(new Uint16Array(1));
const randomValue = randomBytes[0];
const randomDigit = 1000 + (randomValue % 9000);
return randomDigit;
};
export const createDocument = async (template, placeholders, signerData) => {
if (template && template.length > 0) {
+3 -2
View File
@@ -24,7 +24,8 @@ import {
onSaveImage,
onSaveSign,
contractUsers,
contactBook
contactBook,
randomId
} from "../constant/Utils";
import { useParams } from "react-router-dom";
import Tour from "reactour";
@@ -406,7 +407,7 @@ function SignYourSelf() {
};
//function for setting position after drop signature button over pdf
const addPositionOfSignature = (item, monitor) => {
const key = Math.floor(1000 + Math.random() * 9000);
const key = randomId();
let dropData = [];
let dropObj = {};
let filterDropPos = xyPostion.filter(