박권수

feat. 차트 및 상세사항 변경

import moment from 'moment';
export const make = (chartData : any[], numberOfRow : number) => {
export const make = (takeMedicineHist : any[], numberOfRow : number) => {
const now = new Date();
const result : any = {};
new Array(numberOfRow).fill(null).forEach((item : any, index : number) => {
new Array(numberOfRow).fill(null).forEach(() => {
const key = moment(now).format('MM/DD');
result[key] = 0;
now.setDate(now.getDate() - 1);
})
});
chartData.forEach((data : any) => {
takeMedicineHist.forEach((data : any) => {
const key : string = moment(data.takeDate).format('MM/DD');
!isNaN(result[key]) ? result[key] = result[key] + 1 : null;
!isNaN(result[key]) ? result[key] = result[key] + data.dosage : null;
});
const categories : any = [];
......
......@@ -52,7 +52,7 @@ const BottleInfoContainer = (props : BottleInfoProps) => {
categories : [],
},
series : [{
name : '약 복용 횟수',
name : '약 복용 회분',
color : '#337DFF',
data : [],
}],
......@@ -75,7 +75,12 @@ const BottleInfoContainer = (props : BottleInfoProps) => {
try {
const result = await doctorApi.getPatientBottleDetail(token, bottleId);
if (result.statusText === 'OK') {
setTakeMedicineHist(result.data.takeMedicineHist);
setTakeMedicineHist(result.data.takeMedicineHist.map((takeMedicine : any) => {
return ({
...takeMedicine,
takeDate : moment(takeMedicine.takeDate).format('YYYY년 MM월 DD일 hh시 mm분'),
});
}));
const { categories, data } = makeChart.make(result.data.takeMedicineHist, numberOfChartItem);
setBottleInfo({
...result.data,
......
......@@ -72,6 +72,10 @@ const BottleInfoPresenter = (props : BottleInfoProps) => {
</styled.HistDtmWrapper>
<styled.HistInfoWrapper>
<styled.HistInfoEachWrapper>
복용량
<styled.HistInfoEach>{hist.dosage}회분</styled.HistInfoEach>
</styled.HistInfoEachWrapper>
<styled.HistInfoEachWrapper>
약병 내 온도
<styled.HistInfoEach>{hist.temperature}℃</styled.HistInfoEach>
</styled.HistInfoEachWrapper>
......@@ -79,10 +83,6 @@ const BottleInfoPresenter = (props : BottleInfoProps) => {
약병 내 습도
<styled.HistInfoEach>{hist.humidity}%</styled.HistInfoEach>
</styled.HistInfoEachWrapper>
<styled.HistInfoEachWrapper>
약병 내 잔량
<styled.HistInfoEach>{hist.balance}%</styled.HistInfoEach>
</styled.HistInfoEachWrapper>
</styled.HistInfoWrapper>
</styled.HistWrapper>
)
......
......@@ -72,7 +72,7 @@ export const HistDtmWrapper = styled.div `
`;
export const HistDtm = styled.div `
font-size : 18px;
font-size : 16px;
color : #000;
`;
......