From 04056b767d136762c860e646893dff9ea98591ee Mon Sep 17 00:00:00 2001 From: innovatixhub Date: Mon, 25 Nov 2024 10:54:09 -0800 Subject: [PATCH] Add files via upload --- .../billingdetails-input/BillingInput.jsx | 38 ++++++++++++++++++ .../BillingInput.module.scss | 38 ++++++++++++++++++ .../billingdetails-input/BillingInputs.jsx | 40 +++++++++++++++++++ .../BillingInputs.module.scss | 7 ++++ 4 files changed, 123 insertions(+) create mode 100644 src/componants/checkout-page/billingdetails-input/BillingInput.jsx create mode 100644 src/componants/checkout-page/billingdetails-input/BillingInput.module.scss create mode 100644 src/componants/checkout-page/billingdetails-input/BillingInputs.jsx create mode 100644 src/componants/checkout-page/billingdetails-input/BillingInputs.module.scss diff --git a/src/componants/checkout-page/billingdetails-input/BillingInput.jsx b/src/componants/checkout-page/billingdetails-input/BillingInput.jsx new file mode 100644 index 0000000..142d71d --- /dev/null +++ b/src/componants/checkout-page/billingdetails-input/BillingInput.jsx @@ -0,0 +1,38 @@ +import s from "./BillingInput.module.scss"; + +const BillingInput = ({ inputData }) => { + const { + label, + placeholder, + name, + required, + type, + value, + onChange, + autoComplete, + } = inputData; + + const inputAttributes = { + id: name, + name, + type: type || "text", + placeholder: placeholder || "", + required: required || false, + "aria-required": required, + value, + onChange, + autoComplete: autoComplete ? "on" : "off", + }; + + const redStarClass = required ? s.redStar : ""; + + return ( +
+ + +
+ ); +}; +export default BillingInput; diff --git a/src/componants/checkout-page/billingdetails-input/BillingInput.module.scss b/src/componants/checkout-page/billingdetails-input/BillingInput.module.scss new file mode 100644 index 0000000..3ed400b --- /dev/null +++ b/src/componants/checkout-page/billingdetails-input/BillingInput.module.scss @@ -0,0 +1,38 @@ +.input { + display: flex; + flex-direction: column; + gap: 10px; +} + +.input>label { + color: #595959; +} + +.input .redStar::after { + content: "*"; + color: var(--red); +} + +.input>input { + outline: none; + border: none; + border-radius: 4px; + padding: 14px 12px; + background-color: var(--very-light-gray2); + border: solid 2px var(--very-light-gray2); + transition: border-color .2s; + + &:hover, + &:focus { + border-color: var(--medium-light-gray); + } + + &[class=invalid] { + background-color: #ffdada; + border-color: var(--red); + + &::placeholder { + color: var(--primary); + } + } +} \ No newline at end of file diff --git a/src/componants/checkout-page/billingdetails-input/BillingInputs.jsx b/src/componants/checkout-page/billingdetails-input/BillingInputs.jsx new file mode 100644 index 0000000..e573289 --- /dev/null +++ b/src/componants/checkout-page/billingdetails-input/BillingInputs.jsx @@ -0,0 +1,40 @@ +import { useTranslation } from "react-i18next"; +import { billingInputsData } from "src/Data/staticData"; +import BillingInput from "./BillingInput"; +import s from "./BillingInputs.module.scss"; + +const BillingInputs = ({ inputsData }) => { + const { billingValues, handleChange } = inputsData; + const { t } = useTranslation(); + + function onChange(event, name) { + const isPhoneInput = name === "phoneNumber"; + const isNumber = !isNaN(+event.nativeEvent.data); + const isPaste = event.nativeEvent.inputType === "insertFromPaste"; + + if (isPhoneInput && !isNumber) return; + if (isPhoneInput && isPaste) return; + + handleChange(event); + } + + return ( +
+ {billingInputsData.map( + ({ translationKey, name, type, required, id, regex }) => { + const inputData = { + value: billingValues[translationKey], + name, + label: t(`inputsLabels.${translationKey}`), + required, + type, + onChange: (event) => onChange(event, name), + }; + + return ; + } + )} +
+ ); +}; +export default BillingInputs; diff --git a/src/componants/checkout-page/billingdetails-input/BillingInputs.module.scss b/src/componants/checkout-page/billingdetails-input/BillingInputs.module.scss new file mode 100644 index 0000000..3448021 --- /dev/null +++ b/src/componants/checkout-page/billingdetails-input/BillingInputs.module.scss @@ -0,0 +1,7 @@ +@import "src/Styles/mixins"; + +.inputs { + display: flex; + flex-direction: column; + gap: 26px; +} \ No newline at end of file