feat: add departmentlist and userlist page

This commit is contained in:
prafull-opensignlabs
2024-06-27 19:00:55 +05:30
parent cc398d68e4
commit 2c715a77a2
14 changed files with 914 additions and 290 deletions
@@ -17,13 +17,13 @@ async function DocumentBeforesave(request) {
await contractUser.save(null, { useMasterKey: true });
} else {
// Create new entry if not found
const ContractsUsers = Parse.Object.extend('contracts_users');
const ContractsUsers = Parse.Object.extend('contracts_Users');
const newContractUser = new ContractsUsers();
newContractUser.set('DocumentCount', 1);
await newContractUser.save(null, { useMasterKey: true });
}
} catch (error) {
console.log('Error updating document count in contracts_users: ' + error.message);
console.log('Error updating document count in contracts_Users: ' + error.message);
}
if (document?.get('Signers') && document.get('Signers').length > 0) {
document.set('DocSentAt', new Date());
@@ -15,13 +15,13 @@ async function TemplateBeforeSave(request) {
await contractUser.save(null, { useMasterKey: true });
} else {
// Create new entry if not found
const ContractsUsers = Parse.Object.extend('contracts_users');
const ContractsUsers = Parse.Object.extend('contracts_Users');
const newContractUser = new ContractsUsers();
newContractUser.set('TemplateCount', 1);
await newContractUser.save(null, { useMasterKey: true });
}
} catch (error) {
console.log('Error updating template count in contracts_users: ' + error.message);
console.log('Error updating template count in contracts_Users: ' + error.message);
}
}
} catch (err) {
@@ -0,0 +1,26 @@
export default async function getUserByOrgId(req) {
const OrganizationId = req.params.organizationId;
const orgPtr = {
__type: 'Pointer',
className: 'contracts_Organizations',
objectId: OrganizationId,
};
if (!req?.user) {
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
} else {
try {
const extUser = new Parse.Query('contracts_Users');
extUser.equalTo('OrganizationId', orgPtr);
const userRes = await extUser.first({ useMasterKey: true });
if (userRes.length > 0) {
const _userRes = JSON.parse(JSON.stringify(userRes));
return _userRes;
} else {
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
}
} catch (err) {
console.log('err in getuserlist', err);
throw err;
}
}
}
@@ -0,0 +1,26 @@
export default async function getUserList(req) {
const OrganizationId = req.params.organizationId;
const orgPtr = {
__type: 'Pointer',
className: 'contracts_Organizations',
objectId: OrganizationId,
};
if (!req?.user) {
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
} else {
try {
const extUser = new Parse.Query('contracts_Users');
extUser.equalTo('OrganizationId', orgPtr);
const userRes = await extUser.find({ useMasterKey: true });
if (userRes.length > 0) {
const _userRes = JSON.parse(JSON.stringify(userRes));
return _userRes;
} else {
return [];
}
} catch (err) {
console.log('err in getuserlist', err);
throw err;
}
}
}
@@ -18,8 +18,7 @@ export default async function getapitoken(request) {
}
}
} catch (err) {
console.log('Err', err);
console.log('err', err);
console.log('Err in getapitoken', err);
if (err.code == 209) {
return { error: 'Invalid session token' };
} else {