- implemented uplaod company docs;

This commit is contained in:
Vitalii Kiiko
2026-03-30 14:58:48 +02:00
parent 41376794ad
commit f17b0edfa9
6 changed files with 53 additions and 160 deletions

View File

@@ -57,7 +57,7 @@ const DocumentsTable = ({ type, reload = 0, companyId: companyIdProp }) => {
['documentType', type]
]);
}
}, []);
}, [effectiveCompanyId, companies]);
const getCallback = (resp) => {
if (resp.status === 'SUCCESS') {

View File

@@ -1388,12 +1388,17 @@ const DomandaEditInstructorManager = () => {
setIsAdmissible(scoreSum >= maxScore);
}, [data]);
useEffect(() => {
const parsed = parseInt(id)
const refetchEvaluation = useCallback(() => {
const parsed = parseInt(id);
const entityId = !isNaN(parsed) ? parsed : 0;
storeSet('setAsyncRequest');
ApplicationEvaluationService.getEvaluationVersionByApplId(entityId, getVersion, errGetVersion);
}, [id]);
useEffect(() => {
refetchEvaluation();
const parsed = parseInt(id)
const entityId = !isNaN(parsed) ? parsed : 0;
AmendmentsService.getSoccorsoByApplId(entityId, getAmendmentsCallback, errGetAmendmentsCallback, [
['statuses', ['AWAITING', 'RESPONSE_RECEIVED']]
]);
@@ -1458,6 +1463,7 @@ const DomandaEditInstructorManager = () => {
})
))
})}
refetchFn={refetchEvaluation}
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
sourceId={data.id}
applicationId={data.applicationId}

View File

@@ -12,7 +12,6 @@ import getDateFromISOstring from '../../../../../../helpers/getDateFromISOstring
// api
import CompanyDocumentsService from '../../../../../../service/company-documents-service';
import ApplicationService from '../../../../../../service/application-service';
// components
import { FilterMatchMode, FilterOperator } from 'primereact/api';
@@ -25,7 +24,7 @@ import { Tag } from 'primereact/tag';
import { Toast } from 'primereact/toast';
import ProperBandoLabel from '../../../../../../components/ProperBandoLabel';
const CompanyDocsTable = ({ type, reload = 0, companyId: companyIdProp, applicationId }) => {
const CompanyDocsTable = ({ type, reload = 0, companyId: companyIdProp, applicationId, onImportSuccess = () => {} }) => {
const storedCompanyId = useStoreValue('chosenCompanyId');
const effectiveCompanyId = companyIdProp || storedCompanyId;
const companies = useStoreValue('companies');
@@ -145,9 +144,10 @@ const CompanyDocsTable = ({ type, reload = 0, companyId: companyIdProp, applicat
const handleImportDoc = (id) => {
setLoading(true);
ApplicationService.setApplicationDocuments(applicationId, importCallback, errImportCallback, [
['companyDocumentIds', [id]]
]);
CompanyDocumentsService.attachCompanyDocumentToAppl(id, importCallback, errImportCallback, [
['applicationId', applicationId],
['documentType', 'DOCUMENT']
])
};
const importCallback = (resp) => {
@@ -159,6 +159,9 @@ const CompanyDocsTable = ({ type, reload = 0, companyId: companyIdProp, applicat
detail: resp.message
});
}
if (resp.status === 'SUCCESS') {
onImportSuccess();
}
};
const errImportCallback = (resp) => {

View File

@@ -35,6 +35,8 @@ const EvaluationExtraFiles = ({
},
updateCallbackFn = () => {
},
refetchFn = () => {
},
defaultValue = [],
shouldDisable = false
}) => {
@@ -198,6 +200,7 @@ const EvaluationExtraFiles = ({
if (resp.status === 'SUCCESS') {
hideAddDocDialog();
setReloadHash(new Date().getTime());
refetchFn();
} else {
if (toast.current && resp.message) {
toast.current.show({
@@ -316,7 +319,12 @@ const EvaluationExtraFiles = ({
iconPos="right"
onClick={openAddDocDialog}/>
</div>
<CompanyDocsTable type="COMPANY_DOCUMENT" companyId={companyId} applicationId={applicationId} reload={reloadHash}/>
<CompanyDocsTable
type="COMPANY_DOCUMENT"
companyId={companyId}
applicationId={applicationId}
reload={reloadHash}
onImportSuccess={() => refetchFn()}/>
</Dialog>
<Dialog
visible={isVisibleAddDocDialog}

View File

@@ -1295,12 +1295,17 @@ const DomandaEditPreInstructor = () => {
setIsAdmissible(scoreSum >= maxScore);
}, [data]);
useEffect(() => {
const parsed = parseInt(id)
const refetchEvaluation = useCallback(() => {
const parsed = parseInt(id);
const entityId = !isNaN(parsed) ? parsed : 0;
storeSet('setAsyncRequest');
ApplicationEvaluationService.getEvaluationVersionByApplId(entityId, getVersion, errGetVersion);
}, [id]);
useEffect(() => {
refetchEvaluation();
const parsed = parseInt(id)
const entityId = !isNaN(parsed) ? parsed : 0;
AmendmentsService.getSoccorsoByApplId(entityId, getAmendmentsCallback, errGetAmendmentsCallback, [
['statuses', ['AWAITING', 'RESPONSE_RECEIVED', 'DRAFT']]
]);
@@ -1365,6 +1370,7 @@ const DomandaEditPreInstructor = () => {
})
))
})}
refetchFn={refetchEvaluation}
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
sourceId={data.id}
applicationId={data.applicationId}

View File

@@ -17,24 +17,7 @@ export class NetworkService {
}
static post = (url, body, callback, errorCallback, queryParams) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&') {
url = url.substring(0, url.length - 1);
}
}
url = this.buildUrl(url, queryParams);
fetch(url, {
method: 'POST',
@@ -62,23 +45,7 @@ export class NetworkService {
};
static postMultiPart = (url, body, callback, errorCallback, queryParams) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&')
url = url.substring(0, url.length - 1);
}
url = this.buildUrl(url, queryParams);
fetch(url, {
method: 'POST',
@@ -105,23 +72,7 @@ export class NetworkService {
};
static postBlob = (url, body, callback, errorCallback, queryParams) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&')
url = url.substring(0, url.length - 1);
}
url = this.buildUrl(url, queryParams);
fetch(url, {
method: 'POST',
@@ -173,22 +124,7 @@ export class NetworkService {
};
static unauthorizedPost = (url, body, callback, errorCallback, queryParams) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&')
url = url.substring(0, url.length - 1);
}
url = this.buildUrl(url, queryParams);
fetch(url, {
method: 'POST',
@@ -215,23 +151,7 @@ export class NetworkService {
};
static put = (url, body, callback, errorCallback, queryParams = null) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&')
url = url.substring(0, url.length - 1);
}
url = this.buildUrl(url, queryParams);
fetch(url, {
method: 'PUT',
@@ -259,23 +179,7 @@ export class NetworkService {
};
static putMultiPart = (url, body, callback, errorCallback, queryParams = null) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&')
url = url.substring(0, url.length - 1);
}
url = this.buildUrl(url, queryParams);
fetch(url, {
method: 'PUT',
@@ -305,24 +209,16 @@ export class NetworkService {
return value !== null && value !== undefined && value !== ''
}
static buildUrl(url, queryParams) {
if (!queryParams || !queryParams.length) return url;
const parts = queryParams
.filter(p => p && this.isNotBlank(p[0]) && this.isNotBlank(p[1]))
.map(p => encodeURIComponent(p[0]) + '=' + encodeURIComponent(p[1]));
return parts.length ? url + '?' + parts.join('&') : url;
}
static get = (url, callback, errorCallback, queryParams = null) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&')
url = url.substring(0, url.length - 1);
}
url = this.buildUrl(url, queryParams);
if (url.includes('user/me') && isEmpty(storeGet('getToken'))) {
return;
@@ -357,23 +253,7 @@ export class NetworkService {
};
static getBlob = (url, callback, errorCallback, queryParams) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&')
url = url.substring(0, url.length - 1);
}
url = this.buildUrl(url, queryParams);
fetch(url, {
method: 'GET',
@@ -400,18 +280,8 @@ export class NetworkService {
};
static delete = (url, body, callback, errorCallback, queryParams = null) => {
if (queryParams) {
let params = '?'
url = this.buildUrl(url, queryParams);
for (let i = 0; i < queryParams.length; i++) {
params += queryParams[i][0] + '=' + queryParams[i][1]
if (queryParams.length !== i + 1)
params += '&'
url += params
params = ''
}
}
fetch(url, {
method: 'DELETE',
mode: 'cors',