Skip to content

Commit

Permalink
add isPostponeLive env toggle (#811)
Browse files Browse the repository at this point in the history
* add isPostponeLive env toggle

* refactor to more simple code
  • Loading branch information
MarekVigas authored Dec 27, 2023
1 parent 06a8a62 commit 8788aac
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 35 deletions.
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/calculation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ interface MyAppProps extends AppProps {
Component: Page<Partial<TaxFormUserInput>>
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<TaxForm>(
taxFormUserInputToTaxForm(initTaxFormUserInputValues),
)
Expand Down Expand Up @@ -119,6 +120,7 @@ const MyApp = ({ Component, isDebug, isLive, pageProps }: MyAppProps) => {
<Component
isDebug={isDebug}
isLive={isLive}
isPostponeLive={isPostponeLive}
taxForm={taxForm}
taxFormUserInput={taxFormUserInput}
setTaxFormUserInput={updateTaxFormUserInput}
Expand All @@ -141,7 +143,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,
Expand All @@ -150,7 +152,8 @@ MyApp.getInitialProps = (context) => {
'not-pass',
context?.ctx?.req?.headers?.cookie,
),
isLive
isLive,
isPostponeLive
}
}

Expand Down
68 changes: 37 additions & 31 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ const IconLock = () => (
</svg>
)

const Home = ({ nextRoute, nextPostponeRoute, isDebug, isLive }) => (
const Home = ({ nextRoute, nextPostponeRoute, isDebug, isLive, isPostponeLive }) => (
<>
<div className="govuk-grid-column-two-thirds">
<TaxFormSection nextRoute={nextRoute} isDebug={isDebug} isLive={isLive} />
</div>

<div className="govuk-grid-column-one-third">
<div className={styles.postponeBox}>
<PostponeSection nextPostponeRoute={nextPostponeRoute} now={new Date()} />
<PostponeSection nextPostponeRoute={nextPostponeRoute} now={new Date()} isPostponeLive={isPostponeLive} />
</div>

<ul className={styles.safeList}>
Expand Down Expand Up @@ -150,28 +150,29 @@ const TaxFormSection = ({ nextRoute, isDebug, isLive }) => {
)
}

const PostponeSection = ({ nextPostponeRoute, now}) => (
const PostponeSection = ({ nextPostponeRoute, now, isPostponeLive }) => (
<>
<h2 className="govuk-heading-m govuk-!-margin-top-3">
{`Odklad daňového priznania za rok ${TAX_YEAR}`}
</h2>
<PostponeText now={now}/>
<ul className="govuk-list govuk-list--bullet">
<li>{`do 30.6.${
TAX_YEAR + 1
} ak ste mali príjmy len zo Slovenska, alebo`}</li>
<li>{`do 30.6.${TAX_YEAR + 1} ak ste mali príjmy len zo Slovenska, alebo`}</li>
<li>{`do 30.9.${TAX_YEAR + 1} ak ste mali príjmy aj zo zahraničia`}</li>
</ul>

<p className="govuk-body-xs">
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.
</p>

<Link href={nextPostponeRoute} legacyBehavior>
<PostponeButton now={now}/>
</Link>
{
isPostponeLive && (
<>
<p className="govuk-body-xs">
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.
</p>
<PostponeButton now={now} nextPostponeRoute={nextPostponeRoute} />
</>
)
}
</>
)
const PostponeText = ({ now }) => (
Expand All @@ -195,26 +196,31 @@ const PostponeText = ({ now }) => (
</>
)

const PostponeButton = ({ now }) => (
<>
{(now.getMonth() > 2) && (
<>
const PostponeButton = ({ now, nextPostponeRoute }) => {
const isPostponeTime = now.getMonth() < 3

if (!isPostponeTime) {
return (
<button
type="button"
className="btn-secondary govuk-button govuk-button--large govuk-button--disabled"
disabled
>
Termín na podanie odkladu DP vypršal
</button>
</>)}
{(now.getMonth() < 3) && (
<>
<button
type="button"
className="btn-secondary govuk-button govuk-button--large"
>
Súhlasím a chcem odložiť daňové priznanie
</button>
</>)}
</>
)
)
}

if (isPostponeTime) {
return (
<Link href={nextPostponeRoute} legacyBehavior>
<button
type="button"
className="btn-secondary govuk-button govuk-button--large"
>
Súhlasím a chcem odložiť daňové priznanie
</button>
</Link>
)
}
}

0 comments on commit 8788aac

Please sign in to comment.