|
@@ -36,7 +36,8 @@ export default function ActivePlan() {
|
|
|
const [labels, setLabels] = useState<any>([])
|
|
const [labels, setLabels] = useState<any>([])
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
const health = useSelector((state: any) => state.health);
|
|
const health = useSelector((state: any) => state.health);
|
|
|
- const [list,setList] = useState<any>([])
|
|
|
|
|
|
|
+ const [list, setList] = useState<any>([])
|
|
|
|
|
+ const [loaded, setLoaded] = useState(false)
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
getLabelsEvent({ window: health.mode }).then(res => {
|
|
getLabelsEvent({ window: health.mode }).then(res => {
|
|
@@ -46,9 +47,10 @@ export default function ActivePlan() {
|
|
|
getDatas()
|
|
getDatas()
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
- function getDatas(){
|
|
|
|
|
|
|
+ function getDatas() {
|
|
|
getSchedules({ window: health.mode }).then(res => {
|
|
getSchedules({ window: health.mode }).then(res => {
|
|
|
setList((res as any).data)
|
|
setList((res as any).data)
|
|
|
|
|
+ setLoaded(true)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -56,14 +58,34 @@ export default function ActivePlan() {
|
|
|
setShowModal(true)
|
|
setShowModal(true)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!loaded) return <View />
|
|
|
|
|
+
|
|
|
return <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
|
|
return <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
|
|
|
<Text>Plan my daily life</Text>
|
|
<Text>Plan my daily life</Text>
|
|
|
<Text>Header: List top 3 activities that matter most to me/I want to practice to every day</Text>
|
|
<Text>Header: List top 3 activities that matter most to me/I want to practice to every day</Text>
|
|
|
- <View className="plan_item" onClick={tapEdit}>
|
|
|
|
|
- <Text>1</Text>
|
|
|
|
|
- <Text style={{ flex: 1 }}>{schedule.title}</Text>
|
|
|
|
|
- <Text style={{ color: getThemeColor('ACTIVE') }}>Tap to customize</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ list.length == 0 && <View className="plan_item" onClick={tapEdit}>
|
|
|
|
|
+ <Text>1</Text>
|
|
|
|
|
+ <Text style={{ flex: 1 }}>{schedule.title}</Text>
|
|
|
|
|
+ <Text style={{ color: getThemeColor('ACTIVE') }}>Tap to customize</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
|
|
+ {
|
|
|
|
|
+ list.map((item, index) => {
|
|
|
|
|
+ return <View className="plan_item" key={index}>
|
|
|
|
|
+ <Text>{1 + index}</Text>
|
|
|
|
|
+ <Text style={{ flex: 1 }}>{item.title}</Text>
|
|
|
|
|
+ <Text>{item.time ? item.time : item.time_label}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ {
|
|
|
|
|
+ list.length > 0 && list.length < 3 && <View className="plan_item" onClick={tapEdit}>
|
|
|
|
|
+ <Text style={{color: getThemeColor('ACTIVE')}}>+</Text>
|
|
|
|
|
+ <Text style={{ flex: 1,color: getThemeColor('ACTIVE') }}>Daily Activity</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
showModal && <Modal testInfo={null}
|
|
showModal && <Modal testInfo={null}
|
|
@@ -71,11 +93,10 @@ export default function ActivePlan() {
|
|
|
setShowModal(false)
|
|
setShowModal(false)
|
|
|
}}
|
|
}}
|
|
|
confirm={() => { }}>
|
|
confirm={() => { }}>
|
|
|
- <AddLabel labels={labels} defaultValue={schedule.title} disMiss={()=>{
|
|
|
|
|
|
|
+ <AddLabel labels={labels} defaultValue={list.length==0?schedule.title:''} disMiss={() => {
|
|
|
setShowModal(false)
|
|
setShowModal(false)
|
|
|
- // getDatas()
|
|
|
|
|
- Taro.navigateBack()
|
|
|
|
|
- }}/>
|
|
|
|
|
|
|
+ getDatas()
|
|
|
|
|
+ }} />
|
|
|
</Modal>
|
|
</Modal>
|
|
|
}
|
|
}
|
|
|
</View>
|
|
</View>
|