- 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] ['documentType', type]
]); ]);
} }
}, []); }, [effectiveCompanyId, companies]);
const getCallback = (resp) => { const getCallback = (resp) => {
if (resp.status === 'SUCCESS') { if (resp.status === 'SUCCESS') {

View File

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

View File

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

View File

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

View File

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

View File

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