From 9c499b53605c4c39501a26664d3cb83b1fb5c77f Mon Sep 17 00:00:00 2001 From: u6parum Date: Mon, 26 Oct 2020 01:50:40 +0300 Subject: [PATCH] VRTKS-200 Summary changes --- .../SummaryContainer/SummaryContainer.tsx | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/webparts/summaryWebPart/components/SummaryContainer/SummaryContainer.tsx b/src/webparts/summaryWebPart/components/SummaryContainer/SummaryContainer.tsx index 9d2209f..135334f 100644 --- a/src/webparts/summaryWebPart/components/SummaryContainer/SummaryContainer.tsx +++ b/src/webparts/summaryWebPart/components/SummaryContainer/SummaryContainer.tsx @@ -31,6 +31,39 @@ export default class SummaryContainer extends React.Component, prjGuid: string): + Promise> + { + const lastPublishedDateObj = { + key: 200000, + fieldName: 'Дата публикации основного КПП', + value: undefined + } + + const encodedUrl = encodeURI(`http://portal.vertex.spb.ru/pwa/_api/ProjectData/Проекты(guid'${prjGuid}')`) + + const response = await fetch(encodedUrl, + { headers: { + 'accept': 'application/json', + }}) + const json = await response.json() + + if (!json) { + console.error('addMainProjectPlanLastPublishedDate json is invalid =>', json) + return toState + } + + const date = json.ProjectLastPublishedDate + + if (!date) { + console.error('addMainProjectPlanLastPublishedDate json.ProjectLastPublishedDate is invalid =>', date) + return toState + } + + lastPublishedDateObj.value = new Date(date).toLocaleDateString() + return [ ...toState, lastPublishedDateObj ] + } + componentDidMount() { const { order, context } = this.props; let relUrl = context.pageContext.web.serverRelativeUrl; @@ -69,7 +102,7 @@ export default class SummaryContainer extends React.Component { + .then(async currentProject => { res.forEach(e=>{ @@ -89,6 +122,9 @@ export default class SummaryContainer extends React.Component