use webapp builder
This commit is contained in:
@@ -1,64 +1,48 @@
|
||||
import {useTranslations} from "next-intl";
|
||||
import {useEffect, useState} from "react";
|
||||
import {useRequest} from "@witel/webapp-builder";
|
||||
import TimelineManager from "@/core/components/timelines/timelineManager";
|
||||
import moment from "jalali-moment";
|
||||
import {Timeline} from "@mui/lab";
|
||||
import {LinearProgress} from "@mui/material";
|
||||
import {useConfig} from "@witel/webapp-builder";
|
||||
|
||||
const TimeLineDetails = () => {
|
||||
const t = useTranslations();
|
||||
const request = useRequest({notification: false, auth: false})
|
||||
const {config} = useConfig()
|
||||
const [timeLineList, setTimeLineList] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true)
|
||||
request(process.env.NEXT_PUBLIC_CONFIG_APP_URL, 'get').then(res => {
|
||||
let tempArr = []
|
||||
for (const timeLine of res.data.time_lines.navgan_first_page) {
|
||||
let temp = {}
|
||||
temp['label'] = timeLine.label
|
||||
temp['date'] = moment(timeLine.date.from, 'jYYYY/jMM/jDD').locale('fa').format('jD jMMMM')
|
||||
const fromDate = moment(timeLine.date.from, 'jYYYY/jMM/jDD')
|
||||
const toDate = moment(timeLine.date.to, 'jYYYY/jMM/jDD')
|
||||
const today = moment()
|
||||
if (today.isBetween(fromDate, toDate, null, '[]')) {
|
||||
temp['status'] = 'in progress'
|
||||
} else if (today.isAfter(toDate, null)) {
|
||||
temp['status'] = 'done'
|
||||
} else if (today.isBefore(fromDate, null)) {
|
||||
temp['status'] = 'open'
|
||||
}
|
||||
tempArr.push(temp)
|
||||
let tempArr = []
|
||||
for (const timeLine of config.time_lines.navgan_first_page) {
|
||||
let temp = {}
|
||||
temp['label'] = timeLine.label
|
||||
temp['date'] = moment(timeLine.date.from, 'jYYYY/jMM/jDD').locale('fa').format('jD jMMMM')
|
||||
const fromDate = moment(timeLine.date.from, 'jYYYY/jMM/jDD')
|
||||
const toDate = moment(timeLine.date.to, 'jYYYY/jMM/jDD')
|
||||
const today = moment()
|
||||
if (today.isBetween(fromDate, toDate, null, '[]')) {
|
||||
temp['status'] = 'in progress'
|
||||
} else if (today.isAfter(toDate, null)) {
|
||||
temp['status'] = 'done'
|
||||
} else if (today.isBefore(fromDate, null)) {
|
||||
temp['status'] = 'open'
|
||||
}
|
||||
setTimeLineList(tempArr)
|
||||
setLoading(false)
|
||||
}).catch(() => {
|
||||
setLoading(false)
|
||||
})
|
||||
tempArr.push(temp)
|
||||
}
|
||||
setTimeLineList(tempArr)
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{loading ? (
|
||||
<LinearProgress/>
|
||||
) : (
|
||||
<Timeline position="alternate">
|
||||
{timeLineList.map((timeLine, index) => (
|
||||
<TimelineManager
|
||||
key={index}
|
||||
status={timeLine.status}
|
||||
date={timeLine.date}
|
||||
primaryLabel={timeLine.label.primary}
|
||||
secondaryLabel={timeLine.label.secondary}
|
||||
position={index === (timeLineList.length - 1) ? 'end' : ''}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</Timeline>
|
||||
)}
|
||||
</>
|
||||
<Timeline position="alternate">
|
||||
{timeLineList.map((timeLine, index) => (
|
||||
<TimelineManager
|
||||
key={index}
|
||||
status={timeLine.status}
|
||||
date={timeLine.date}
|
||||
primaryLabel={timeLine.label.primary}
|
||||
secondaryLabel={timeLine.label.secondary}
|
||||
position={index === (timeLineList.length - 1) ? 'end' : ''}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</Timeline>
|
||||
)
|
||||
}
|
||||
export default TimeLineDetails
|
||||
Reference in New Issue
Block a user