Browse Source

access check alert 多语言

leon 1 year ago
parent
commit
102c95efcb

BIN
src/assets/images/avatar_empty.png


BIN
src/assets/images/night_three_ring.png


BIN
src/assets/images/notice_switch_select.png


BIN
src/assets/images/notice_switch_unselect.png


BIN
src/assets/images/test.png


BIN
src/assets/images/tooltip_add_to_mine.png


+ 1 - 2
src/context/locales/en.js

@@ -153,8 +153,7 @@ export default {
         check_access: {
             non_access: {
                 title: 'Well Done',
-                one_day_desc: 'You\'re on a 1-day streak.\nTwo more days until unlocking \'Fasting with sleep.\'',
-                two_day_desc:'You\'re on a 2-day streak.\nOne more day until unlocking \'Fasting with sleep.\'',
+                desc: 'You\'re on a {{day}}-day streak.\n{{left_day}} more {{day_unit}} until unlocking \'Fasting with sleep.\'',
                 btn: 'Got it!'
             },
             gain_access:{

+ 78 - 0
src/context/locales/zh.js

@@ -112,6 +112,84 @@ export default {
             location_cancel:'返回',
             location_confirm:'去设置'
         },
+        choose_scenario: {
+            title: 'Choose Circadain Clock',
+            description: 'Circadian clock is key to your health. And your acts of fasting and sleep will affect your circadian health in powerful ways.',
+            fasting: 'Fasting',
+            fast_desc: 'Track overnight fasting in 2 steps.',
+            fast_sleep: 'Fasting with Sleep',
+            fast_sleep_desc: 'Track fasting before bed, during sleep, and after waking up.',
+            free: 'Free',
+            limit_time_offer: 'Limit-Time Offer',
+        },
+        suggest: {
+            step_0_title: 'Set End Time of Fasting',
+            end_fast_picker_header: 'What time do you want to break your fast and start your breakfast?',
+            end_fast_picker_footer: 'This is the time you may begin eating breakfast or your first meal of the day.',
+            step_1_title: 'Suggested Fasting Schedule',
+            fast_suggest_header: 'To benefit from overnight fasting and enjoy breakfast at {{time}}, start fasting at suggested time.',
+            start_fast_time: 'Start fasting at {{time}}',
+            intermitent_fast: '{{data}} Intermittent Fasting',
+            fast_desc: '{{start_time}} hours fasting, {{end_time}} hours eating',
+            step_2_title: 'Set Wake Time',
+            end_sleep_picker_header: 'What time do you want to wake up?',
+            fall_sleep_picker_header: 'How long does it take you to fall asleep?',
+            fall_sleep_picker_footer: 'It takes 10 to 30 minutes for most people to fall asleep once they\'re in bed.',
+            step_3_title: 'Suggested Sleep Schedule',
+            sleep_suggest_header: 'To wake up refreshed at {{time}}, go to bed at suggested time.',
+            cycles: '{{times}} sleep cycles',
+            go_to_bed_at: 'Go to bed at {{time}}',
+            restorative: 'Restorative',
+            suggest_plan: 'Suggest Plan',
+            set_myself: 'Set Schedule Myself',
+            popular: 'Popular',
+            recent: 'Recent',
+
+        },
+        set_goal: {
+            set_action_plan: 'Set Action Plan',
+            almost_done: 'Almost done!',
+            header: 'Review goal and action plan',
+            footer: 'Feel free to modify your shedule as needed.',
+        },
+
+        check_access: {
+            non_access: {
+                title: 'Well Done',
+                desc: 'You\'re on a {{day}}-day streak.\n{{left_day}} more days until unlocking \'Fasting with sleep.\'',
+                btn: 'Got it!'
+            },
+            gain_access:{
+                title:'Premium Access Unlocked',
+                desc:'You\'ve unlocked \'Fasting with Sleep\' since you\'re on a {{day}}-day streak.\nAre you ready to up the game?',
+                upgrade:'Upgrade to Fasting with Sleep',
+                upgrade_desc:'Offer Expiring in {{time}}',
+                stay_btn:'Stay with Fasting Only',
+                more:'Learn more'
+            },
+            upgrade_pro:{
+                title:'Congrats on Your PRO Status!',
+                desc:'To preserve this status, continue your fasting streak in {{time}} and begin your sleep streak. Remember to keep both of them going.',
+                btn:'I got this!'
+            },
+            sleep_schedule:{
+                title:'Sleep Schedule',
+                desc:'Your previous sleep schedule was {{start_time}} - {{end_time}}.\nDo you want to set a new schedule?',
+                confirm:'Set a new schedule',
+                cancel:'Keep old schedule'
+            },
+            stay_qualified:{
+                title:'Well Done',
+                desc:'You\'re on a {{fast_streak_day}}-day fasting streak and a {{sleep_streak_day}}-day sleep streak.\nKeep \'em going to stay in the game.',
+                btn:'Got it!',
+            },
+            lose_access:{
+                title:'Premium Access Lost',
+                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\nsince you lost your fasting streak. To regain access, become a PRO or achieve a new 3-day fasting streak.',
+                confirm:'Become a PRO member',
+                cancel:'Achieve New Fasting Streak'
+            },
+        },
         common: {
             prompt: '提示',
             action_sheet_cancel: '取消',

+ 23 - 9
src/features/auth/components/Login.tsx

@@ -37,28 +37,43 @@ export default function Login(props: { register: () => void }) {
 
     useEffect(() => {
         if (user.isLogin) {
+            //上报用户登录完成
+
 
             if (process.env.TARO_ENV == 'rn') {
                 navigation.pop(2)
                 return
             }
 
-            if (user.scenario_select_count > 0 || user.ongoing) {
+            if (user.is_new_user) {
                 Taro.navigateBack({
-                    delta: 2
+                    delta: 1
+                })
+                debugger
+                Taro.redirectTo({
+                    url: '/pages/clock/ChooseScenario?trigger_event=SETUP_UPON_ACCOUNT_CREATION'
                 })
-                console.log('login 2 navi back')
             }
             else {
-                console.log('login 1 navi back')
                 Taro.navigateBack({
-                    delta: 1
-                })
-                Taro.redirectTo({
-                    url: '/pages/clock/ChooseScenario'
+                    delta: 2
                 })
             }
 
+            // if (user.scenario_select_count > 0 || user.ongoing) {
+            //     Taro.navigateBack({
+            //         delta: 2
+            //     })
+            // }
+            // else {
+            //     Taro.navigateBack({
+            //         delta: 1
+            //     })
+            //     Taro.redirectTo({
+            //         url: '/pages/clock/ChooseScenario?trigger_event=SETUP_UPON_ACCOUNT_CREATION'
+            //     })
+            // }
+
         }
     }, [user.isLogin])
 
@@ -114,7 +129,6 @@ export default function Login(props: { register: () => void }) {
             })
             return
         }
-        debugger
 
         jumpPage('/pages/common/H5?title=User Agreement&url=' + resource[0].url, 'H5', navigation, {
             title: 'User Agreement',

+ 64 - 43
src/features/trackTimeDuration/components/CheckAccess.tsx

@@ -10,6 +10,7 @@ import { chooseMode, initTarget, updateStep } from "@/store/set_target";
 import { jumpPage } from "../hooks/Common";
 import { useDidShow } from "@tarojs/taro";
 import Taro from "@tarojs/taro";
+import { useTranslation } from "react-i18next";
 
 let confirmAction: any = null;
 let cancelAction: any = null;
@@ -32,6 +33,8 @@ export default function CheckAccess(props: { record: any, count: number }) {
     const [confirmText, setConfirmText] = useState('')
     const [subConfirmText, setSubConfirmText] = useState('')
 
+    const { t } = useTranslation()
+
     //判断选择混合场景,如果成功了,就弹窗
     const [checkChooseMixed, setCheckChooseMixed] = useState(false)
     const [chooseMixedSuccess, setChooseMixedSuccess] = useState(false)
@@ -54,11 +57,11 @@ export default function CheckAccess(props: { record: any, count: number }) {
             const currentStatus = obj.access.current.qualification.status
             const preStatus = obj.access.previous.qualification.status
             if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'NOT_QUALIFIED' && obj.current_record.status == 'WAIT_FOR_START') {
-                lose()
+                lose(obj.access.current.qualification.condition)
             }
-            else if (currentStatus == 'PROVISIONAL_QUALIFIED'){
+            else if (currentStatus == 'PROVISIONAL_QUALIFIED') {
                 Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
-                if (new Date().getTime() > obj.access.current.qualification.expire && obj.current_record.status == 'WAIT_FOR_START'){
+                if (new Date().getTime() > obj.access.current.qualification.expire && obj.current_record.status == 'WAIT_FOR_START') {
                     if (global.indexPageRefresh) {
                         global.indexPageRefresh()
                     }
@@ -115,17 +118,21 @@ export default function CheckAccess(props: { record: any, count: number }) {
             // setAccess(acccessData)
 
             if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
-                const { streak_fast_current } = acccessData.current.qualification.condition
+                const { streak_fast_current, streak_required } = acccessData.current.qualification.condition
                 if (streak_fast_current == 0) {
                     return;
                 }
                 setShowFastAlert(true)
                 setKeepContent(false)
-                setAlertTitle('Well Done')
-                setAlertContent(`You're on a ${streak_fast_current}-day streak.
-                    ${streak_fast_current == 1 ? 'Two more days' : 'One more day'} until unlocking 'Fasting with sleep.'`)
+                setAlertTitle(t('feature.check_access.non_access.title'))
+                setAlertContent(t('feature.check_access.non_access.desc',
+                    {
+                        day: streak_fast_current,
+                        left_day: streak_required - streak_fast_current,
+                        day_unit: streak_required - streak_fast_current == 1 ? 'day' : 'days'
+                    }))
                 setShowCancel(false)
-                setConfirmText('Got it!')
+                setConfirmText(t('feature.check_access.non_access.btn'))
             }
             else if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'PROVISIONAL_QUALIFIED') {
                 const { streak_fast_current } = acccessData.current.qualification.condition
@@ -134,12 +141,12 @@ export default function CheckAccess(props: { record: any, count: number }) {
                 const { expire } = acccessData.current.qualification
                 setShowFastAlert(true)
                 setKeepContent(false)
-                setAlertTitle('Premium Access Unlocked')
-                setAlertContent(`You've unlocked 'Fasting with Sleep' since you're on a ${streak_fast_current}-day streak.\nAre you ready to up the game?`)
+                setAlertTitle(t('feature.check_access.gain_access.title'))
+                setAlertContent(t('feature.check_access.gain_access.desc', { day: streak_fast_current }))
                 setShowCancel(true)
-                setCancelText('Stay with Fasting Only')
-                setConfirmText(`Upgrade to Fasting with Sleep`)
-                setSubConfirmText(`Offer Expiring in ${TimeFormatter.countdown(expire)}`)
+                setCancelText(t('feature.check_access.gain_access.stay_btn'))
+                setConfirmText(t('feature.check_access.gain_access.upgrade'))
+                setSubConfirmText(t('feature.check_access.gain_access.upgrade_desc', { time: TimeFormatter.countdown(expire) }))
 
                 confirmAction = upgrade
                 timer = setInterval(() => {
@@ -157,13 +164,12 @@ export default function CheckAccess(props: { record: any, count: number }) {
                     const { expire } = acccessData.current.qualification
                     setShowFastAlert(true)
                     setKeepContent(false)
-                    setAlertTitle('Premium Access Unlocked')
-                    setAlertContent(`You've unlocked 'Fasting with Sleep' since you're on a ${streak_fast_current}-day streak.
-                    \nAre you ready to up the game?`)
+                    setAlertTitle(t('feature.check_access.gain_access.title'))
+                    setAlertContent(t('feature.check_access.gain_access.desc', { day: streak_fast_current }))
                     setShowCancel(true)
-                    setConfirmText(`Upgrade to Fasting with Sleep`)
-                    setSubConfirmText(`Offer Expiring in ${TimeFormatter.countdown(expire)}`)
-                    setCancelText('Stay with Fasting Only')
+                    setCancelText(t('feature.check_access.gain_access.stay_btn'))
+                    setConfirmText(t('feature.check_access.gain_access.upgrade'))
+                    setSubConfirmText(t('feature.check_access.gain_access.upgrade_desc', { time: TimeFormatter.countdown(expire) }))
                     confirmAction = upgrade
                     timer = setInterval(() => {
                         if (new Date().getTime() > expire) {
@@ -177,14 +183,14 @@ export default function CheckAccess(props: { record: any, count: number }) {
                 }
 
                 setShowFastAlert(true)
-                setAlertTitle('Well Done')
-                setAlertContent(`You're on a ${streak_fast_current}-day fasting streak${streak_sleep_current > 0 ? ' and a ' + streak_sleep_current + '-day sleep streak' : ''}.\nKeep 'em going to stay in the game.`)
+                setAlertTitle(t('feature.check_access.stay_qualified.title'))
+                setAlertContent(t('feature.check_access.stay_qualified.title', { fast_streak_day: streak_fast_current, sleep_streak_day: streak_sleep_current }))
                 setShowCancel(false)
-                setConfirmText('Got it!')
+                setConfirmText(t('feature.check_access.stay_qualified.btn'))
             }
             else if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
                 debugger
-                lose();
+                lose(acccessData.current.qualification);
                 // setShowFastAlert(true)
                 // setAlertTitle('Premium Access Lost')
                 // setAlertContent(`You've lost premium access to the 'Fasting with Sleep' feature
@@ -200,32 +206,41 @@ export default function CheckAccess(props: { record: any, count: number }) {
         const { expire } = access.current.qualification
         setShowFastAlert(true)
         setKeepContent(false)
-        setAlertTitle('Congrats on Your PRO Status!')
-        setAlertContent(`To preserve this status, continue your fasting streak in ${TimeFormatter.countdown(expire)} and begin your sleep streak. Remember to keep both of them going.`)
+        setAlertTitle(t('feature.check_access.upgrade_pro.title'))
+        setAlertContent(t('feature.check_access.upgrade_pro.desc', { time: TimeFormatter.countdown(expire) }))
         setShowCancel(false)
-        setConfirmText(`I got this!`)
+        setConfirmText(t('feature.check_access.upgrade_pro.btn'))
         setSubConfirmText('')
         timer = setInterval(() => {
 
             if (new Date().getTime() > expire) {
-                debugger
                 cancel()
                 return
             }
-            setAlertContent(`To preserve this status, continue your fasting streak in ${TimeFormatter.countdown(expire)} and begin your sleep streak. Remember to keep both of them going.`)
+            setAlertContent(t('feature.check_access.upgrade_pro.desc', { time: TimeFormatter.countdown(expire) }))
         }, 1000)
     }
 
-    async function lose() {
-        var showDayRing = await getStorage('showedDisqualifiedAlert') || false;
-        if (showDayRing) {
+    async function lose(condition) {
+        var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
+        if (showedDisqualifiedAlert) {
             return;
         }
+
+        var type = ''
+        if (condition.streak_fast_current == 0 && condition.streak_sleep_current == 0) {
+            type = 'fasting and sleep'
+        }
+        else if (condition.streak_fast_current == 0) {
+            type = 'fasting'
+        }
+        else if (condition.streak_sleep_current == 0) {
+            type = 'sleep'
+        }
         setShowFastAlert(true)
         setKeepContent(false)
-        setAlertTitle('Premium Access Lost')
-        setAlertContent(`You've lost premium access to the 'Fasting with Sleep' feature
-                since you lost your fasting streak. To regain access, become a PRO or achieve a new 3-day fasting streak.`)
+        setAlertTitle(t('feature.check_access.lose_access.title'))
+        setAlertContent(t('feature.check_access.lose_access.desc', { type: type }))
         setShowCancel(true)
         setCancelText('Achieve New Fasting Streak')
         setConfirmText('Become a PRO member')
@@ -239,6 +254,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
         const { start_time, end_time } = global.ring.schedule.fast
         var params: any = {
             scenario: 'FAST',
+            trigger: 'POPUP_DISQUALIFIED_DISMISS',
             schedule: {
                 fast: {
                     start_time: start_time,
@@ -267,12 +283,12 @@ export default function CheckAccess(props: { record: any, count: number }) {
         if (prev_input && valid) {
             setShowFastAlert(true)
             setKeepContent(true)
-            setAlertTitle('Update Sleep Schedule')
-            setAlertContent(`Your sleep schedule was ${start_time} - ${end_time}.
-            Do you want to update to a new schedule?`)
+            setAlertTitle(t('feature.check_access.sleep_schedule.title'))
+            setAlertContent(t('feature.check_access.sleep_schedule.desc',
+                { start_time: start_time, end_time: end_time }))
             setShowCancel(true)
-            setCancelText('Keep old schedule')
-            setConfirmText('Update new shedule')
+            setCancelText(t('feature.check_access.sleep_schedule.cancel'))
+            setConfirmText(t('feature.check_access.sleep_schedule.confirm'))
             setSubConfirmText('')
             setTimeout(() => {
                 cancelAction = cancelSetting
@@ -299,7 +315,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
     }
 
     function goSetting() {
-        
+
         getPlans().then(res => {
             const data = res as { scenarios: any[] };
             console.log(data)
@@ -320,7 +336,12 @@ export default function CheckAccess(props: { record: any, count: number }) {
             dispatch(updateStep({ step: 2 }))
             dispatch(chooseMode({ isMixed: true }))
             setCheckChooseMixed(true)
-            jumpPage(`/pages/clock/SetGoal?upgrade=true&isSelf=1`, 'SetGoal', navigation, {})
+            jumpPage(`/pages/clock/SetGoal?upgrade=true&isSelf=1&trigger_event=POPUP_QUALIFIED_UPGRADED_SET`, 'SetGoal', navigation, {
+                upgrade: true,
+                isSelf: 1,
+                trigger_event: 'POPUP_QUALIFIED_UPGRADED_SET'
+
+            })
             confirmAction = goSetting
         })
 
@@ -330,7 +351,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
         const { start_time, end_time } = global.ring.schedule.fast
         var params: any = {
             scenario: 'FAST_SLEEP',
-            trigger_event:'PROVISIONAL_UPGRADE_KEEP',
+            trigger_event: 'POPUP_QUALIFIED_UPGRADED_DISMISS',
             schedule: {
                 fast: {
                     start_time: start_time,
@@ -353,7 +374,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
     function confirm() {
         if (!keepContent) {
             setShowFastAlert(false)
-            
+
         }
 
         if (timer) {

+ 13 - 5
src/features/trackTimeDuration/components/ClockHeader.tsx

@@ -93,7 +93,9 @@ export default function ClockHeader(props: { homeData: any }) {
                             })
                             return;
                         }
-                        jumpPage('/pages/clock/ChooseScenario', 'ChooseScenario', navigation)
+                        jumpPage('/pages/clock/ChooseScenario?trigger_event=SETUP_AFTER_ACCOUNT_CREATION', 'ChooseScenario', navigation, {
+                            trigger_event: 'SETUP_AFTER_ACCOUNT_CREATION'
+                        })
                         break;
                     case 1:
                         if (time.status != 'WAIT_FOR_START') {
@@ -120,8 +122,10 @@ export default function ClockHeader(props: { homeData: any }) {
                             })
                             dispatch(initTarget(targets))
                             dispatch(updateStep({ step: 0 }))
-                            dispatch(chooseMode({ isMixed: ring.current_record.scenario=='FAST_SLEEP' }))
-                            jumpPage(`/pages/clock/Suggest`, 'Suggest', navigation, {})
+                            dispatch(chooseMode({ isMixed: ring.current_record.scenario == 'FAST_SLEEP' }))
+                            jumpPage(`/pages/clock/Suggest?trigger_event=SETUP_AFTER_ACCOUNT_CREATION`, 'Suggest', navigation, {
+                                trigger_event: 'SETUP_AFTER_ACCOUNT_CREATION'
+                            })
                         })
 
                         break;
@@ -150,8 +154,12 @@ export default function ClockHeader(props: { homeData: any }) {
                             })
                             dispatch(initTarget(targets))
                             dispatch(updateStep({ step: 2 }))
-                            dispatch(chooseMode({ isMixed: ring.current_record.scenario=='FAST_SLEEP' }))
-                            jumpPage(`/pages/clock/SetGoal?upgrade=true&isSelf=1`, 'SetGoal', navigation, {})
+                            dispatch(chooseMode({ isMixed: ring.current_record.scenario == 'FAST_SLEEP' }))
+                            jumpPage(`/pages/clock/SetGoal?upgrade=true&isSelf=1&trigger_event=SETUP_AFTER_ACCOUNT_CREATION`, 'SetGoal', navigation, {
+                                trigger_event: 'SETUP_AFTER_ACCOUNT_CREATION',
+                                upgrade: true,
+                                isSelf: 1
+                            })
                         })
                         break;
                 }

+ 5 - 5
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -314,12 +314,12 @@ export default function Component(props: { type: string, data: any, time: any, s
             durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
         }
 
-        if (dayNight.nightRingDate) {
-            if (new Date(dayNight.nightRingDate).getDate() == new Date().getDate() && new Date().getHours() < 12) {
+        // if (dayNight.nightRingDate) {
+        //     if (new Date(dayNight.nightRingDate).getDate() == new Date().getDate() && new Date().getHours() < 12) {
 
-                realRing = null;
-            }
-        }
+        //         realRing = null;
+        //     }
+        // }
 
         if (!user.isLogin) {
             currentDot = null;

+ 1 - 0
src/features/trackTimeDuration/components/More.tsx

@@ -59,6 +59,7 @@ const Component = forwardRef((props, ref) => {
                         })
                         break;
                     case 1:
+                        debugger
                         Taro.navigateTo({
                             url: '/pages/clock/ChooseScenario'
                         })

+ 1 - 1
src/features/trackTimeDuration/components/Streaks.tsx

@@ -66,7 +66,7 @@ export default function Streaks(props: { count: number }) {
     function getDatas() {
         setIsLoading(true)
         var a = dayjs().format('YYYYMMDD')
-        getStreaks({ date: a }).then(res => {
+        getStreaks({ date: a,mode:'by_end_date' }).then(res => {
             console.log('streak', res)
             if (res) {
                 setFastStreaks((res as any).fast)

+ 1 - 0
src/features/trackTimeDuration/components/TitleView.tsx

@@ -81,6 +81,7 @@ export default function Component(props: {
                         })
                         return;
                     }
+                    debugger
                     jumpPage('/pages/clock/ChooseScenario', 'ChooseScenario', navigation)
                     break;
             }

+ 3 - 4
src/pages/account/ChooseAuth.tsx

@@ -38,7 +38,7 @@ export default function Page() {
                 if (user.scenario_select_count == 0) {
                     console.log('new')
                     Taro.redirectTo({
-                        url: '/pages/clock/ChooseScenario'
+                        url: '/pages/clock/ChooseScenario?trigger_event=SETUP_UPON_ACCOUNT_CREATION'
                     })
                     setTimeout(() => {
                         Taro.navigateTo({
@@ -118,13 +118,12 @@ export default function Page() {
                     })
                 }
                 else {
+                    debugger
                     Taro.redirectTo({
-                        url: '/pages/clock/ChooseScenario'
+                        url: '/pages/clock/ChooseScenario?trigger_event=SETUP_UPON_ACCOUNT_CREATION'
                     })
                 }
             }
-            
-            debugger
         }).catch(e => {
             setBtnDisable(false)
         })

+ 18 - 1
src/pages/account/Setting.tsx

@@ -42,8 +42,18 @@ export default function Page() {
             hasCache = true;
         })
     }, [])
-    function logoutF() {
 
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
+    async function logoutF() {
+        var showDayRing = await getStorage('showedDisqualifiedAlert') || false;
         showAlert({
             title: t('feature.common.modal.logout_title'),
             content: t('feature.common.modal.logout_content'),
@@ -58,6 +68,13 @@ export default function Page() {
                             data: true
                         })
                     }
+
+                    if (showDayRing) {
+                        Taro.setStorage({
+                            key: 'showedDisqualifiedAlert',
+                            data: true
+                        })
+                    }
                     
                     if (process.env.TARO_ENV == 'weapp') {
                         Taro.switchTab({

+ 22 - 11
src/pages/clock/ChooseScenario.tsx

@@ -7,22 +7,32 @@ import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import { getPlans } from "@/services/trackTimeDuration";
 import { chooseMode, initTarget, updateStep } from "@/store/set_target";
 import { useDispatch, useSelector } from "react-redux";
-import { useDidShow } from "@tarojs/taro";
+import { useDidShow, useRouter } from "@tarojs/taro";
 import { TimeFormatter } from "@/utils/time_format";
 import Footer from "@/components/layout/Footer";
 import Taro from "@tarojs/taro";
 import { rpxToPx, vibrate } from "@/utils/tools";
 import { IconCheck } from "@/components/basic/Icons";
 import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
+import { useTranslation } from "react-i18next";
 
 export default function ChooseScenario() {
     const [selected, setSelected] = useState(0);
     const ring = useSelector((state: any) => state.ring);
+    const {t} = useTranslation();
     const dispatch = useDispatch();
     var navigation: any = null
+
+    let router
+    var navigation: any = null
     if (process.env.TARO_ENV === 'rn') {
         var useNavigation = require("@react-navigation/native").useNavigation
         navigation = useNavigation()
+        const useRoute = require("@react-navigation/native").useRoute
+        router = useRoute()
+    }
+    else {
+        router = useRouter()
     }
 
     useEffect(() => {
@@ -55,7 +65,9 @@ export default function ChooseScenario() {
 
     function goSuggestion() {
         dispatch(updateStep({ step: 0 }))
-        jumpPage(`/pages/clock/Suggest`, 'Suggest', navigation, {})
+        jumpPage(`/pages/clock/Suggest?trigger_event=`+router.params.trigger_event, 'Suggest', navigation, {
+            trigger_event:router.params.trigger_event
+        })
     }
 
     function chooseType(index: number) {
@@ -70,7 +82,6 @@ export default function ChooseScenario() {
         //     return;
         // }
         setSelected(index)
-
         dispatch(chooseMode({ isMixed: index == 1 }))
     }
 
@@ -125,23 +136,23 @@ export default function ChooseScenario() {
     return <View style={{
         color: '#fff', flexDirection: 'column', display: 'flex'
     }}>
-        <Text className="target_title">Choose Circadain Clock</Text>
-        <Text className="target_desc">Circadian clock is key to your health. And your acts of fasting and sleep will affect your circadian health in powerful ways.</Text>
+        <Text className="target_title">{t('feature.choose_scenario.title')}</Text>
+        <Text className="target_desc">{t('feature.choose_scenario.description')}</Text>
 
         <View className={selected == 0 ? 'item1 item_sel1' : 'item1'} onClick={() => chooseType(0)}>
             <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
                 <Rings2 common={common} bgRing={bgRing} targetRing={selected==0?targetRing:null} canvasId={new Date().getTime()} />
             </View>
             <View style={{ display: 'flex', flexDirection: 'column' }}>
-                <Text className="choose_item_title">Fasting</Text>
-                <Text className="choose_item_desc">Track overnight fasting in 2 steps.</Text>
+                <Text className="choose_item_title">{t('feature.choose_scenario.fasting')}</Text>
+                <Text className="choose_item_desc">{t('feature.choose_scenario.fast_desc')}</Text>
                 {
                     selected == 0 && <View className="choose_item_check_bg">
                         <IconCheck color={ColorType.fast} width={38} height={26} />
                     </View>
                 }
 
-                <View className="choose_corner_tag">Free</View>
+                <View className="choose_corner_tag">{t('feature.choose_scenario.free')}</View>
 
 
             </View>
@@ -154,14 +165,14 @@ export default function ChooseScenario() {
                 </View>
             </View>
             <View style={{ display: 'flex', flexDirection: 'column' }}>
-                <Text className="choose_item_title">Fasting with Sleep</Text>
-                <Text className="choose_item_desc">Track fasting before bed, during sleep, and after waking up.</Text>
+                <Text className="choose_item_title">{t('feature.choose_scenario.fast_sleep')}</Text>
+                <Text className="choose_item_desc">{t('feature.choose_scenario.fast_sleep_desc')}</Text>
                 {
                     selected == 1 && <View className="choose_item_check_bg">
                         <IconCheck color={ColorType.fast} width={38} height={26} />
                     </View>
                 }
-                <View className="choose_corner_tag">Limit-Time Offer</View>
+                <View className="choose_corner_tag">{t('feature.choose_scenario.limit_time_offer')}</View>
             </View>
         </View>
         <View style={{ flex: 1 }} />

+ 5 - 5
src/pages/clock/SetGoal.tsx

@@ -193,10 +193,10 @@ export default function SetGoal() {
         }
 
         if (router.params.upgrade) {
-            params.trigger_event = 'PROVISIONAL_UPGRADE_SET'
+            params.trigger_event = router.params.trigger_event
         }
         else {
-            params.trigger_event = 'SET'
+            params.trigger_event = router.params.trigger_event?router.params.trigger_event:'SET'
         }
 
         setPlan(params).then(res => {
@@ -305,9 +305,9 @@ export default function SetGoal() {
     }
 
     return <View style={{ display: 'flex', flexDirection: 'column' }}>
-        <Text className="target_title">{isSelf ? 'Set Action Plan' : 'Almost Done!'}</Text>
+        <Text className="target_title">{isSelf ? t('feature.set_goal.set_action_plan') : t('feature.set_goal.almost_done')}</Text>
         {
-            !isSelf && <Text className="target_desc">Review goal and action plan</Text>
+            !isSelf && <Text className="target_desc">{t('feature.set_goal.header')}</Text>
         }
 
         <View style={{ color: '#fff' }}>
@@ -386,7 +386,7 @@ export default function SetGoal() {
                 </View>
             </View>
 
-            <Text className="cell_footer">Feel free to modify your shedule as needed.</Text>
+            <Text className="cell_footer">{t('feature.set_goal.footer')}</Text>
         </View>
 
         <View style={{ flex: 1 }} />

+ 41 - 33
src/pages/clock/Suggest.tsx

@@ -13,6 +13,7 @@ import { TimeFormatter } from "@/utils/time_format";
 import Footer from "@/components/layout/Footer";
 import { IconCheck } from "@/components/basic/Icons";
 import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
+import { useTranslation } from "react-i18next";
 
 export default function Suggest() {
     let router: any = null
@@ -37,6 +38,7 @@ export default function Suggest() {
     const [scrollTop, setScrollTop] = useState(0)
     const [fastRecommendIndex, setFastRecommendIndex] = useState(-1)
     const [fastLastIndex, setFastLastIndex] = useState(-1)
+    const { t } = useTranslation()
 
 
     useEffect(() => {
@@ -171,40 +173,43 @@ export default function Suggest() {
         var step: number = target.step + 1
         dispatch(updateStep({ step: step }))
 
-        var url = '/pages/clock/Suggest'
+        var url = '/pages/clock/Suggest?trigger_event=' + router.params.trigger_event
         var pageName = 'Suggest'
         if (!target.isMixed) {
             if (step == 2) {
-                url = '/pages/clock/SetGoal'
+                url = '/pages/clock/SetGoal?trigger_event=' + router.params.trigger_event
                 pageName = 'SetGoal'
             }
         }
         else {
             if (step == 4) {
-                url = '/pages/clock/SetGoal'
+                url = '/pages/clock/SetGoal?trigger_event=' + router.params.trigger_event
                 pageName = 'SetGoal'
             }
         }
 
-        jumpPage(url, pageName, navigation, {})
+        jumpPage(url, pageName, navigation, {
+            trigger_event: router.params.trigger_event
+        })
     }
 
     function myself() {
-        jumpPage(`/pages/clock/SetGoal?isSelf=1`, 'SetGoal', navigation, {
-            isSelf: 1
+        jumpPage(`/pages/clock/SetGoal?isSelf=1&trigger_event=` + router.params.trigger_event, 'SetGoal', navigation, {
+            isSelf: 1,
+            trigger_event: router.params.trigger_event
         })
     }
 
     function suggestTitle() {
         switch (pageStep) {
             case 0:
-                return 'Set End Time of Fasting'
+                return t('feature.suggest.step_0_title')
             case 1:
-                return 'Suggested Fasting Schedule'
+                return t('feature.suggest.step_1_title')
             case 2:
-                return 'Set Wake Time'
+                return t('feature.suggest.step_2_title')
             case 3:
-                return 'Suggested Sleep Schedule'
+                return t('feature.suggest.step_3_title')
             default:
                 return ''
         }
@@ -213,13 +218,13 @@ export default function Suggest() {
     function suggestDesc() {
         switch (pageStep) {
             case 0:
-                return 'What time do you want to break your fast and start your breakfast?'
+                return t('feature.suggest.end_fast_picker_header')
             case 1:
-                return 'To benefit from overnight fasting and enjoy breakfast at ' + target.fast.schedule.fast.end_time + ', start fasting at suggested time.'
+                return t('feature.suggest.fast_suggest_header', { time: target.fast.schedule.fast.end_time })
             case 2:
-                return 'What time do you want to wake up?'
+                return t('feature.suggest.end_sleep_picker_header')
             case 3:
-                return 'To wake up refreshed at ' + target.sleep.schedule.sleep.end_time + ', go to bed at suggested time.'
+                return t('feature.suggest.sleep_suggest_header', { time: target.sleep.schedule.sleep.end_time })
             default:
                 return ''
         }
@@ -340,7 +345,7 @@ export default function Suggest() {
 
             </View>
             {
-                pageStep == 0 && <Text className="suggest_footer_note">This is the time you may begin eating breakfast or your first meal of the day.</Text>
+                pageStep == 0 && <Text className="suggest_footer_note">{t('feature.suggest.end_fast_picker_footer')}</Text>
             }
             {
                 pageStep == 1 && <Text className="suggest_footer_note">If you plan to skip breakfast, pick a time for your first meal of the day.</Text>
@@ -358,7 +363,7 @@ export default function Suggest() {
 
     function fallSleepPicker() {
         return <View>
-            <View className="target_desc">How long does it take you to fall asleep?</View>
+            <View className="target_desc">{t('feature.suggest.fall_sleep_picker_header')}</View>
             <View style={{ marginLeft: rpxToPx(46), marginRight: rpxToPx(46), borderRadius: rpxToPx(20), overflow: 'hidden' }}>
                 <PickerViews ref={null}
                     onChange={fallSleepChanged}
@@ -371,7 +376,7 @@ export default function Suggest() {
                     onCancel={() => { }} />
 
             </View>
-            <Text className="suggest_footer_note">It takes 10 to 30 minutes for most people to fall asleep once they're in bed.</Text>
+            <Text className="suggest_footer_note">{t('feature.suggest.fall_sleep_picker_footer')}</Text>
         </View>
     }
 
@@ -465,24 +470,27 @@ export default function Suggest() {
                                         <View className="suggest_item_title">{item.hours} hours</View>
                                         <View style={{ flex: 1 }} />
                                         <View className='suggest_fast_tag_bg'>
-                                        {
-                                            index == fastRecommendIndex &&
-                                            <View className='suggest_fast_tag'>Popular</View>
-                                        }
-                                        {
-                                            index == fastLastIndex &&
-                                            <View className='suggest_fast_tag'>Recent</View>
-                                        }
+                                            {
+                                                index == fastRecommendIndex &&
+                                                <View className='suggest_fast_tag'>{t('feature.suggest.popular')}</View>
+                                            }
+                                            {
+                                                index == fastLastIndex &&
+                                                <View className='suggest_fast_tag'>{t('feature.suggest.recent')}</View>
+                                            }
                                         </View>
-                                        
-                                        
+
+
                                     </View>
 
-                                    <View className="suggest_item_desc">{index == suggestIndex ? `${item.hours} hours fasting / ${item.left} hours eating` : `${item.hours}/${item.left} Intermittent Fasting`}</View>
+                                    <View className="suggest_item_desc">{index == suggestIndex ?
+                                        t('feature.suggest.fast_desc', { start_time: item.hours, end_time: item.left }) :
+                                        t('feature.suggest.intermitent_fast', { data: `${item.hours}/${item.left}` })
+                                    }</View>
                                     {
                                         index == suggestIndex &&
                                         <View className="suggest_choose">
-                                            <View style={{ color: ColorType.fast }}>Start fasting at  {item.time}</View>
+                                            <View style={{ color: ColorType.fast }}>{t('feature.suggest.start_fast_time', { time: item.time })}</View>
                                             <IconCheck color={ColorType.fast} width={38} height={26} />
                                         </View>
                                     }
@@ -536,17 +544,17 @@ export default function Suggest() {
                             <View className="suggest_item_desc">{item.number} sleep cycles</View>
                             {
                                 index == suggestIndex && <View className="suggest_choose">
-                                    <View style={{ color: ColorType.sleep }}>Go to bed at {item.time}</View>
+                                    <View style={{ color: ColorType.sleep }}>{t('feature.suggest.go_to_bed_at', { time: item.time })}</View>
                                     <IconCheck color={ColorType.sleep} width={38} height={26} />
                                 </View>
                             }
 
                         </View>
                         {
-                            index == 0 && <View className='suggest_tag' style={{backgroundColor:ColorType.sleep}}>Popular</View>
+                            index == 0 && <View className='suggest_tag' style={{ backgroundColor: ColorType.sleep }}>{t('feature.suggest.popular')}</View>
                         }
                         {
-                            index == 1 && <View className='suggest_tag' style={{backgroundColor:ColorType.sleep}}>Restorative</View>
+                            index == 1 && <View className='suggest_tag' style={{ backgroundColor: ColorType.sleep }}>{t('feature.suggest.restorative')}</View>
                         }
                     </View>
                 })
@@ -583,7 +591,7 @@ export default function Suggest() {
                     title={pageStep == 0 || pageStep == 2 ? 'Suggest Plan' : 'Next'}
                     background={pageStep < 2 ? ColorType.fast : ColorType.sleep}
                 />
-                <Text className="suggest_footer_btn" onClick={myself}>Set Schedule Myself</Text>
+                <Text className="suggest_footer_btn" onClick={myself}>{t('feature.suggest.set_myself')}</Text>
             </View>
         </Footer>
 

+ 7 - 1
src/pages/common/RecordsHistory.tsx

@@ -296,6 +296,7 @@ export default function Page() {
             }).then(res => {
                 refresh()
                 global.refreshActivity()
+                
                 // router.params.refreshList()
                 // Taro.getCurrentPages()[0].refresh()
             })
@@ -312,9 +313,14 @@ export default function Page() {
         else if (router.params.type == 'time') {
             clearTimeRecords().then(res => {
                 refresh()
-                global.indexPageRefresh()
 
                 global.refrehWeekly()
+                if (global.indexPageRefresh) {
+                    global.indexPageRefresh()
+                }
+                if (global.refreshStreaks){
+                    global.refreshStreaks()
+                }
                 // global.refreshTime()
                 // global.refreshMetric()
                 // Taro.getCurrentPages()[0].refresh()