یه دیفالت پراپس درست کردم که اول زمان انتخاب استان و شهر اول این ۲ گزینه را ببینه کاربر

|44
temp
mahdi 2 years ago
parent 6df39b6968
commit 9775574162
  1. 6
      public/index.html
  2. 8
      src/components/Select/index.js
  3. 4
      src/views/Address/index.js

@ -8,7 +8,11 @@
<meta name="description" content="فروشگاه کتاب کمک آموزشی دانوین" /> <meta name="description" content="فروشگاه کتاب کمک آموزشی دانوین" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.svg" /> <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.svg" />
<script> <script>
window.t = (x) => x; const words = new Set();
window.t = (x) => {
words.add(x);
return x;
};
</script> </script>
<!-- <!--
manifest.json provides metadata used when your web app is installed on a manifest.json provides metadata used when your web app is installed on a

@ -11,6 +11,7 @@ function Select({
name, name,
defaultValue, defaultValue,
width = "w-1/2", width = "w-1/2",
selectProvince,
}) { }) {
console.log({ options }); console.log({ options });
return ( return (
@ -22,6 +23,11 @@ function Select({
onChange={(e) => onChange(name, e.target.value)} onChange={(e) => onChange(name, e.target.value)}
defaultValue={defaultValue} defaultValue={defaultValue}
> >
{selectProvince && (
<option value="" disabled selected hidden>
{selectProvince}
</option>
)}
{options.map((option, index) => ( {options.map((option, index) => (
<option <option
key={index} key={index}
@ -50,4 +56,6 @@ export default Select;
Select.defaultProps = { Select.defaultProps = {
options: ["Really", "Option 2", "Option 3"], options: ["Really", "Option 2", "Option 3"],
borderColor: "border-gray-300", borderColor: "border-gray-300",
selectProvince: false,
}; };

@ -523,6 +523,7 @@ export const Address = ({
<div className="flex flex-col lg:flex-row items-center gap-3 lg:gap-5 w-full"> <div className="flex flex-col lg:flex-row items-center gap-3 lg:gap-5 w-full">
<Select <Select
selectProvince={"استان"}
options={provinces.map((e) => ({ value: e.id, name: e.name }))} options={provinces.map((e) => ({ value: e.id, name: e.name }))}
name="provinceId" name="provinceId"
defaultValue={ defaultValue={
@ -546,6 +547,7 @@ export const Address = ({
{!cityLoading ? ( {!cityLoading ? (
// <div>fdfds</div> // <div>fdfds</div>
<Select <Select
selectProvince={"شهر"}
options={cities.map((e) => ({ value: e.id, name: e.name }))} options={cities.map((e) => ({ value: e.id, name: e.name }))}
name="cityId" name="cityId"
defaultValue={ defaultValue={
@ -579,7 +581,6 @@ export const Address = ({
</div> </div>
)} )}
</div> </div>
<Input <Input
width={isMobile ? "100%" : "50%"} width={isMobile ? "100%" : "50%"}
label={window.t("کد پستی")} label={window.t("کد پستی")}
@ -599,7 +600,6 @@ export const Address = ({
direction="ltr" direction="ltr"
maxLength={10} maxLength={10}
/> />
<div <div
className={`flex ${ className={`flex ${
profilePage ? "mt-10" : "lg:hidden" profilePage ? "mt-10" : "lg:hidden"

Loading…
Cancel
Save