update 5 files

master
Reza_ashrafi 2 years ago
parent 0e6c073a99
commit 82d7aec1df
  1. 4
      src/components/Input/index.js
  2. 2
      src/components/Select/index.js
  3. 2
      src/components/Textarea/index.js
  4. 19
      src/router.js
  5. 102
      src/views/Auth/Profile/index.js

@ -19,11 +19,11 @@ export default function Input(props) {
return ( return (
<div <div
className="input flex flex-col relative my-2 dark:bg-opacity-10 w-full" className="input flex flex-col relative dark:bg-opacity-10 w-full"
style={{ width }} style={{ width }}
> >
<label <label
className={`absolute right-2 transform bg-white -translate-y-1/2 dark:text-white px-2 text-xs transition-all duration-300 pointer-events-none ${value || focusToggle ? "top-0 text-xs" : "top-1/2 text-sm"} ${focusToggle ? "text-blueC0" : "text-gray1"}`} className={`absolute right-2 transform bg-white -translate-y-1/2 dark:text-white px-2 text-xs transition-all duration-300 pointer-events-none ${value || focusToggle ? "top-0 lg:text-xs text-sm" : "top-1/2 text-tiny lg:text-sm"} ${focusToggle ? "text-blueC0" : "text-gray1"}`}
> >
{label} {label}
</label> </label>

@ -10,7 +10,7 @@ function Select({
onChange, onChange,
name, name,
defaultValue, defaultValue,
width = "w-1/2", width = "w-full",
selectProvince, selectProvince,
}) { }) {
return ( return (

@ -7,7 +7,7 @@ export default function Textarea({ placeholder, onChange, value, name }) {
<textarea <textarea
className={_.join( className={_.join(
[ [
"my-2 border border-gray-300 rounded-md text-xs lg:text-sm py-6 px-3 outline-none focus:border-greenB9", "border w-full border-gray-300 rounded-md text-xs lg:text-sm py-6 px-3 outline-none focus:border-greenB9",
// backgroundColor, // backgroundColor,
], ],
" " " "

@ -34,6 +34,7 @@ import Dialog from "./components/Dialog";
import Address from "./views/Address"; import Address from "./views/Address";
import Favorites from "./views/Favorites"; import Favorites from "./views/Favorites";
import Addresses from "./views/Dashboard/layouts/Mobile/ProfileAddress"; import Addresses from "./views/Dashboard/layouts/Mobile/ProfileAddress";
import Profile from "./views/Auth/Profile"
function Router({ function Router({
isDark, isDark,
@ -567,6 +568,24 @@ function Router({
/> />
} }
/> />
<Route
path="/profile"
exact
element={
<Profile
headerOptions={{
logo: false,
hamburgerMenu: false,
qr: false,
title: false,
back: true,
shown: true,
menu: false,
// bookmark: "contentId",
}}
/>
}
/>
<Route <Route
path="*" path="*"
exact exact

@ -29,6 +29,7 @@ function Profile({
provinceList, provinceList,
cityList, cityList,
setHeaderOptions, setHeaderOptions,
headerOptions,
loading, loading,
}) { }) {
let navigate = useNavigate(); let navigate = useNavigate();
@ -69,18 +70,7 @@ function Profile({
}, [user]); }, [user]);
useEffect(() => { useEffect(() => {
if (!isMobile) { setHeaderOptions(headerOptions);
setHeaderOptions({
logo: true,
hamburgerMenu: true,
qr: true,
title: false,
back: false,
shown: true,
menu: false,
});
}
getProvince(); getProvince();
getCity({ provinceId: profile.provinceId }); getCity({ provinceId: profile.provinceId });
}, []); }, []);
@ -216,33 +206,23 @@ function Profile({
// if (setDone) return <Navigate path="/" />; // if (setDone) return <Navigate path="/" />;
return isMobile ? ( return isMobile ? (
<div className="profile main d-flex justify-content-center"> <div className="flex flex-col gap-6 lg:hidden px-4 pb-20">
<main> <header className="flex flex-col gap-2 w-full">
<header className="d-flex align-items-center justify-content-between"> <h1 className="text-base text-gray1">{window.t("حساب کاربری")}</h1>
<div> <p className="text-sm text-gray1">
<h1>{window.t("حساب کاربری")}</h1> {window.t("لطفا مشخصات خود را به صورت کامل نمایید.")}
<p>{window.t("لطفا مشخصات خود را به صورت کامل نمایید.")}</p> </p>
</div>
<div className="mobile justify-content-center">
<Upload
name="file"
value={formData?.file}
onChange={onChange}
label={window.t("فایل")}
/>
</div>
</header> </header>
<div className="profile__box d-flex" onSubmit={(e) => onSubmit()}> <form
<div className="profile__box--section"> className="flex flex-col items-center w-full gap-4"
<div className="mb-2 desktop justify-content-center"> onSubmit={(e) => e.preventDefault()}
>
<Upload <Upload
name="file" name="file"
value={formData?.file} value={formData?.file}
onChange={onChange} onChange={onChange}
label={window.t("فایل")} label={window.t("فایل")}
/> />
</div>
<div className="mb-2">
<Input <Input
name="firstName" name="firstName"
label={window.t("نام")} label={window.t("نام")}
@ -254,8 +234,6 @@ function Profile({
} }
regex={(val) => val} regex={(val) => val}
/> />
</div>
<div className="mb-2">
<Input <Input
name="lastName" name="lastName"
label={window.t("نام نام خانوادگی")} label={window.t("نام نام خانوادگی")}
@ -267,8 +245,6 @@ function Profile({
onInput={onInput.persianOnly} onInput={onInput.persianOnly}
regex={(val) => val} regex={(val) => val}
/> />
</div>
<div className="mb-2">
<Input <Input
name="username" name="username"
label={window.t("نام کاربری")} label={window.t("نام کاربری")}
@ -279,8 +255,6 @@ function Profile({
align="left" align="left"
regex={(val) => onInput.englishAndNumberWithoutSpace(val)} regex={(val) => onInput.englishAndNumberWithoutSpace(val)}
/> />
</div>
<div className="mb-2">
<Gender <Gender
options={[window.t("دختر"), window.t("پسر")]} options={[window.t("دختر"), window.t("پسر")]}
name="gender" name="gender"
@ -288,10 +262,8 @@ function Profile({
onChange={(name, value) => onChange={(name, value) =>
setFormData({ ...formData, [name]: value }) setFormData({ ...formData, [name]: value })
} }
label="" label="جنسیت"
/> />
</div>
<div className="mb-2">
<Input <Input
name="nationalId" name="nationalId"
label={window.t("کد ملی/اتباع")} label={window.t("کد ملی/اتباع")}
@ -303,8 +275,6 @@ function Profile({
} }
regex={(val) => onInput.numberOnly(val)} regex={(val) => onInput.numberOnly(val)}
/> />
</div>
<div className="mb-2">
<Birthdate <Birthdate
name="birthDate" name="birthDate"
onChange={(name, value) => onChange={(name, value) =>
@ -312,8 +282,6 @@ function Profile({
} }
value={formData?.birthDate} value={formData?.birthDate}
/> />
</div>
<div className="mb-2">
<Input <Input
name="password" name="password"
label={window.t("رمز عبور")} label={window.t("رمز عبور")}
@ -324,10 +292,6 @@ function Profile({
align="left" align="left"
regex={(val) => onInput.englishAndNumberWithoutSpace(val)} regex={(val) => onInput.englishAndNumberWithoutSpace(val)}
/> />
</div>
</div>
<div className="profile__box--section">
<div className="mb-2" style={{ minWidth: "100%" }}>
<Gender <Gender
options={[window.t("معلم"), window.t("دانش آموز")]} options={[window.t("معلم"), window.t("دانش آموز")]}
name="status" name="status"
@ -335,9 +299,7 @@ function Profile({
selectedOption={formData?.status} selectedOption={formData?.status}
onChange={onChange} onChange={onChange}
/> />
</div>
{formData?.status === 1 ? ( {formData?.status === 1 ? (
<div className="mb-2">
<Select <Select
options={grades} options={grades}
name="gradeIds" name="gradeIds"
@ -347,10 +309,8 @@ function Profile({
setFormData({ ...formData, [name]: value }) setFormData({ ...formData, [name]: value })
} }
/> />
</div>
) : null} ) : null}
{formData?.status === 2 ? ( {formData?.status === 2 ? (
<div className="mb-2">
<MultipleSelector <MultipleSelector
options={grades} options={grades}
name="gradeIds" name="gradeIds"
@ -362,12 +322,10 @@ function Profile({
align="right" align="right"
defaultValue={profile} defaultValue={profile}
/> />
</div>
) : null} ) : null}
{formData?.status === window.t("دانش آموز") && {formData?.status === window.t("دانش آموز") &&
formData?.gradeIds > 9 ? ( formData?.gradeIds > 9 ? (
<div className="mb-2">
<Select <Select
options={[ options={[
window.t("ریاضی"), window.t("ریاضی"),
@ -384,9 +342,7 @@ function Profile({
setFormData({ ...formData, [name]: value }) setFormData({ ...formData, [name]: value })
} }
/> />
</div>
) : null} ) : null}
<div className="mb-2" style={{ minWidth: "100%" }}>
<Select <Select
options={provinceList} options={provinceList}
name="provinceId" name="provinceId"
@ -396,8 +352,6 @@ function Profile({
setFormData({ ...formData, [name]: value }) setFormData({ ...formData, [name]: value })
} }
/> />
</div>
<div className="mb-2">
<Select <Select
options={cityList} options={cityList}
name="cityId" name="cityId"
@ -407,9 +361,7 @@ function Profile({
setFormData({ ...formData, [name]: value }) setFormData({ ...formData, [name]: value })
} }
/> />
</div>
{formData?.status == 1 ? ( {formData?.status == 1 ? (
<div className="mb-2">
<Input <Input
name="schools" name="schools"
label={window.t("نام مدرسه")} label={window.t("نام مدرسه")}
@ -419,10 +371,8 @@ function Profile({
setFormData({ ...formData, [name]: value }) setFormData({ ...formData, [name]: value })
} }
/> />
</div>
) : null} ) : null}
{formData?.status == 2 ? ( {formData?.status == 2 ? (
<div className="mb-2">
<Input <Input
name="schools" name="schools"
label={window.t("محل تدریس")} label={window.t("محل تدریس")}
@ -430,7 +380,6 @@ function Profile({
regex={(val) => onInput.persianOnly(val)} regex={(val) => onInput.persianOnly(val)}
onChange={onChange} onChange={onChange}
/> />
</div>
) : null} ) : null}
{formData?.status == 2 ? ( {formData?.status == 2 ? (
<Document <Document
@ -441,7 +390,6 @@ function Profile({
name="docFileIds" name="docFileIds"
/> />
) : null} ) : null}
<div className="mb-2">
<Input <Input
name="postalCode" name="postalCode"
placeholder={window.t("کد پستی")} placeholder={window.t("کد پستی")}
@ -452,8 +400,6 @@ function Profile({
value={formData?.postalCode} value={formData?.postalCode}
regex={(val) => onInput.numberOnly(val)} regex={(val) => onInput.numberOnly(val)}
/> />
</div>
<div className="mb-2">
<TextArea <TextArea
placeholder={window.t("آدرس محل سکونت")} placeholder={window.t("آدرس محل سکونت")}
name="address" name="address"
@ -462,13 +408,13 @@ function Profile({
setFormData({ ...formData, [name]: value }) setFormData({ ...formData, [name]: value })
} }
/> />
</div> <button
<div className="profile__box--form__footer d-flex justify-content-center"> className="w-full bg-blueC0 py-3 text-base text-white rounded-sm"
<button onClick={() => onSubmit()}>{window.t("ذخیره")}</button> onClick={() => onSubmit()}
</div> >
</div> {window.t("ذخیره")}
</div> </button>
</main> </form>
</div> </div>
) : ( ) : (
<div <div
@ -504,7 +450,6 @@ function Profile({
setFormData({ ...formData, [name]: value }) setFormData({ ...formData, [name]: value })
} }
regex={(val) => val} regex={(val) => val}
padding="py-4"
value={formData?.lastName} value={formData?.lastName}
/> />
</div> </div>
@ -569,7 +514,12 @@ function Profile({
/> />
<div className="w-full"></div> <div className="w-full"></div>
</div> </div>
<button className="w-full bg-blueC0 py-3 text-tiny text-white rounded-sm" onClick={() => onSubmit()}>{window.t("ذخیره")}</button> <button
className="w-full bg-blueC0 py-3 text-tiny text-white rounded-sm"
onClick={() => onSubmit()}
>
{window.t("ذخیره")}
</button>
</div> </div>
); );
} }

Loading…
Cancel
Save