Commit 0a2e890b by Arjun Jhukal

updated the minor changes

parent da08a393
"use client";
import InputFile from '@/components/atom/InputFile';
import PasswordField from '@/components/molecules/PasswordField';
import { US_STATES } from '@/constants/state';
import { PlayerProps, SinlgePlayerResponseProps } from '@/types/player';
import { Button, InputLabel, OutlinedInput } from '@mui/material';
import { Button, InputLabel, MenuItem, OutlinedInput, Select } from '@mui/material';
import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import dayjs from 'dayjs';
......@@ -181,6 +182,36 @@ export default function AddPlayerForm({ formik, id, data, loading, buttonLabel }
{formik.touched.phone && formik.errors.phone ? formik.errors.phone : ""}
</span>
</div>
<div className="input__field">
<InputLabel htmlFor="pob">State</InputLabel>
<Select
fullWidth
id="pob"
name="pob"
displayEmpty
value={formik.values.pob}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
sx={formFieldSx}
renderValue={(selected) =>
selected === "" ? "Select a State" : selected
}
>
<MenuItem value="">
<em>Select a State</em>
</MenuItem>
{US_STATES.map((state) => (
<MenuItem key={state.value} value={state.value}>
{state.label}
</MenuItem>
))}
</Select>
<span className="error">{formik.touched.pob && formik.errors.pob}</span>
</div>
<div className="input__field">
<InputLabel htmlFor="zip_code">Zip Code <span className="text-red-500">*</span></InputLabel>
<OutlinedInput
......
......@@ -21,6 +21,7 @@ export const PlayerValidationSchema = (isEdit: boolean) => Yup.object().shape({
address: Yup.string().required("Address is required"),
city: Yup.string().required("City is required"),
zip_code: Yup.string().required("Zip code is required"),
pob: Yup.string().required("State is required"),
phone: Yup.string()
.matches(/^\+?\d{7,15}$/, "Invalid phone number")
.required("Phone is required"),
......@@ -69,6 +70,7 @@ export default function AddPlayerPage({ id }: { id?: string }) {
profile_image: null,
dob: data?.data.dob || null as Dayjs | null,
zip_code: data?.data.zip_code || "",
pob: data?.data.pob || "",
} : initialPlayerValues,
validationSchema: PlayerValidationSchema(!!id),
enableReinitialize: true,
......@@ -86,7 +88,7 @@ export default function AddPlayerPage({ id }: { id?: string }) {
if (values.phone) formData.append("phone", values.phone);
if (values.dob) formData.append("dob", values.dob.toString());
if (values.zip_code) formData.append("zip_code", values.zip_code);
if (values.pob) formData.append("pob", values.pob);
if (values.profile_image) {
if (Array.isArray(values.profile_image)) {
values.profile_image.forEach((file) => formData.append("profile_image", file));
......
......@@ -49,6 +49,8 @@ export default function EditUserProfile({ id, buttonLabel }: { id: string, butto
if (values.city) formData.append("city", values.city);
if (values.phone) formData.append("phone", values.phone);
if (values.dob) formData.append("dob", formattedDob);
if (values.zip_code) formData.append("zip_code", values.zip_code);
if (values.pob) formData.append("pob", values.pob);
if (values.profile_image) {
if (Array.isArray(values.profile_image)) {
......
export const US_STATES = [
{ label: "Alabama", value: "AL" },
{ label: "Alaska", value: "AK" },
{ label: "Arizona", value: "AZ" },
{ label: "Arkansas", value: "AR" },
{ label: "California", value: "CA" },
{ label: "Colorado", value: "CO" },
{ label: "Connecticut", value: "CT" },
{ label: "Delaware", value: "DE" },
{ label: "District Of Columbia", value: "DC" },
{ label: "Florida", value: "FL" },
{ label: "Georgia", value: "GA" },
{ label: "Hawaii", value: "HI" },
{ label: "Idaho", value: "ID" },
{ label: "Illinois", value: "IL" },
{ label: "Indiana", value: "IN" },
{ label: "Iowa", value: "IA" },
{ label: "Kansas", value: "KS" },
{ label: "Kentucky", value: "KY" },
{ label: "Louisiana", value: "LA" },
{ label: "Maine", value: "ME" },
{ label: "Maryland", value: "MD" },
{ label: "Massachusetts", value: "MA" },
{ label: "Michigan", value: "MI" },
{ label: "Minnesota", value: "MN" },
{ label: "Mississippi", value: "MS" },
{ label: "Missouri", value: "MO" },
{ label: "Montana", value: "MT" },
{ label: "Nebraska", value: "NE" },
{ label: "Nevada", value: "NV" },
{ label: "New Hampshire", value: "NH" },
{ label: "New Jersey", value: "NJ" },
{ label: "New Mexico", value: "NM" },
{ label: "New York", value: "NY" },
{ label: "North Carolina", value: "NC" },
{ label: "North Dakota", value: "ND" },
{ label: "Ohio", value: "OH" },
{ label: "Oklahoma", value: "OK" },
{ label: "Oregon", value: "OR" },
{ label: "Pennsylvania", value: "PA" },
{ label: "Rhode Island", value: "RI" },
{ label: "South Carolina", value: "SC" },
{ label: "South Dakota", value: "SD" },
{ label: "Tennessee", value: "TN" },
{ label: "Texas", value: "TX" },
{ label: "Utah", value: "UT" },
{ label: "Vermont", value: "VT" },
{ label: "Virginia", value: "VA" },
{ label: "Washington", value: "WA" },
{ label: "West Virginia", value: "WV" },
{ label: "Wisconsin", value: "WI" },
{ label: "Wyoming", value: "WY" },
];
......@@ -17,6 +17,7 @@ export interface CommonPlayerProps {
state?: string;
dob?: string | Dayjs | null;
zip_code?: string;
pob?: string;
}
export interface PlayerProps extends CommonPlayerProps {
......@@ -43,6 +44,7 @@ export const initialPlayerValues: PlayerProps = {
profile_image: null,
dob: null as Dayjs | null,
zip_code: "",
pob: ""
};
type GameInformation = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment