diff --git a/src/components/Drawers.tsx b/src/components/Drawers.tsx index a6c2bf8..9366ec0 100644 --- a/src/components/Drawers.tsx +++ b/src/components/Drawers.tsx @@ -47,12 +47,13 @@ function Drawers() { if (payCartError) { if (payCartError.includes("insufficient funds: ")) { const notEnoughMoneyAmount = parseInt(payCartError.replace(/^.*insufficient\sfunds:\s(?=\d+$)/, "")); - setNotEnoughMoneyAmount(notEnoughMoneyAmount); } setLoading(false); + closeCartDrawer() + navigate("payment") return enqueueSnackbar(payCartError); } @@ -321,7 +322,7 @@ console.log('aaaaaaaaaaAAAAAAAAAAAAAA', (cart.appliedCartPurchasesDiscount?.Targ onClick={() => (notEnoughMoneyAmount === 0 ? !loading && handlePayClick() : handleReplenishWallet())} sx={{ mt: "25px", display: "block" }} > - {loading ? : "Оплатить"} + {loading ? : notEnoughMoneyAmount === 0 ? "Оплатить" : "Пополнить"} diff --git a/src/components/InputTextfield.tsx b/src/components/InputTextfield.tsx index 1df9cf4..68fc345 100644 --- a/src/components/InputTextfield.tsx +++ b/src/components/InputTextfield.tsx @@ -20,6 +20,8 @@ interface Props { FormInputSx?: SxProps; TextfieldProps: TextFieldProps; onChange: (e: React.ChangeEvent) => void; + onBlur?: () => void + onFocus?: () => void } export default function InputTextfield({ @@ -31,6 +33,8 @@ export default function InputTextfield({ TextfieldProps, color, FormInputSx, + onBlur = ()=>{}, + onFocus = ()=>{} }: Props) { const theme = useTheme() const upMd = useMediaQuery(theme.breakpoints.up("md")) @@ -45,6 +49,7 @@ export default function InputTextfield({ return ( )} { + onBlur() + }} + onFocus={(e) => { + onFocus() + }} {...TextfieldProps} fullWidth id={id} diff --git a/src/components/TotalPrice.tsx b/src/components/TotalPrice.tsx index fcd0a3f..4e0e86d 100644 --- a/src/components/TotalPrice.tsx +++ b/src/components/TotalPrice.tsx @@ -8,6 +8,7 @@ import { Loader } from "./Loader"; import { currencyFormatter } from "@root/utils/currencyFormatter"; import { payCart } from "@root/api/cart"; import { setUserAccount } from "@root/stores/user"; +import { useCart } from "@root/utils/hooks/useCart"; interface Props { priceBeforeDiscounts: number; @@ -19,6 +20,7 @@ export default function TotalPrice({ priceAfterDiscounts, priceBeforeDiscounts, const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); const isMobile = useMediaQuery(theme.breakpoints.down(550)); + const cart = useCart(); const [notEnoughMoneyAmount, setNotEnoughMoneyAmount] = useState(0); const [loading, setLoading] = useState(false); const navigate = useNavigate(); @@ -162,6 +164,7 @@ export default function TotalPrice({ priceAfterDiscounts, priceBeforeDiscounts, )} + ) } @@ -157,8 +213,8 @@ function VerificationIndicator({ verificationStatus, sx, }: { - verificationStatus: VerificationStatus; - sx?: SxProps; + verificationStatus: VerificationStatus; + sx?: SxProps; }) { return ( void; +} -export default function UserFields () { +export default function UserFields({ + loginPasswordFocus, + setLoginPasswordFocus +}: Props) { const theme = useTheme() const upSm = useMediaQuery(theme.breakpoints.up("sm")) const upMd = useMediaQuery(theme.breakpoints.up("md")) - const fields = useUserStore((state) => state.settingsFields) + const { settingsFields, user } = useUserStore((state) => state) + - console.log("fields") - const textFieldProps = { gap: upMd ? "16px" : "10px", color: "#F2F3F7", bold: true, } - return( + return ( setSettingsField("firstname", e.target.value)} id="firstname" @@ -46,9 +52,9 @@ export default function UserFields () { setSettingsField("secondname", e.target.value)} id="secondname" @@ -58,9 +64,9 @@ export default function UserFields () { setSettingsField("middlename", e.target.value)} id="middlename" @@ -70,9 +76,9 @@ export default function UserFields () { setSettingsField("orgname", e.target.value)} id="orgname" @@ -82,21 +88,27 @@ export default function UserFields () { setSettingsField("email", e.target.value)} + onFocus={() => { + setLoginPasswordFocus(true) + }} + onBlur={() => { + setLoginPasswordFocus(false) + }} id="email" - label="E-mail" + label="Изменить E-mail" {...textFieldProps} /> setSettingsField("phoneNumber", e.target.value)} id="phoneNumber" @@ -106,14 +118,21 @@ export default function UserFields () { { + setLoginPasswordFocus(true) + }} + onBlur={() => { + setLoginPasswordFocus(false) + }} + onChange={(e) => setSettingsField("password", e.target.value)} id="password" - label="Пароль" + label="Изменить пароль" {...textFieldProps} /> diff --git a/src/pages/AccountSettings/onChangeLoginPassword.tsx b/src/pages/AccountSettings/onChangeLoginPassword.tsx new file mode 100644 index 0000000..9ce1bb1 --- /dev/null +++ b/src/pages/AccountSettings/onChangeLoginPassword.tsx @@ -0,0 +1,55 @@ +import { Box, Button, Modal, Typography, useMediaQuery, useTheme } from "@mui/material" + + +interface Props { + type: "email" | "password" | "all" | ""; + ok: () => void; + cancel: () => void; +} + +export const OnChangeLoginPassword = ({ + type, + ok, + cancel +}: Props) => { + const theme = useTheme() + const isMobile = useMediaQuery(theme.breakpoints.down(600)) + + return ( + + + + Вы уверены, что хотите изменить + {type === "all" || type === "email" ? " почту " : ""} + {type === "all" ? "и" : ""} + {type === "all" || type === "password" ? " пароль " : ""} + ? + + + + + + + + + ) +} \ No newline at end of file diff --git a/src/utils/parse-error.ts b/src/utils/parse-error.ts index 3eb0b41..fbef7d3 100644 --- a/src/utils/parse-error.ts +++ b/src/utils/parse-error.ts @@ -15,7 +15,8 @@ const translateMessage: Record = { "field is empty": "Поле \"Номер телефона\" не заполнено", "user with this email or login is exist": "Пользователь уже существует", "user with this login is exist": "Пользователь с таким логином уже существует", - "unauthorized": "Ссылка просрочена" + "unauthorized": "Ссылка просрочена", + "insufficient funds: 910000": "Недостаточно средств" } export const parseAxiosError = (nativeError: unknown): [string, number?] => {