Fix an issue with profile form
This commit is contained in:
@@ -59,7 +59,6 @@ export default function SignUp() {
|
|||||||
name="name"
|
name="name"
|
||||||
required
|
required
|
||||||
fullWidth
|
fullWidth
|
||||||
id="name"
|
|
||||||
label="Name"
|
label="Name"
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
@@ -68,7 +67,6 @@ export default function SignUp() {
|
|||||||
<TextField
|
<TextField
|
||||||
required
|
required
|
||||||
fullWidth
|
fullWidth
|
||||||
id="email"
|
|
||||||
label="Email Address"
|
label="Email Address"
|
||||||
name="email"
|
name="email"
|
||||||
/>
|
/>
|
||||||
@@ -80,7 +78,6 @@ export default function SignUp() {
|
|||||||
name="password"
|
name="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
type="password"
|
type="password"
|
||||||
id="password"
|
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid size={{ xs: 12 }}>
|
<Grid size={{ xs: 12 }}>
|
||||||
@@ -90,7 +87,6 @@ export default function SignUp() {
|
|||||||
name="password2"
|
name="password2"
|
||||||
label="Repeat Password"
|
label="Repeat Password"
|
||||||
type="password"
|
type="password"
|
||||||
id="password2"
|
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ const initialState = {
|
|||||||
company: "",
|
company: "",
|
||||||
website: "",
|
website: "",
|
||||||
location: "",
|
location: "",
|
||||||
status: "",
|
|
||||||
skills: "",
|
skills: "",
|
||||||
githubusername: "",
|
githubusername: "",
|
||||||
bio: "",
|
bio: "",
|
||||||
|
status: "",
|
||||||
twitter: "",
|
twitter: "",
|
||||||
facebook: "",
|
facebook: "",
|
||||||
linkedin: "",
|
linkedin: "",
|
||||||
@@ -82,16 +82,19 @@ const ProfileForm = () => {
|
|||||||
youtube,
|
youtube,
|
||||||
linkedin,
|
linkedin,
|
||||||
instagram,
|
instagram,
|
||||||
status,
|
|
||||||
} = formData;
|
} = formData;
|
||||||
|
|
||||||
const onChange = (
|
const onChange = (
|
||||||
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
||||||
) => setFormData({ ...formData, [e.target.name]: e.target.value });
|
) => {
|
||||||
|
return setFormData({ ...formData, [e.target.name]: e.target.value });
|
||||||
|
};
|
||||||
|
|
||||||
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
const editing = profile ? true : false;
|
const editing = profile ? true : false;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const form = new FormData();
|
||||||
|
const status = form.get("status") as string;
|
||||||
if (facebook?.length > 100) {
|
if (facebook?.length > 100) {
|
||||||
dispatch(createAlert("Facebook link is longer 100 characters", "danger"));
|
dispatch(createAlert("Facebook link is longer 100 characters", "danger"));
|
||||||
} else if (linkedin?.length > 100) {
|
} else if (linkedin?.length > 100) {
|
||||||
@@ -108,9 +111,9 @@ const ProfileForm = () => {
|
|||||||
dispatch(createAlert("Skills is longer 100 characters", "danger"));
|
dispatch(createAlert("Skills is longer 100 characters", "danger"));
|
||||||
} else if (skills.length === 0) {
|
} else if (skills.length === 0) {
|
||||||
dispatch(createAlert("Skills is required", "danger"));
|
dispatch(createAlert("Skills is required", "danger"));
|
||||||
} else if (skills.length > 100 || skills.length === 0) {
|
|
||||||
dispatch(createAlert("Status is required", "danger"));
|
|
||||||
} else if (status?.length === 0) {
|
} else if (status?.length === 0) {
|
||||||
|
dispatch(createAlert("Status is required", "danger"));
|
||||||
|
} else if (location?.length === 0) {
|
||||||
dispatch(createAlert("Location is longer 100 characters", "danger"));
|
dispatch(createAlert("Location is longer 100 characters", "danger"));
|
||||||
} else if (githubusername?.length > 50) {
|
} else if (githubusername?.length > 50) {
|
||||||
dispatch(
|
dispatch(
|
||||||
@@ -217,7 +220,7 @@ const ProfileForm = () => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid size={{ xs: 6 }}>
|
<Grid size={{ xs: 6 }}>
|
||||||
<TextField
|
<TextField
|
||||||
name="githubUser"
|
name="githubusername"
|
||||||
fullWidth
|
fullWidth
|
||||||
label="Github Username"
|
label="Github Username"
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
@@ -239,7 +242,6 @@ const ProfileForm = () => {
|
|||||||
required
|
required
|
||||||
placeholder="Select Profesional status"
|
placeholder="Select Profesional status"
|
||||||
defaultValue={""}
|
defaultValue={""}
|
||||||
value={status}
|
|
||||||
>
|
>
|
||||||
<MenuItem value="">None</MenuItem>
|
<MenuItem value="">None</MenuItem>
|
||||||
<MenuItem value="Developer">Developer</MenuItem>
|
<MenuItem value="Developer">Developer</MenuItem>
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ import type { TypedUseSelectorHook } from "react-redux";
|
|||||||
import type { RootState, AppDispatch } from "../store";
|
import type { RootState, AppDispatch } from "../store";
|
||||||
|
|
||||||
// Use throughout your app instead of plain `useDispatch` and `useSelector`
|
// Use throughout your app instead of plain `useDispatch` and `useSelector`
|
||||||
|
// taken from the redux wiki. Same as normal hook but typed
|
||||||
export const useAppDispatch: () => AppDispatch = useDispatch;
|
export const useAppDispatch: () => AppDispatch = useDispatch;
|
||||||
export const useAppDispatch2 = () => useDispatch<AppDispatch>;
|
|
||||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
||||||
|
|||||||
Reference in New Issue
Block a user