Code Monkey home page Code Monkey logo

multi-step-form-main's Introduction

Frontend Mentor - Multi-step form solution

This is a solution to the Multi-step form challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Note: Delete this note and update the table of contents based on what sections you keep.

Overview

The challenge

Users should be able to:

  • Complete each step of the sequence
  • Go back to a previous step to update their selections
  • See a summary of their selections on the final step and confirm their order
  • View the optimal layout for the interface depending on their device's screen size
  • See hover and focus states for all interactive elements on the page
  • Receive form validation messages if:
    • A field has been missed
    • The email address is not formatted correctly
    • A step is submitted, but no selection has been made

Screenshot

screencapture-dan-multi-step-form-vercel-app-2023-07-30-17_17_46 screencapture-dan-multi-step-form-vercel-app-Page2-2023-07-30-17_18_01

Note: Delete this note and the paragraphs above when you add your screenshot. If you prefer not to add a screenshot, feel free to remove this entire section.

Links

My process

Built with

  • Semantic HTML5 markup
  • SCSS custom properties
  • Flexbox
  • React Hooks
  • React - JS library
  • Sass - React framework

Note: These are just examples. Delete this note and replace the list above with your own choices

What I learned

-Data Transfer -Problem with SVG Manipulation

To see how you can add code snippets, see below:

let navigator = useNavigate();
    let location = useLocation();
    const {
        formValue,
        formValue1,
        formValue2,
        formValues15,
        formValues14,
        formValues13 } = location.state;

    const [formErrors, setFormErrors] = useState({});
    const [formValues4, setFormValue4] = useState([]);
    const [formValues5, setFormValue5] = useState([]);
    const [isSubmit, setisSubmit] = useState(false);
    const [isSubmit1, setisSubmit1] = useState(false);
    const [selectedOption, setSelectedOption] = useState('');
    const [selectedOption2, setSelectedOption2] = useState('');
    const [selectedOption3, setSelectedOption3] = useState('');

    const handleSubmit = (e) => {
        e.preventDefault();
        setFormErrors(validate(selectedOption, selectedOption2, selectedOption3));
        setisSubmit(true)
        // console.log(totalValue);
    };

    useEffect(() => {
        setFormValue4(totalValue);
        if (Object.keys(formErrors).length === 0 && isSubmit) {
            if (formValue == null || formValue1 == null || formValue2 == null || formValue === '' || formValue1 === '' || formValue2 === '') {
                const statesToPass = {
                    formValue5: formValues15,
                    formValue1: formValues14,
                    formValue2: formValues13,
                    formValues4: formValues4
                };
                navigator('../Page4', { state: statesToPass });
            } else {
                const statesToPass = {
                    formValue5: formValue,
                    formValue1: formValue1,
                    formValue2: formValue2,
                    formValues4: formValues4
                };
                navigator('../Page4', { state: statesToPass });
            }
            console.log(location.state)
        }
    },
        // eslint-disable-next-line react-hooks/exhaustive-deps
        [formErrors, selectedOption, selectedOption2, selectedOption3, isSubmit])



    const goBack1 = (e) => {
        e.preventDefault();
        setisSubmit1(true);
    }


    useEffect(() => {
        setFormValue5(formValue);
        if (isSubmit1) {
            const statesToPass = {
                formValue5: formValues5,
            };
            navigator('../Page2', { state: statesToPass });
            // console.log(formValues5)
        }
    },
        // eslint-disable-next-line react-hooks/exhaustive-deps
        [selectedOption, selectedOption2, selectedOption3, isSubmit1])

    const validate = (values) => {
        const errors = {};
        if (selectedOption === '' && selectedOption2 === '' && selectedOption3 === '') {
            errors.options = "Please select an plan"
        }
        return errors;
    }

if date looping was thing....lol

Note: Delete this note and the content within this section and replace with your own learnings.

Continued development

-Better Techniques for data tranfer been page modules. -using local storage in the place of useStates

Note: Delete this note and the content within this section and replace with your own plans for continued development.

Useful resources

  • Radio-Input - This helped me for working with Radio inputs and alzo the design inspiration. I really liked this pattern and will use it going forward.
  • CheckBox - This is an amazing article which helped me finally understand checkBox. I'd recommend it to anyone still learning this concept.

Author

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.