From 8788aaca1ce4238154e56e10874293ae800c1573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Viga=C5=A1?= Date: Wed, 27 Dec 2023 10:47:02 -0800 Subject: [PATCH] add isPostponeLive env toggle (#811) * add isPostponeLive env toggle * refactor to more simple code --- next.config.js | 1 + src/lib/calculation.ts | 2 +- src/pages/_app.tsx | 9 ++++-- src/pages/index.tsx | 68 +++++++++++++++++++++++------------------- 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/next.config.js b/next.config.js index abdbf844..110a2b31 100644 --- a/next.config.js +++ b/next.config.js @@ -3,6 +3,7 @@ module.exports = { // this allows us to deploy one bundle into multiple envs publicRuntimeConfig: { isLive: process.env.NEXT_PUBLIC_isLive === "true" || false, + isPostponeLive: process.env.NEXT_PUBLIC_isPostponeLive === "true" || false, navodyBaseUrl: process.env.NEXT_PUBLIC_navodyBaseUrl, priznanieStepUrl: process.env.NEXT_PUBLIC_priznanieStepUrl, odkladStepUrl: process.env.NEXT_PUBLIC_odkladStepUrl, diff --git a/src/lib/calculation.ts b/src/lib/calculation.ts index d6b4c2b3..b9f3b6da 100644 --- a/src/lib/calculation.ts +++ b/src/lib/calculation.ts @@ -42,7 +42,7 @@ const POCET_MESIACOV = 12 // 63,4-násobok platného životného minima const ZVYHODNENIE_NA_PARTNERA = 13_825 -export const TAX_YEAR = 2022 +export const TAX_YEAR = 2023 export const MIN_2_PERCENT_CALCULATED_DONATION = 3 export const MAX_CHILD_AGE_BONUS = 25 diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 3e5a280d..034e353a 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -58,9 +58,10 @@ interface MyAppProps extends AppProps { Component: Page> isDebug: boolean isLive: boolean + isPostponeLive: boolean } -const MyApp = ({ Component, isDebug, isLive, pageProps }: MyAppProps) => { +const MyApp = ({ Component, isDebug, isLive, isPostponeLive, pageProps }: MyAppProps) => { const [taxForm, setTaxForm] = useState( taxFormUserInputToTaxForm(initTaxFormUserInputValues), ) @@ -119,6 +120,7 @@ const MyApp = ({ Component, isDebug, isLive, pageProps }: MyAppProps) => { { MyApp.getInitialProps = (context) => { const props = App.getInitialProps(context) const { - publicRuntimeConfig: { isLive }, + publicRuntimeConfig: { isLive, isPostponeLive }, } = getConfig() return { ...props, @@ -150,7 +152,8 @@ MyApp.getInitialProps = (context) => { 'not-pass', context?.ctx?.req?.headers?.cookie, ), - isLive + isLive, + isPostponeLive } } diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 58e0e2d9..a9616c08 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -29,7 +29,7 @@ const IconLock = () => ( ) -const Home = ({ nextRoute, nextPostponeRoute, isDebug, isLive }) => ( +const Home = ({ nextRoute, nextPostponeRoute, isDebug, isLive, isPostponeLive }) => ( <>
@@ -37,7 +37,7 @@ const Home = ({ nextRoute, nextPostponeRoute, isDebug, isLive }) => (
- +
    @@ -150,28 +150,29 @@ const TaxFormSection = ({ nextRoute, isDebug, isLive }) => { ) } -const PostponeSection = ({ nextPostponeRoute, now}) => ( +const PostponeSection = ({ nextPostponeRoute, now, isPostponeLive }) => ( <>

    {`Odklad daňového priznania za rok ${TAX_YEAR}`}

      -
    • {`do 30.6.${ - TAX_YEAR + 1 - } ak ste mali príjmy len zo Slovenska, alebo`}
    • +
    • {`do 30.6.${TAX_YEAR + 1} ak ste mali príjmy len zo Slovenska, alebo`}
    • {`do 30.9.${TAX_YEAR + 1} ak ste mali príjmy aj zo zahraničia`}
    -

    - Používaním tejto služby súhlasíte so spracovaním osobných údajov v rozsahu - nevyhnutnom na vygenerovanie odkladu daňového priznania. Vaše údaje - neukladáme, sú použité výlučne na spracovanie odkladu daňového priznania. -

    - - - - + { + isPostponeLive && ( + <> +

    + Používaním tejto služby súhlasíte so spracovaním osobných údajov v rozsahu + nevyhnutnom na vygenerovanie odkladu daňového priznania. Vaše údaje + neukladáme, sú použité výlučne na spracovanie odkladu daňového priznania. +

    + + + ) + } ) const PostponeText = ({ now }) => ( @@ -195,10 +196,11 @@ const PostponeText = ({ now }) => ( ) -const PostponeButton = ({ now }) => ( - <> - {(now.getMonth() > 2) && ( - <> +const PostponeButton = ({ now, nextPostponeRoute }) => { + const isPostponeTime = now.getMonth() < 3 + + if (!isPostponeTime) { + return ( - )} - {(now.getMonth() < 3) && ( - <> - - )} - -) + ) + } + + if (isPostponeTime) { + return ( + + + + ) + } +}