Decide

joined 2 years ago
 

Preamble: I'm sure there's a better community to ask this question, comment below if you're aware of it.

Okay, for background I'm a bootcamp student, I'm still learning, but I'm almost done. I've been tweaking my LinkedIn as I go, trying to be more attractive for recruiters in the future. Well, last week I was contacted by a recruiter, and asked if I was interested in job opportunities. I did some brief research, and it looks like an actual company on Glassdoor. Anyway, I sent over my resume, and was on a call for maybe 5 minutes. We talk for a bit, and she asked me how I am in interviews and my experience. I tell her that I've been "technically" freelance, but I haven't done anything because of starting cost, but she seemed to ignore that concern. Towards the end of the call I asked her if this would be with her company, and she said yes, and then I said bye.

Now, the problem is that this company is specifically for interview prep, and helping students get hired at other companies. While she said I'd be with her company, I'm concerned that I'm trying to be sold something here. The company is called GigaMe, and there is barely anything online about them.

So, my overall question would be, "what would you do?" Or, what should I expect? I don't think i should get my hopes up, but any advice would help.

[–] Decide@programming.dev 1 points 2 years ago (4 children)

If there's any links, resources, mental models, or anything that you or anyone else think would be helpful in getting this to work, I'm all ears. Also, since it's pretty obvious that this is an assignment, my limitation is that I cannot use useEffect, and the PhoneComponent has to use 4 inputs.

I've been stuck on this for about a week now, so any help, feedback, insight, or articles I should read would be incredibly appreciated.

[–] Decide@programming.dev 2 points 2 years ago* (last edited 2 years ago)

Hey, I'm just now seeing this. So, my component hierarchy is something like this:

App

  • Form
    • TextInput
    • PhoneInput

The TextInput components are very simple:

import { ErrorMessage } from "../ErrorMessage"; //this function can be used to determine if the error message renders based on criteria

export const FunctionalTextInput = ({
  dataProperty,
  errorMessage,
  placeholder,
  value,
  propertyHandler,
}: {
  dataProperty: string;
  errorMessage: string;
  placeholder: string;
  value: string;
  propertyHandler: (property: string, e: string) => void;
}) => {
  //Object.keys(initialUserData)[0]
  return (
    <>
      <div>
        {dataProperty}:
         propertyHandler(dataProperty, e.target.value)}
        />
      </div>
      
    
  );
};
export const FunctionalTextInput = ({
  dataProperty,
  errorMessage,
  placeholder,
  value,
  propertyHandler,
}: {
  dataProperty: string;
  errorMessage: string;
  placeholder: string;
  value: string;
  propertyHandler: (property: string, e: string) => void;
}) => {
  //Object.keys(initialUserData)[0]
  return (
    &lt;>
      <div>
        {dataProperty}:
         propertyHandler(dataProperty, e.target.value)}
        />
      </div>
      
    
  );
};

The shape of my data is like so:

export type UserInformation = {
  firstName: string;
  lastName: string;
  email: string;
  city: string;
  phone: string[];
};

In my Form Component, I have two functions that work in the TextInput component, but not the PhoneInput component.

const dataHandler = (e: FormEvent) => {
    e.preventDefault();
    userDataHandler(formData);
    setFormData(initialUserData);
  };
const propertyHandler = (property: string, value: string) => {
    setFormData((prevProp) => ({ ...prevProp, [property]: value }));
  };

So, over the past few hours I've been trying to talk to bing about this, and get some answers. After a few hours, I finally think the problem is a conflict of state. It seems like the state I'm using in my PhoneInput component interferes with the state of the parent component. This seems to be the case since when I click submit, my dataHandler function doesn't trigger for the PhoneInput component.

So, I guess now I'm wondering how that works? I've heard of raising state to the parent, but passing state down, not as data, but as actual state, sounds difficult and somewhat complex. I'm wondering how to use this technique, the uses, and how I can determine when to use it. Or, better yet, maybe I'm missing something and the answer is right outside my reach.

The phone input in question:

// This is a component that is used for the phone input
// it wall accept 4 inputs, and "lift" the values to the parent component as a single, unformatted string.

import { ChangeEventHandler, useRef, useState } from "react";
import { ErrorMessage } from "../ErrorMessage";

