function GuestFlow() {
  const [image, setimage] = useState("");
  const setImage = (image) => {
    setimage(image);
  };
  const [meme, setMeme] = useState(
    "https://media.giphy.com/media/3o6gbbuLW76jkt8vIc/giphy.gif"
  );
  const [draw, setDraw] = useState();
  const [step, setStep] = useState(1);

  const increaseStep = () => {
    setStep(step + 1);
  };
  const decreaseStep = () => {
    setStep(step - 1);
  };
  const REQUEST_POST = "/api/v1/post";
  const submitPost = async () => {
    try {
      await axios
        .post(REQUEST_POST, {
          name: name,
          owner: userID,
          birth: birthday,
          color: color,
          city: city,
          gender: gender,
          size: size,
          eyes: eyecolor,
          haircolor: hair,
          getToKnow: know,
          food: food,
          superpower: superpower,
          smthToDieFor: smthToDieFor,
          meme: meme,
          proud: proud,
          pet: pet,
          selfie: image,
          drawing: draw,
        })
        .then(increaseStep);
    } catch (error) {
      console.log(error);
      alert(error);
    }
  };

  const [fieldValues, dispatchFieldAction] = useReducer(
    fieldReducer,
    initalState
  );

  const handleChange = (e) => {
    dispatchFieldAction({
      fieldName: e.target.name,
      fieldValue: e.target.value,
    });
  };
  const {
    name,
    birthday,
    gender,
    size,
    color,
    hair,
    eyecolor,
    know,
    food,
    superpower,
    proud,
    pet,
    smthToDieFor,
    city,
  } = fieldValues;
  switch (step) {
    case 1:
      // start
      return <Question0 increaseStep={increaseStep} />;
    case 2:
      //gender
      return (
        <Question1
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          value={gender}
        />
      );
    case 3:
      // name
      return (
        <Question2
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          name={name}
        />
      );
    case 4:
      // birthday
      return (
        <Question3
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          birthday={birthday}
          handleChange={handleChange}
        />
      );
    case 5:
      // size
      return (
        <Question4
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          size={size}
          handleChange={handleChange}
        />
      );
    case 6:
      // city
      return (
        <Question31
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          city={city}
          handleChange={handleChange}
        />
      );
    case 7:
      // pet
      return (
        <Question32
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          pet={pet}
          handleChange={handleChange}
        />
      );
    case 8:
      // food
      return (
        <Question33
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          food={food}
          handleChange={handleChange}
        />
      );
    case 9:
      //color - radiobutton
      return (
        <Question5
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          value={color}
        />
      );
    case 10:
      // hair- radiobutton
      return (
        <Question6
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          value={hair}
        />
      );
    case 11:
      // eye color
      return (
        <Question7
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          eyecolor={eyecolor}
        />
      );
    case 12:
      // where do we know each other
      return (
        <Question8
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          know={know}
          handleChange={handleChange}
        />
      );
    case 13:
      // superpower
      return (
        <Question9
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          superpower={superpower}
          handleChange={handleChange}
        />
      );
    case 14:
      // something to die for
      return (
        <Question91
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          smthToDieFor={smthToDieFor}
          handleChange={handleChange}
        />
      );
    case 15:
      // proud
      return (
        <Question92
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          proud={proud}
          handleChange={handleChange}
        />
      );
    case 16:
      // gif
      return (
        <GuestGif
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          setMeme={setMeme}
          handleChange={handleChange}
        />
      );
    case 17:
      // Picture select
      return (
        <GuestPicUpload
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          setImage={setImage}
        />
      );
    case 18:
      // drawing
      return (
        <GuestPaintSection
          increaseStep={submitPost}
          decreaseStep={decreaseStep}
          setDraw={setDraw}
        />
      );
    case 19:
      return (
        <GuestSuccess increaseStep={increaseStep} decreaseStep={decreaseStep} />
      );
    default:
      return <p>Lit</p>;
  }
}
// navigate from register-step to register step using switch
navigate from register-step to register step using switch
navigate from register - step to register step using switch
function GuestFlow() {
  const [image, setimage] = useState("");
  const setImage = (image) => {
    setimage(image);
  };
  const [meme, setMeme] = useState(
    "https://media.giphy.com/media/3o6gbbuLW76jkt8vIc/giphy.gif"
  );
  const [draw, setDraw] = useState();
  const [step, setStep] = useState(1);
  const increaseStep = () => {
    setStep(step + 1);
  };
  const decreaseStep = () => {
    setStep(step - 1);
  };
  const REQUEST_POST = "/api/v1/post";
  const submitPost = async () => {
    try {
      await axios
        .post(REQUEST_POST, {
          name: name,
          owner: userID,
          birth: birthday,
          color: color,
          city: city,
          gender: gender,
          size: size,
          eyes: eyecolor,
          haircolor: hair,
          getToKnow: know,
          food: food,
          superpower: superpower,
          smthToDieFor: smthToDieFor,
          meme: meme,
          proud: proud,
          pet: pet,
          selfie: image,
          drawing: draw,
        })
        .then(increaseStep);
    } catch (error) {
      console.log(error);
      alert(error);
    }
  };
  const [fieldValues, dispatchFieldAction] = useReducer(
    fieldReducer,
    initalState
  );
  const handleChange = (e) => {
    dispatchFieldAction({
      fieldName: e.target.name,
      fieldValue: e.target.value,
    });
  };
  const {
    name,
    birthday,
    gender,
    size,
    color,
    hair,
    eyecolor,
    know,
    food,
    superpower,
    proud,
    pet,
    smthToDieFor,
    city,
  } = fieldValues;
  switch (step) {
    case 1:
      return <Question0 increaseStep={increaseStep} />;
    case 2:
      return (
        <Question1
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          value={gender}
        />
      );
    case 3:
      return (
        <Question2
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          name={name}
        />
      );
    case 4:
      return (
        <Question3
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          birthday={birthday}
          handleChange={handleChange}
        />
      );
    case 5:
      return (
        <Question4
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          size={size}
          handleChange={handleChange}
        />
      );
    case 6:
      return (
        <Question31
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          city={city}
          handleChange={handleChange}
        />
      );
    case 7:
      return (
        <Question32
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          pet={pet}
          handleChange={handleChange}
        />
      );
    case 8:
      return (
        <Question33
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          food={food}
          handleChange={handleChange}
        />
      );
    case 9:
      return (
        <Question5
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          value={color}
        />
      );
    case 10:
      return (
        <Question6
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          value={hair}
        />
      );
    case 11:
      return (
        <Question7
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          handleChange={handleChange}
          eyecolor={eyecolor}
        />
      );
    case 12:
      return (
        <Question8
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          know={know}
          handleChange={handleChange}
        />
      );
    case 13:
      return (
        <Question9
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          superpower={superpower}
          handleChange={handleChange}
        />
      );
    case 14:
      return (
        <Question91
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          smthToDieFor={smthToDieFor}
          handleChange={handleChange}
        />
      );
    case 15:
      return (
        <Question92
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          proud={proud}
          handleChange={handleChange}
        />
      );
    case 16:
      return (
        <GuestGif
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          setMeme={setMeme}
          handleChange={handleChange}
        />
      );
    case 17:
      return (
        <GuestPicUpload
          increaseStep={increaseStep}
          decreaseStep={decreaseStep}
          setImage={setImage}
        />
      );
    case 18:
      return (
        <GuestPaintSection
          increaseStep={submitPost}
          decreaseStep={decreaseStep}
          setDraw={setDraw}
        />
      );
    case 19:
      return (
        <GuestSuccess increaseStep={increaseStep} decreaseStep={decreaseStep} />
      );
    default:
      return <p>Lit</p>;
  }
}
function GuestFlow ( ) { const [ image , setimage ] = useState ( "" ) ; const setImage = ( image ) => { setimage ( image ) ; } ; const [ meme , setMeme ] = useState ( "https://media.giphy.com/media/3o6gbbuLW76jkt8vIc/giphy.gif" ) ; const [ draw , setDraw ] = useState ( ) ; const [ step , setStep ] = useState ( 1 ) ; const increaseStep = ( ) => { setStep ( step + 1 ) ; } ; const decreaseStep = ( ) => { setStep ( step - 1 ) ; } ; const REQUEST_POST = "/api/v1/post" ; const submitPost = async ( ) => { try { await axios . post ( REQUEST_POST , { name : name , owner : userID , birth : birthday , color : color , city : city , gender : gender , size : size , eyes : eyecolor , haircolor : hair , getToKnow : know , food : food , superpower : superpower , smthToDieFor : smthToDieFor , meme : meme , proud : proud , pet : pet , selfie : image , drawing : draw , } ) . then ( increaseStep ) ; } catch ( error ) { console . log ( error ) ; alert ( error ) ; } } ; const [ fieldValues , dispatchFieldAction ] = useReducer ( fieldReducer , initalState ) ; const handleChange = ( e ) => { dispatchFieldAction ( { fieldName : e . target . name , fieldValue : e . target . value , } ) ; } ; const { name , birthday , gender , size , color , hair , eyecolor , know , food , superpower , proud , pet , smthToDieFor , city , } = fieldValues ; switch ( step ) { case 1 : return < Question0 increaseStep = { increaseStep } / > ; case 2 : return ( < Question1 increaseStep = { increaseStep } decreaseStep = { decreaseStep } handleChange = { handleChange } value = { gender } / > ) ; case 3 : return ( < Question2 increaseStep = { increaseStep } decreaseStep = { decreaseStep } handleChange = { handleChange } name = { name } / > ) ; case 4 : return ( < Question3 increaseStep = { increaseStep } decreaseStep = { decreaseStep } birthday = { birthday } handleChange = { handleChange } / > ) ; case 5 : return ( < Question4 increaseStep = { increaseStep } decreaseStep = { decreaseStep } size = { size } handleChange = { handleChange } / > ) ; case 6 : return ( < Question31 increaseStep = { increaseStep } decreaseStep = { decreaseStep } city = { city } handleChange = { handleChange } / > ) ; case 7 : return ( < Question32 increaseStep = { increaseStep } decreaseStep = { decreaseStep } pet = { pet } handleChange = { handleChange } / > ) ; case 8 : return ( < Question33 increaseStep = { increaseStep } decreaseStep = { decreaseStep } food = { food } handleChange = { handleChange } / > ) ; case 9 : return ( < Question5 increaseStep = { increaseStep } decreaseStep = { decreaseStep } handleChange = { handleChange } value = { color } / > ) ; case 10 : return ( < Question6 increaseStep = { increaseStep } decreaseStep = { decreaseStep } handleChange = { handleChange } value = { hair } / > ) ; case 11 : return ( < Question7 increaseStep = { increaseStep } decreaseStep = { decreaseStep } handleChange = { handleChange } eyecolor = { eyecolor } / > ) ; case 12 : return ( < Question8 increaseStep = { increaseStep } decreaseStep = { decreaseStep } know = { know } handleChange = { handleChange } / > ) ; case 13 : return ( < Question9 increaseStep = { increaseStep } decreaseStep = { decreaseStep } superpower = { superpower } handleChange = { handleChange } / > ) ; case 14 : return ( < Question91 increaseStep = { increaseStep } decreaseStep = { decreaseStep } smthToDieFor = { smthToDieFor } handleChange = { handleChange } / > ) ; case 15 : return ( < Question92 increaseStep = { increaseStep } decreaseStep = { decreaseStep } proud = { proud } handleChange = { handleChange } / > ) ; case 16 : return ( < GuestGif increaseStep = { increaseStep } decreaseStep = { decreaseStep } setMeme = { setMeme } handleChange = { handleChange } / > ) ; case 17 : return ( < GuestPicUpload increaseStep = { increaseStep } decreaseStep = { decreaseStep } setImage = { setImage } / > ) ; case 18 : return ( < GuestPaintSection increaseStep = { submitPost } decreaseStep = { decreaseStep } setDraw = { setDraw } / > ) ; case 19 : return ( < GuestSuccess increaseStep = { increaseStep } decreaseStep = { decreaseStep } / > ) ; default : return < p > Lit < / p > ; } }
navigate from register-step to register step using switch
navigate from register - step to register step using switch
// start //gender // name // birthday // size // city // pet // food //color - radiobutton // hair- radiobutton // eye color // where do we know each other // superpower // something to die for // proud // gif // Picture select // drawing