diff --git a/apps/tax/pages/tax/index.tsx b/apps/tax/pages/tax/index.tsx index 9d567dea..a9baf41a 100644 --- a/apps/tax/pages/tax/index.tsx +++ b/apps/tax/pages/tax/index.tsx @@ -1,10 +1,9 @@ import React, { useState } from 'react' -import { Box, Button, Divider, FormStepperV2, Section } from '@island.is/island-ui/core' +import { Box, FormStepperV2, Section } from '@island.is/island-ui/core' import FormStepsLayout from '@island.is/tax/screens/Layouts/FormStepsLayout' - -import StepOne from './steps/StepOne' -import StepTwo from './steps/StepTwo' +import StepOne from '@island.is/tax/screens/Tax/steps/StepOne' +import StepTwo from '@island.is/tax/screens/Tax/steps/StepTwo' const steps = [ { title: 'Gagnaöflun', index: 0 }, @@ -30,30 +29,44 @@ export async function getServerSideProps() { } } -const renderStep = (step: number) => { - switch (step) { - case 0: - return - case 1: - return - case 2: - return
Step3
- case 3: - return
Step4
- case 4: - return
Step5
- case 5: - return
Step6
- case 6: - return
Step7
- default: - break - } -} - const Tax = ({ taxInfo }) => { const [currentStep, setCurrentStep] = useState(0) + const renderStep = (step: number) => { + switch (step) { + case 0: + return + case 1: + return + case 2: + return
Step3
+ case 3: + return
Step4
+ case 4: + return
Step5
+ case 5: + return
Step6
+ case 6: + return
Step7
+ default: + break + } + } + + const onForward = () => { + if (currentStep < 6) { + const newStep = currentStep + 1 + setCurrentStep(newStep) + } + } + + const onBackward = () => { + if (currentStep > 0) { + const newStep = currentStep - 1 + setCurrentStep(newStep) + } + } + return ( { } > - - {renderStep(currentStep)} - - - - - + {renderStep(currentStep)} ) } diff --git a/apps/tax/screens/Tax/Buttons.tsx b/apps/tax/screens/Tax/Buttons.tsx new file mode 100644 index 00000000..6741645e --- /dev/null +++ b/apps/tax/screens/Tax/Buttons.tsx @@ -0,0 +1,33 @@ +import { Box, Button } from '@island.is/island-ui/core' + +type ButtonProps = { + onForward: () => void + onBackward: () => void +} + +const Buttons = ({ onForward, onBackward }: ButtonProps) => { + return ( + + + + + ) +} + +export default Buttons diff --git a/apps/tax/pages/tax/steps/StepOne.tsx b/apps/tax/screens/Tax/steps/StepOne.tsx similarity index 86% rename from apps/tax/pages/tax/steps/StepOne.tsx rename to apps/tax/screens/Tax/steps/StepOne.tsx index e47bec38..1fe21eb9 100644 --- a/apps/tax/pages/tax/steps/StepOne.tsx +++ b/apps/tax/screens/Tax/steps/StepOne.tsx @@ -1,6 +1,13 @@ import { Box, Checkbox, Icon, Text } from '@island.is/island-ui/core' -const StepOne = () => { +import Buttons from '../Buttons' + +type StepOneProps = { + onForward: () => void + onBackward: () => void +} + +const StepOne = ({ onForward, onBackward }: StepOneProps) => { return ( { subLabel="Ég skil að ofangreind gögn verði sótt rafrænt." /> + + ) } diff --git a/apps/tax/screens/StepTwo.css.ts b/apps/tax/screens/Tax/steps/StepTwo.css.ts similarity index 100% rename from apps/tax/screens/StepTwo.css.ts rename to apps/tax/screens/Tax/steps/StepTwo.css.ts diff --git a/apps/tax/pages/tax/steps/StepTwo.tsx b/apps/tax/screens/Tax/steps/StepTwo.tsx similarity index 90% rename from apps/tax/pages/tax/steps/StepTwo.tsx rename to apps/tax/screens/Tax/steps/StepTwo.tsx index 27bf41d7..d2a8fc46 100644 --- a/apps/tax/pages/tax/steps/StepTwo.tsx +++ b/apps/tax/screens/Tax/steps/StepTwo.tsx @@ -8,9 +8,16 @@ import { Text, Typography, } from '@island.is/island-ui/core' -import { fieldWrapper } from '@island.is/tax/screens/StepTwo.css' +import { fieldWrapper } from '@island.is/tax/screens/Tax/steps/StepTwo.css' -const StepTwo = () => { +import Buttons from '../Buttons' + +type StepTwoProps = { + onForward: () => void + onBackward: () => void +} + +const StepTwo = ({ onForward, onBackward }: StepTwoProps) => { return ( { - + + ) }