type TPhoneInputProps = {
  errorMessage: string;
  dataProperty: string;
  higherPhoneState: string[];
  propertyHandler: (property: string, e: string) => void;
};
export const FunctionalPhoneInput = ({
  errorMessage,
  dataProperty,
  higherPhoneState,
  propertyHandler,
}: TPhoneInputProps) => {
  const [phoneState, setPhoneState] = useState(["", "", "", ""]);
  const phoneNumber = [
    useRef(null),
    useRef(null),
    useRef(null),
    useRef(null),
  ];
  const phoneNum0 = phoneNumber[0];
  const phoneNum1 = phoneNumber[1];
  const phoneNum2 = phoneNumber[2];
  const phoneNum3 = phoneNumber[3];
  const phoneChangeController =
    (
      index: 0 | 1 | 2 | 3 //  1 | 2 | 3 | 4,
    ): ChangeEventHandler =>
    (e: React.ChangeEvent) => {
      const length = [2, 2, 2, 1];
      const nextInput = phoneNumber[index + 1];
      const prevInput = phoneNumber[index - 1];
      const maxLength = length[index];
      const value = e.target.value;
      const shouldGoToNextInput =
        maxLength === value.length &amp;&amp; nextInput?.current;
      const shouldGoToPrevInput = value.length === 0;
      const newState = phoneState.map((phone, phoneIndex) =>
        index === phoneIndex ? e.target.value : phone
      );
      if (shouldGoToNextInput) {
        nextInput.current?.focus();
      }
      if (shouldGoToPrevInput) {
        prevInput.current?.focus();
      }
      setPhoneState(newState);
      console.log(newState.join(""));
      console.log(dataProperty);

      // Concatenate the new state with e.target.value to get the full phone number
      // const fullPhoneNumber =
      //   newState.slice(0, index).join("") +
      //   e.target.value +
      //   newState.slice(index + 1).join("");
      propertyHandler(dataProperty, newState.join(""));
    };
  return (
&lt;> 
<div>
        Phone:
        <div>
          
          -
          
          -
          
          -
          
        </div>
      </div>

  );
};

Please note that this component is 1000% broken. I was in the process of changing it with Bings suggestions, but it's frustrating getting anything useful out of the thing.

 

I'm currently having trouble with the phone component I'm writing. To be extra vague about it, on my onChange, I'm using a function to move to the next text box. However, when I use my data handler function to raise the value to the parent, it doesn't work. In addition, by adding my data handler to the individual text boxes, it breaks my next Box function.

//dataHandler => raises state data to parent
//nextBox => moves focus to next text box 
 
//onChange should be here
 {
    dataHandler(dataProp, e); 
    nextBox(1);
} />

In the code above, either nextBox works alone, or if I add my handler, then neither work.

I'm also wondering about practices. On other forms, I put this type of handler on single boxes, and it works fine. Since my phone input component has multiple boxes, I'm thinking that onChange won't work exactly the same regardless.

Any advice, tips, or need to know info?

Ps: I'm on mobile, so I greatly simplified the code I'm using, and the formatting is wonky. Assume that there's an onChange before the brackets with an (e) =>. My app or lemmy is deleting it on submission.

 

End of a season. This is a very touching chapter that proves how great the writers are.

[–] Decide@programming.dev 1 points 2 years ago (1 children)

Thank you 🙏

[–] Decide@programming.dev 1 points 2 years ago (3 children)

If you still have any, I'd appreciate one.

[–] Decide@programming.dev 3 points 2 years ago (3 children)

Godot is written in GoLang?

[–] Decide@programming.dev 1 points 2 years ago

This is more than I had hoped for, thank you. I also think you're right, that it'll work for me. I'd very much like to contribute to something good in the world, and knowing that this was an option that I overlooked helps immensely. When I've tried "regular" jobs, I tended to not fit into the setting so well, being that I tend to bring up some philosophical question or ask too many questions in general.

I want to run it down real fast, to be sure I got it all:

  1. Go to their site and look for dev credits
  2. Contact the people who made the site, and essentially see if I can join them or take on some work with them.
  3. If it's not a yes, then ask questions and seek advice.
  4. At some point get a gov job for it's benefits.

I do have another question I'm curious about. Can you tell me about how you create your static sites? I've practiced it in the past, but how do you deal with a large amount of repeated elements? Another question is about your study or learning habits. I know we should practice, but getting some insight into how other people do things sometimes yields new information that might work with me.

[–] Decide@programming.dev 2 points 2 years ago* (last edited 2 years ago) (3 children)

Of course. I am a bit curious about what GLAM is and any other important terms I can search that can help me find this type of work. Generally, I'm mainly curious about the whole starting process, what to look out for, and how to best approach this area.

[–] Decide@programming.dev 5 points 2 years ago (1 children)

Can you tell me the appeal of Arc? I have it, and I've used it, but I just can't seem to "get it".

[–] Decide@programming.dev 3 points 2 years ago (5 children)

This is really good advice. I had no idea I about that area of work. It makes sense in hindsight, but having it written out so clearly really gives me some ideas on where to focus. Thank you.

[–] Decide@programming.dev 3 points 2 years ago

Thank you! Your reply provides a lot of missing context. It will be my bible, or at least part of the guidelines I need to get something started.

[–] Decide@programming.dev 3 points 2 years ago (2 children)

This makes a lot of sense. I'll have to see how I can apply this locally, but at least it's more information that I had before on how to approach this. I appreciate it, thank you.

[–] Decide@programming.dev 3 points 2 years ago

I'll look into this and see if I can fill in the gaps. Thank you!

view more: ‹ prev next ›