diff --git a/web-components/src/components/inputs/new/CustomSelect/CustomSelect.Placeholder.tsx b/web-components/src/components/inputs/new/CustomSelect/CustomSelect.Placeholder.tsx index 37c8222397..a4e569582c 100644 --- a/web-components/src/components/inputs/new/CustomSelect/CustomSelect.Placeholder.tsx +++ b/web-components/src/components/inputs/new/CustomSelect/CustomSelect.Placeholder.tsx @@ -7,7 +7,7 @@ export function Placeholder({ isOpen, options, selectedOption, - OptionComponent, + OptionComponent = () => <>, ariaLabel, }: { setIsOpen: (isOpen: boolean) => void; @@ -24,8 +24,8 @@ export function Placeholder({ className="inline-flex justify-center w-full border-none px-4 py-2 bg-grey-0 text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none" onClick={() => setIsOpen(!isOpen)} > - {'value' in options[0] ? ( - options.find(opt => opt.value === selectedOption)?.label + {options[0] && 'value' in options[0] ? ( + options.find(opt => opt?.value === selectedOption)?.label ) : ( )} diff --git a/web-components/src/components/inputs/new/CustomSelect/CustomSelect.tsx b/web-components/src/components/inputs/new/CustomSelect/CustomSelect.tsx index 7b9355685b..3bc896b9b0 100644 --- a/web-components/src/components/inputs/new/CustomSelect/CustomSelect.tsx +++ b/web-components/src/components/inputs/new/CustomSelect/CustomSelect.tsx @@ -20,7 +20,7 @@ const CustomSelect = ({ const [isOpen, setIsOpen] = useState(false); const [selectedOption, setSelectedOption] = useState(defaultOption); const [OptionComponent, setOptionComponent] = useState( - () => options[0].component?.element as ComponentType, + () => options?.[0]?.component?.element as ComponentType, ); const handleSelect = (option: string) => { diff --git a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx index a571773cf9..98ec354e50 100644 --- a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx +++ b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx @@ -12,7 +12,10 @@ import { spendingCapAtom, } from 'pages/BuyCredits/BuyCredits.atoms'; import { PAYMENT_OPTIONS } from 'pages/BuyCredits/BuyCredits.constants'; -import { getCreditsAvailableBannerText } from 'pages/BuyCredits/BuyCredits.utils'; +import { + getCreditsAvailableBannerText, + getOrderedSellOrders, +} from 'pages/BuyCredits/BuyCredits.utils'; import { findDisplayDenom } from '../DenomLabel/DenomLabel.utils'; import { @@ -42,8 +45,6 @@ export const CreditsAmount = ({ cryptoCurrencies, allowedDenoms, creditTypePrecision, - card, - orderedSellOrders, }: CreditsAmountProps) => { const { _ } = useLingui(); @@ -54,6 +55,15 @@ export const CreditsAmount = ({ const [spendingCap, setSpendingCap] = useAtom(spendingCapAtom); const paymentOption = useAtomValue(paymentOptionAtom); + const card = useMemo( + () => paymentOption === PAYMENT_OPTIONS.CARD, + [paymentOption], + ); + const orderedSellOrders = useMemo( + () => getOrderedSellOrders(card, cardSellOrders, filteredCryptoSellOrders), + [card, cardSellOrders, filteredCryptoSellOrders], + ); + const displayDenom = useMemo( () => findDisplayDenom({ diff --git a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.types.tsx b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.types.tsx index c6b84c6cad..32c31be521 100644 --- a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.types.tsx +++ b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.types.tsx @@ -14,7 +14,7 @@ export type Currency = { export interface CreditsAmountProps { creditsAvailable: number; setCreditsAvailable: UseStateSetter; - filteredCryptoSellOrders: Array | undefined; + filteredCryptoSellOrders: Array; cardSellOrders: Array; cryptoCurrencies: Currency[]; allowedDenoms?: AllowedDenoms; diff --git a/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.constants.ts b/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.constants.ts new file mode 100644 index 0000000000..60b51f3080 --- /dev/null +++ b/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.constants.ts @@ -0,0 +1 @@ +export const KEPLR_LOGIN_REQUIRED = 'keplr-login-required'; diff --git a/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.tsx b/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.tsx new file mode 100644 index 0000000000..08b275e24a --- /dev/null +++ b/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.tsx @@ -0,0 +1,71 @@ +import { Box } from '@mui/material'; + +import ContainedButton from 'web-components/src/components/buttons/ContainedButton'; +import OutlinedButton from 'web-components/src/components/buttons/OutlinedButton'; +import Card from 'web-components/src/components/cards/Card'; +import SellOrderNotFoundIcon from 'web-components/src/components/icons/SellOrderNotFoundIcon'; +import Modal from 'web-components/src/components/modal'; +import { Title } from 'web-components/src/components/typography'; + +import { UseStateSetter } from 'types/react/use-state'; + +import { + BuyWarningModalContent, + BuyWarningModalStateType, +} from './BuyWarningModal.types'; + +interface BuyWarningModalProps extends BuyWarningModalContent { + warningModalState: BuyWarningModalStateType; + onClose: UseStateSetter; + handleClick: (action: string | null) => void; +} + +export const BuyWarningModal = ({ + modalContent, + warningModalState, + onClose, + handleClick, +}: BuyWarningModalProps) => { + const { title, content, buttons } = modalContent; + return ( + onClose({ ...warningModalState, openModal: false })} + className="w-[560px] !py-40 !px-30" + > + + + + {title} + + {content} + {buttons?.map((button, index) => { + return button.type === 'outlined' ? ( + handleClick(button.action)} + className={`h-[49px] ${ + buttons.find(button => button.type === 'contained') + ? 'w-[90%]' + : '' + }`} + > + {button.text} + + ) : ( + handleClick(button.action)} + key={index} + className={`text-lg w-[90%] h-[49px] ${ + buttons.length > 1 ? 'mb-20' : '' + }`} + > + {button.text} + + ); + })} + + + ); +}; diff --git a/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.types.ts b/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.types.ts new file mode 100644 index 0000000000..04b257b7ae --- /dev/null +++ b/web-marketplace/src/components/organisms/BuyWarningModal/BuyWarningModal.types.ts @@ -0,0 +1,19 @@ +export type BuyWarningModalStateType = { + openModal: boolean; + creditsAvailable: number; +}; +type BuyWarningModalButtonType = 'outlined' | 'contained'; + +interface BuyWarningModalButton { + text: string; + action: string | null; + type: BuyWarningModalButtonType; +} + +export interface BuyWarningModalContent { + modalContent: { + title: string; + content: React.ReactNode; + buttons: BuyWarningModalButton[]; + }; +} diff --git a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx index 8447282f5c..dfb7b2a9ad 100644 --- a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx +++ b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx @@ -255,6 +255,9 @@ export const ChooseCreditsForm = React.memo( PAYMENT_OPTIONS.CARD, ); } + if (!cardSellOrders.length && paymentOption === PAYMENT_OPTIONS.CARD) { + handlePaymentOptions(PAYMENT_OPTIONS.CRYPTO); + } }, [cardSellOrders.length, initialPaymentOption]); // just run this once useEffect(() => { diff --git a/web-marketplace/src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.SelectAccountModal.tsx b/web-marketplace/src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.SelectAccountModal.tsx index 50c930d1b3..6fc564b93c 100644 --- a/web-marketplace/src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.SelectAccountModal.tsx +++ b/web-marketplace/src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.SelectAccountModal.tsx @@ -55,6 +55,7 @@ export const SelectAccountModal = ({
{accounts.map(account => (
Regen Registry programor are not associated with another known registry. <1/><2/>To create your own credits, <3>learn more in our docs." msgstr "" -#: src/pages/BuyCredits/BuyCredits.constants.ts:18 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:48 msgid "Complete" msgstr "" @@ -1109,7 +1128,7 @@ msgid "Congrats! Your bridge has been initiated" msgstr "" #: src/components/organisms/ConfirmationModal.tsx:90 -#: src/pages/BuyCredits/BuyCredits.constants.ts:12 +#: src/pages/BuyCredits/BuyCredits.constants.ts:11 msgid "Congrats! Your purchase was successful." msgstr "" @@ -1182,6 +1201,7 @@ msgstr "" msgid "Copy link to project page" msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:552 #: src/lib/constants/shared.constants.tsx:58 #: src/lib/constants/shared.constants.tsx:160 msgid "Country" @@ -1238,6 +1258,10 @@ msgstr "" msgid "Created by" msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:319 +msgid "credit" +msgstr "" + #: src/components/organisms/CreditActivityTable/CreditActivityTable.tsx:147 msgid "credit activity table" msgstr "" @@ -1272,11 +1296,11 @@ msgstr "" msgid "Credit Batch Info" msgstr "" -#: src/components/organisms/CreditBatches/CreditBatches.tsx:127 +#: src/components/organisms/CreditBatches/CreditBatches.tsx:126 msgid "credit batch table" msgstr "" -#: src/components/organisms/CreditBatches/CreditBatches.tsx:243 +#: src/components/organisms/CreditBatches/CreditBatches.tsx:242 #: src/components/organisms/CreditBatchesSection/CreditBatchesSection.tsx:24 #: src/pages/Dashboard/Dashboard.constants.tsx:42 #: src/pages/EcocreditsByAccount/EcocreditsByAccount.tsx:93 @@ -1360,7 +1384,7 @@ msgstr "" msgid "credit name" msgstr "" -#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:268 +#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:269 msgid "Credit prices vary. By default the lowest priced credits will be purchased first." msgstr "" @@ -1389,7 +1413,8 @@ msgstr "" msgid "credits" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:71 +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:226 +#: src/components/organisms/Order/Order.Summary.tsx:68 msgid "Credits" msgstr "" @@ -1397,13 +1422,13 @@ msgstr "" msgid "Credits are held in escrow when a sell order is created, and taken out of escrow when the sell order is either cancelled, updated with a reduced quantity, or processed." msgstr "" -#: src/components/molecules/CreditsAmount/CreditsAmount.Header.tsx:46 +#: src/components/molecules/CreditsAmount/CreditsAmount.Header.tsx:48 #: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.AdvanceSettings.tsx:71 #: src/lib/constants/shared.constants.tsx:182 msgid "credits available" msgstr "" -#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:106 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:101 msgid "Credits Available" msgstr "" @@ -1455,7 +1480,7 @@ msgstr "" msgid "Credits issuance is calculated based on a weighted scale between 20 and 50 years." msgstr "" -#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:83 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:82 msgid "Credits issued" msgstr "" @@ -1467,24 +1492,20 @@ msgstr "" msgid "Credits purchased with crypto can be purchased in either a retired or tradable state." msgstr "" -#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:82 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:81 msgid "Credits Registered" msgstr "" #: src/components/molecules/BatchTotalsGrid.tsx:46 -#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:128 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:123 msgid "Credits Retired" msgstr "" #: src/components/molecules/BatchTotalsGrid.tsx:39 -#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:106 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:101 msgid "Credits Tradable" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:119 -msgid "Credits were purchased in a tradable format and were not retired" -msgstr "" - #: src/components/organisms/UserCredits.tsx:167 msgid "credits you purchased" msgstr "" @@ -1534,7 +1555,7 @@ msgid "Custom url" msgstr "" #: src/components/organisms/PaymentInfoForm/PaymentInfoForm.CustomerInfo.tsx:51 -#: src/pages/BuyCredits/BuyCredits.constants.ts:15 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:42 msgid "Customer info" msgstr "" @@ -1558,7 +1579,7 @@ msgstr "" msgid "Date of upload" msgstr "" -#: src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.SelectAccountModal.tsx:65 +#: src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.SelectAccountModal.tsx:66 #: src/components/organisms/RegistryLayout/RegistryLayout.constants.ts:12 msgid "default avatar" msgstr "" @@ -1573,6 +1594,7 @@ msgstr "" #: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:152 #: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:55 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:77 msgid "department" msgstr "" @@ -1584,7 +1606,7 @@ msgstr "" #: src/components/organisms/EditProfileForm/EditProfileForm.tsx:207 #: src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.tsx:155 #: src/pages/Description/Description.tsx:48 -#: src/pages/ProjectReview/ProjectReview.tsx:224 +#: src/pages/ProjectReview/ProjectReview.tsx:225 msgid "Description" msgstr "" @@ -1771,7 +1793,7 @@ msgstr "" msgid "edit profile" msgstr "" -#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:23 +#: src/components/organisms/AdminNavigation/AdminNavigation.constants.tsx:38 #: src/components/organisms/RolesForm/components/ProfileModal/ProfileModal.tsx:115 #: src/pages/Dashboard/Dashboard.constants.tsx:54 msgid "Edit profile" @@ -1835,7 +1857,7 @@ msgstr "" msgid "Endangered" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:164 +#: src/components/organisms/Order/Order.Summary.tsx:148 msgid "ending in" msgstr "" @@ -1849,6 +1871,7 @@ msgstr "" #: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:154 #: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:60 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:82 msgid "environmental authority" msgstr "" @@ -1873,7 +1896,7 @@ msgstr "" msgid "Examples of a retirement reason include: “company travel 2025”, “offsetting my personal footprint”, or the name of a specific person or organization." msgstr "" -#: src/components/organisms/Order/Order.tsx:125 +#: src/components/organisms/Order/Order.tsx:133 msgid "Expected delivery date" msgstr "" @@ -1966,6 +1989,10 @@ msgstr "" msgid "Filters" msgstr "" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:114 +msgid "find another credit card project" +msgstr "" + #: src/components/molecules/PlanStepper.tsx:18 #: src/components/organisms/CreditClassForms/CreateCreditClassForm.tsx:40 #: src/components/organisms/CreditClassForms/CreateCreditClassForm.tsx:41 @@ -2039,10 +2066,6 @@ msgstr "" msgid "Hash" msgstr "" -#: src/pages/Projects/AllProjects/AllProjects.TerrasosCredits.tsx:59 -msgid "hectares" -msgstr "" - #: src/components/organisms/BasicInfoForm/BasicInfoForm.tsx:193 msgid "Hectares" msgstr "" @@ -2137,7 +2160,7 @@ msgstr "" msgid "Impact" msgstr "" -#: src/components/molecules/CreditsAmount/CreditsAmount.Header.tsx:51 +#: src/components/molecules/CreditsAmount/CreditsAmount.Header.tsx:53 msgid "in" msgstr "" @@ -2174,10 +2197,6 @@ msgstr "" msgid "Input an email address to receive a receipt of your purchase.<0>Take note: we will email you a prompt to associate this email with your account for easier future access. This is entirely optional." msgstr "" -#: src/pages/BuyCredits/BuyCredits.constants.ts:8 -msgid "Insufficient balance" -msgstr "" - #: src/lib/constants/shared.constants.tsx:70 msgid "Invalid date" msgstr "" @@ -2219,7 +2238,7 @@ msgstr "" msgid "join the community" msgstr "" -#: src/pages/ProjectReview/ProjectReview.tsx:221 +#: src/pages/ProjectReview/ProjectReview.tsx:222 msgid "Jurisdiction" msgstr "" @@ -2252,7 +2271,7 @@ msgstr "" msgid "Last Updated:" msgstr "" -#: src/components/templates/ProjectDetails/hooks/useSeo.ts:62 +#: src/components/templates/ProjectDetails/hooks/useSeo.ts:56 msgid "Learn about {creditClassName} credits sourced from {accountName} in {projectAddress}." msgstr "" @@ -2292,6 +2311,9 @@ msgid "Learn more about wallets in our <0>user guide." msgstr "" #: src/components/organisms/BasketOverview/BasketOverview.Tooltip.tsx:16 +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:440 +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:469 +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:491 #: src/pages/ChooseCreditClass/ChooseCreditClass.config.tsx:10 msgid "Learn more»" msgstr "" @@ -2321,7 +2343,7 @@ msgid "listen to podcast" msgstr "" #: src/components/organisms/MediaForm/MediaForm.constants.ts:24 -#: src/pages/ProjectReview/ProjectReview.tsx:281 +#: src/pages/ProjectReview/ProjectReview.tsx:282 msgid "Loading video player..." msgstr "" @@ -2336,7 +2358,7 @@ msgstr "" #: src/components/organisms/EditFileForm/EditFileForm.tsx:135 #: src/lib/constants/shared.constants.tsx:53 #: src/pages/ProjectLocation/ProjectLocation.tsx:44 -#: src/pages/ProjectReview/ProjectReview.tsx:214 +#: src/pages/ProjectReview/ProjectReview.tsx:215 msgid "Location" msgstr "" @@ -2446,7 +2468,7 @@ msgid "media" msgstr "" #: src/pages/Media/Media.tsx:76 -#: src/pages/ProjectReview/ProjectReview.tsx:239 +#: src/pages/ProjectReview/ProjectReview.tsx:240 msgid "Media" msgstr "" @@ -2470,7 +2492,7 @@ msgstr "" #: src/components/organisms/CreditClassForms/CreditClassForm.tsx:105 #: src/components/organisms/CreditClassForms/CreditClassReview.tsx:40 #: src/pages/ProjectMetadata/ProjectMetadata.tsx:72 -#: src/pages/ProjectReview/ProjectReview.tsx:318 +#: src/pages/ProjectReview/ProjectReview.tsx:319 msgid "Metadata" msgstr "" @@ -2559,15 +2581,14 @@ msgid "Must have recipients" msgstr "" #: src/pages/Dashboard/Dashboard.constants.tsx:73 -#~ msgid "my orders" -#~ msgstr "" +msgid "my orders" +msgstr "" -#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:46 -#: src/pages/Dashboard/Dashboard.constants.tsx:79 +#: src/pages/Dashboard/Dashboard.constants.tsx:87 msgid "My orders" msgstr "" -#: src/pages/Dashboard/Dashboard.constants.tsx:87 +#: src/pages/Dashboard/Dashboard.constants.tsx:95 msgid "My prefinance projects" msgstr "" @@ -2582,8 +2603,8 @@ msgid "Name of document" msgstr "" #: src/components/organisms/Order/Order.Summary.tsx:143 -#~ msgid "name on card" -#~ msgstr "" +msgid "name on card" +msgstr "" #: src/components/organisms/AdditionalityForm.tsx:214 msgid "Natural ecosystem, unmanaged" @@ -2648,7 +2669,7 @@ msgstr "" msgid "No credit batches to display" msgstr "" -#: src/components/organisms/CreditBatches/CreditBatches.tsx:107 +#: src/components/organisms/CreditBatches/CreditBatches.tsx:106 msgid "No credits issued" msgstr "" @@ -2755,14 +2776,6 @@ msgstr "" msgid "Order Summary" msgstr "" -#: src/pages/Dashboard/Dashboard.constants.tsx:73 -msgid "orders" -msgstr "" - -#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:43 -msgid "Orders" -msgstr "" - #: src/components/organisms/EditProfileForm/EditProfileForm.constants.tsx:40 msgid "Organization" msgstr "" @@ -2811,16 +2824,16 @@ msgstr "" msgid "payment" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:172 +#: src/components/organisms/Order/Order.Summary.tsx:156 msgid "payment currency" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:155 +#: src/components/organisms/Order/Order.Summary.tsx:139 msgid "payment info" msgstr "" #: src/components/organisms/PaymentInfoForm/PaymentInfoForm.PaymentInfo.tsx:45 -#: src/pages/BuyCredits/BuyCredits.constants.ts:14 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:41 msgid "Payment info" msgstr "" @@ -2879,6 +2892,10 @@ msgstr "" msgid "Please enter a location for the retirement of these credits. This prevents double counting of credits in different locations." msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:536 +msgid "Please enter a location for the retirement of these credits. This prevents double counting of credits in different locations. These credits will auto-retire." +msgstr "" + #: src/lib/constants/shared.constants.tsx:68 msgid "Please enter a valid amount" msgstr "" @@ -3031,7 +3048,7 @@ msgstr "" msgid "price per credit" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:74 +#: src/components/organisms/Order/Order.Summary.tsx:71 msgid "Price per credit" msgstr "" @@ -3067,11 +3084,11 @@ msgstr "" msgid "Proceed with caution: this cannot be undone!" msgstr "" -#: src/components/organisms/RegistryLayout/RegistryLayout.config.tsx:183 +#: src/pages/Dashboard/Dashboard.constants.tsx:81 msgid "profile" msgstr "" -#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:20 +#: src/components/organisms/AdminNavigation/AdminNavigation.constants.tsx:35 #: src/pages/ProfileEdit/ProfileEdit.constants.tsx:7 msgid "Profile" msgstr "" @@ -3108,7 +3125,7 @@ msgstr "" #: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:86 #: src/components/organisms/CreditBatches/CreditBatches.config.ts:18 -#: src/pages/BuyCredits/BuyCredits.utils.tsx:157 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:124 #: src/pages/Dashboard/MyEcocredits/hooks/useBasketPutSubmit.tsx:105 #: src/pages/Dashboard/MyEcocredits/hooks/useCreateSellOrderSubmit.tsx:139 #: src/pages/Dashboard/MyEcocredits/hooks/useCreditRetireSubmit.tsx:113 @@ -3134,8 +3151,9 @@ msgstr "" #: src/components/organisms/SellOrdersTable/SellOrdersTable.constants.ts:20 msgid "PROJECT" msgstr "" +msgstr "" -#: src/components/organisms/ProjectTopSection/ProjectTopSection.tsx:175 +#: src/components/organisms/ProjectTopSection/ProjectTopSection.tsx:176 msgid "Project {onChainProjectId}" msgstr "" @@ -3279,6 +3297,7 @@ msgstr "" #: src/components/templates/ProjectDetails/ProjectDetails.PrefinanceTimeline.tsx:81 msgid "PROJECTED:" msgstr "" +msgstr "" #: src/components/organisms/ProjectCardsSection/ProjectCardsSection.tsx:81 #: src/components/organisms/RegistryLayout/RegistryLayout.config.tsx:41 @@ -3305,7 +3324,7 @@ msgstr "" msgid "Publications" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:190 +#: src/components/organisms/Order/Order.Summary.tsx:174 msgid "purchase date" msgstr "" @@ -3313,6 +3332,10 @@ msgstr "" msgid "purchase now" msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:416 +msgid "Purchase options" +msgstr "" + #: src/components/organisms/SellOrdersTable/SellOrdersTable.constants.ts:48 msgid "PURCHASE OPTIONS" msgstr "" @@ -3381,7 +3404,7 @@ msgstr "" msgid "Regen impact address" msgstr "" -#: src/components/templates/ProjectDetails/hooks/useSeo.ts:56 +#: src/components/templates/ProjectDetails/hooks/useSeo.ts:52 #: src/siteMetadata.ts:4 msgid "Regen Marketplace" msgstr "" @@ -3405,6 +3428,7 @@ msgstr "" #: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:151 #: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:53 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:75 msgid "region" msgstr "" @@ -3490,6 +3514,10 @@ msgstr "" msgid "Retirable" msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.utils.tsx:185 +msgid "RETIRABLE ONLY" +msgstr "" + #: src/components/organisms/CreditRetireForm/CreditRetireForm.tsx:136 #: src/components/organisms/Modals/CreditRetireModal/CreditRetireModal.constants.ts:3 msgid "Retire" @@ -3500,6 +3528,7 @@ msgid "Retire all credits upon transfer" msgstr "" #: src/components/molecules/CreditsAmount/CreditsAmount.constants.ts:11 +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:428 msgid "Retire credits now" msgstr "" @@ -3512,11 +3541,11 @@ msgstr "" msgid "Retired by" msgstr "" -#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.constants.ts:6 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.constants.ts:5 msgid "Retired credits have been taken out of circulation permanently and cannot be sold to anyone else." msgstr "" -#: src/pages/BuyCredits/BuyCredits.constants.ts:16 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:46 msgid "Retirement" msgstr "" @@ -3532,7 +3561,7 @@ msgstr "" msgid "Retirement date" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:111 +#: src/components/organisms/Order/Order.Summary.tsx:108 msgid "Retirement Info" msgstr "" @@ -3541,7 +3570,7 @@ msgstr "" msgid "Retirement is permanent and non-reversible." msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:135 +#: src/components/organisms/Order/Order.Summary.tsx:120 #: src/components/organisms/RetirementCertificatesTable/RetirementCertificatesTable.headers.tsx:54 #: src/features/ecocredit/CreateBatchBySteps/CreateBatchMultiStepForm/Review.tsx:139 #: src/pages/Certificate/Certificate.constants.ts:18 @@ -3553,12 +3582,13 @@ msgstr "" msgid "Retirement note" msgstr "" -#: src/pages/BuyCredits/BuyCredits.utils.tsx:56 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:61 msgid "Retirement permanently removes used credits from circulation to prevent their reuse, ensuring that the environmental benefit claimed is real and not double-counted." msgstr "" #: src/components/organisms/AgreePurchaseForm/AgreePurchaseForm.Retirement.tsx:61 -#: src/components/organisms/Order/Order.Summary.tsx:129 +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:501 +#: src/components/organisms/Order/Order.Summary.tsx:118 #: src/lib/constants/shared.constants.tsx:148 #: src/pages/Certificate/Certificate.constants.ts:17 msgid "Retirement reason" @@ -3616,7 +3646,7 @@ msgstr "" msgid "Save my credit card info for next time" msgstr "" -#: src/pages/Dashboard/Dashboard.constants.tsx:95 +#: src/pages/Dashboard/Dashboard.constants.tsx:103 msgid "Saved payment info" msgstr "" @@ -3630,6 +3660,10 @@ msgstr "" msgid "SDGs" msgstr "" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:144 +msgid "search for new credits" +msgstr "" + #: src/pages/CreditClassDetails/CreditClassDetails.AdditionalInfo.tsx:88 msgid "sectoral scopes" msgstr "" @@ -3678,8 +3712,8 @@ msgstr "" msgid "Select all" msgstr "" -#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:252 -#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:253 +#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:254 +#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:255 msgid "Select option" msgstr "" @@ -3687,6 +3721,7 @@ msgstr "" msgid "Sell" msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:281 #: src/pages/Marketplace/Storefront/hooks/useCheckSellOrderAvailabilty.tsx:48 msgid "Sell order" msgstr "" @@ -3746,7 +3781,7 @@ msgstr "" msgid "settings" msgstr "" -#: src/components/organisms/AdminNavigation/AdminNavigation.utils.tsx:28 +#: src/components/organisms/AdminNavigation/AdminNavigation.constants.tsx:43 #: src/pages/Dashboard/Dashboard.constants.tsx:62 #: src/pages/Settings/Settings.tsx:52 msgid "Settings" @@ -3839,6 +3874,18 @@ msgstr "" msgid "Sold Out" msgstr "" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:131 +msgid "Sorry, another user has purchased all of the available credits from this project" +msgstr "" + +#: src/pages/BuyCredits/BuyCredits.utils.tsx:102 +msgid "Sorry, another user has purchased all of the USD credits you selected!" +msgstr "" + +#: src/pages/BuyCredits/BuyCredits.utils.tsx:156 +msgid "Sorry, another user has purchased some or all of the credits you selected!" +msgstr "" + #: src/config/errors.tsx:29 msgid "Sorry, someone has purchased this sell order!" msgstr "" @@ -3860,6 +3907,7 @@ msgstr "" #: src/lib/constants/shared.constants.tsx:91 msgid "Sorry, your transaction was not successful." msgstr "" +msgstr "" #: src/pages/Projects/AllProjects/AllProjects.tsx:288 msgid "Sort by:" @@ -3941,6 +3989,7 @@ msgstr "" #: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:158 #: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:70 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:92 msgid "sub-watershed" msgstr "" @@ -4026,7 +4075,6 @@ msgstr "" msgid "terms of service" msgstr "" -#: src/components/organisms/RegistryLayout/RegistryLayout.constants.ts:29 #: src/components/organisms/TerrasosHeader/TerrasosHeader.constants.ts:7 msgid "Terrasos Logo" msgstr "" @@ -4121,6 +4169,10 @@ msgstr "" msgid "The retirement location can be where you live or your business operates." msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:477 +msgid "The seller of these credits has chosen to only allow for immediate retiring of credits. These credits cannot be purchased as a tradable asset." +msgstr "" + #: src/pages/CreditClassDetails/CreditClassDetailsSimple/CreditClassDetailsSimple.constants.ts:4 msgid "The structure, procedures and requirements for project registration, the quantification, monitoring, reporting and verification (MRV), and issuance of credits related to a certain credit type." msgstr "" @@ -4129,10 +4181,6 @@ msgstr "" msgid "The total amount of credits that were issued to this project." msgstr "" -#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.constants.ts:4 -msgid "The total amount of credits that were registered to this project." -msgstr "" - #: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.constants.ts:5 #: src/pages/Projects/AllProjects/AllProjects.constants.ts:4 msgid "There are currently no open sell orders for this project." @@ -4146,10 +4194,18 @@ msgstr "" msgid "These credits are currently sold out. More may become available in the future." msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:453 +msgid "These credits will be a tradable asset. They can be retired later via Regen Marketplace." +msgstr "" + #: src/components/molecules/CreditsAmount/CreditsAmount.constants.ts:19 msgid "These credits will be a tradeable asset. They can be retired later via Regen Marketplace." msgstr "" +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:431 +msgid "These credits will be retired upon purchase and will not be tradable. Retirement is permanent and non-reversible." +msgstr "" + #: src/components/molecules/CreditsAmount/CreditsAmount.constants.ts:12 msgid "These credits will be retired upon purchase and will not be tradeable. Retirement is permanent and non-reversible." msgstr "" @@ -4315,11 +4371,11 @@ msgid "total credits you have purchased" msgstr "" #: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:130 -#: src/components/organisms/Order/Order.Summary.tsx:94 +#: src/components/organisms/Order/Order.Summary.tsx:91 msgid "total price" msgstr "" -#: src/pages/BuyCredits/BuyCredits.utils.tsx:139 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:106 msgid "total purchase price" msgstr "" @@ -4335,11 +4391,15 @@ msgstr "" msgid "Tradable" msgstr "" -#: src/components/organisms/Order/Order.Summary.tsx:115 +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.utils.tsx:175 +msgid "TRADABLE AND RETIRABLE" +msgstr "" + +#: src/components/organisms/Order/Order.Summary.tsx:112 msgid "Tradable Credits" msgstr "" -#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.constants.ts:5 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.constants.ts:4 msgid "Tradable credits have no yet been retired and can be held, sold, or sent to another party." msgstr "" @@ -4449,7 +4509,7 @@ msgstr "" msgid "Use your social account to log in to Regen Marketplace." msgstr "" -#: src/components/templates/MultiStepTemplate/MultiStep.context.tsx:218 +#: src/components/templates/MultiStepTemplate/MultiStep.context.tsx:216 msgid "useMultiStep must be used within a MultiStepProvider" msgstr "" @@ -4596,15 +4656,11 @@ msgstr "" msgid "view project" msgstr "" -#: src/components/organisms/Order/Order.tsx:89 -msgid "View Receipt" -msgstr "" - #: src/components/atoms/WrappedResourcesCard.tsx:33 msgid "view resource" msgstr "" -#: src/pages/BuyCredits/BuyCredits.constants.ts:11 +#: src/pages/BuyCredits/BuyCredits.constants.ts:10 msgid "view retirement certificate" msgstr "" @@ -4674,6 +4730,7 @@ msgstr "" #: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:157 #: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:65 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:87 msgid "watershed" msgstr "" @@ -4784,6 +4841,7 @@ msgid "You are not yet listed as an issuer on any credit classes" msgstr "" #: src/components/molecules/BottomCreditRetireFields/BottomCreditRetireFields.tsx:83 +#: src/components/organisms/BuyCreditsModal/BuyCreditsModal.tsx:505 msgid "You can add the name of the organization or person you are retiring the credits on behalf of here (i.e. 'Retired on behalf of ABC Organization')" msgstr "" diff --git a/web-marketplace/src/lib/i18n/locales/es.po b/web-marketplace/src/lib/i18n/locales/es.po index ea4ec52876..8d580652ac 100644 --- a/web-marketplace/src/lib/i18n/locales/es.po +++ b/web-marketplace/src/lib/i18n/locales/es.po @@ -22,6 +22,9 @@ msgstr "" #: src/components/organisms/CreditActivityTable/CreditActivityTable.tsx:65 #: src/components/organisms/Documentation/Documentation.constants.ts:11 #: src/pages/CreditClassDetails/CreditClassDetailsWithContent/CreditClassDetailsWithContent.constants.ts:35 +msgid "" +msgstr "" + #: src/lib/constants/shared.constants.tsx:96 msgid "- see less" msgstr "- ver menos" @@ -431,6 +434,10 @@ msgstr "Admin" msgid "Advanced settings" msgstr "Configuración avanzada" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:46 +#~ msgid "Agree & purchase" +#~ msgstr "Aceptar y comprar" + #: src/pages/BatchDetails/BatchDetails.tsx:129 msgid "All credits" msgstr "Todos los créditos" @@ -502,6 +509,14 @@ msgstr "El monto no puede exceder" msgid "Amount Escrowed" msgstr "Monto depositado en depósito" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:145 +msgid "amount now available in" +msgstr "Cantidad ahora disponible en" + +#: src/pages/BuyCredits/BuyCredits.utils.tsx:91 +msgid "amount now available in usd" +msgstr "Cantidad ahora disponible en USD" + #: src/pages/Dashboard/MyEcocredits/hooks/useCreateSellOrderSubmit.tsx:150 msgid "amount of credits" msgstr "cantidad de créditos" @@ -510,7 +525,7 @@ msgstr "cantidad de créditos" msgid "Amount of credits" msgstr "Cantidad de créditos" -#: src/pages/BuyCredits/BuyCredits.utils.tsx:165 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:310 #: src/pages/Dashboard/MyEcocredits/hooks/useCreditRetireSubmit.tsx:126 msgid "amount retired" msgstr "cantidad retirada" @@ -534,7 +549,7 @@ msgstr "cantidad enviada" msgid "Amount to sell" msgstr "Cantidad a vender" -#: src/pages/BuyCredits/BuyCredits.utils.tsx:166 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:311 msgid "amount tradable" msgstr "cantidad negociable" @@ -728,6 +743,10 @@ msgstr "Fecha de inicio del lote" msgid "BATCH START DATE" msgstr "FECHA DE INICIO DEL LOTE" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:119 +msgid "Because we use blockchain technology, if another user purchases the credits before you check out, you’ll need to choose different credits." +msgstr "Debido a que utilizamos tecnología blockchain, si otro usuario compra los créditos antes de realizar el pago, deberá elegir créditos diferentes." + #: src/components/molecules/ProjectPageMetadata/ProjectPageMetadata.tsx:159 #: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCreditsInfo.ComplianceInfo.tsx:74 msgid "biome" @@ -1027,6 +1046,10 @@ msgstr "Elige denominación" msgid "Choose ecocredits batch" msgstr "Elige el lote de ecocréditos" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:157 +msgid "Choose new credits" +msgstr "Elige nuevos créditos" + #: src/components/molecules/ProjectSelect.tsx:25 #: src/features/ecocredit/CreateBatchBySteps/hooks/useUpdateProjectOptions.ts:14 msgid "Choose Project" @@ -1375,7 +1398,7 @@ msgstr "Emisión de crédito pendiente" msgid "credit name" msgstr "nombre de credito" -#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:268 +#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:278 msgid "Credit prices vary. By default the lowest priced credits will be purchased first." msgstr "Los precios de los créditos varían. Por defecto, se comprarán primero los créditos con el precio más bajo." @@ -1418,6 +1441,7 @@ msgstr "Los créditos se mantienen en depósito en garantía cuando se crea una msgid "credits available" msgstr "créditos disponibles" +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:106 #: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:106 msgid "Credits Available" msgstr "Créditos disponibles" @@ -1470,6 +1494,7 @@ msgstr "Entrada de créditos" msgid "Credits issuance is calculated based on a weighted scale between 20 and 50 years." msgstr "La emisión de créditos se calcula con base en una escala ponderada entre 20 y 50 años." +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:83 #: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:83 msgid "Credits issued" msgstr "Créditos emitidos" @@ -1482,17 +1507,20 @@ msgstr "créditos comprados" msgid "Credits purchased with crypto can be purchased in either a retired or tradable state." msgstr "Los créditos comprados con criptomonedas se pueden comprar en estado retirado o negociable." +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:82 #: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:82 msgid "Credits Registered" msgstr "Créditos registrados" #: src/components/molecules/BatchTotalsGrid.tsx:46 #: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:128 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:128 msgid "Credits Retired" msgstr "Créditos Retirados" #: src/components/molecules/BatchTotalsGrid.tsx:39 #: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:106 +#: src/components/molecules/ProjectBatchTotals/ProjectBatchTotals.tsx:106 msgid "Credits Tradable" msgstr "Créditos negociables" @@ -1573,7 +1601,7 @@ msgstr "fecha" msgid "Date of upload" msgstr "Fecha de subida" -#: src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.SelectAccountModal.tsx:65 +#: src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.SelectAccountModal.tsx:66 #: src/components/organisms/RegistryLayout/RegistryLayout.constants.ts:12 msgid "default avatar" msgstr "avatar predeterminado" @@ -1981,6 +2009,10 @@ msgstr "Los archivos aún se pueden compartir de forma privada a través de un e msgid "Filters" msgstr "Filtros" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:98 +msgid "find another credit card project" +msgstr "Encuentra otro proyecto de tarjeta de crédito" + #: src/components/molecules/PlanStepper.tsx:18 #: src/components/organisms/CreditClassForms/CreateCreditClassForm.tsx:40 #: src/components/organisms/CreditClassForms/CreateCreditClassForm.tsx:41 @@ -2770,6 +2802,10 @@ msgstr "operador" msgid "Opportunities" msgstr "Oportunidades" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:103 +msgid "or, buy with crypto" +msgstr "o comprar con criptomonedas" + #: src/components/organisms/LoginModal/components/LoginModal.Select.tsx:67 msgid "or, log in with email / social" msgstr "o inicie sesión con correo electrónico / redes sociales" @@ -3135,7 +3171,7 @@ msgstr "Guía del programa" #: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:86 #: src/components/organisms/CreditBatches/CreditBatches.config.ts:18 -#: src/pages/BuyCredits/BuyCredits.utils.tsx:157 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:302 #: src/pages/Dashboard/MyEcocredits/hooks/useBasketPutSubmit.tsx:105 #: src/pages/Dashboard/MyEcocredits/hooks/useCreateSellOrderSubmit.tsx:139 #: src/pages/Dashboard/MyEcocredits/hooks/useCreditRetireSubmit.tsx:113 @@ -3162,6 +3198,7 @@ msgstr "Proyecto" msgid "PROJECT" msgstr "PROYECTO" +#: src/components/organisms/ProjectTopSection/ProjectTopSection.tsx:175 #: src/components/organisms/ProjectTopSection/ProjectTopSection.tsx:175 msgid "Project {onChainProjectId}" msgstr "Proyecto {onChainProjectId}" @@ -3588,7 +3625,7 @@ msgstr "Lugar de retiro" msgid "Retirement note" msgstr "Nota de jubilación" -#: src/pages/BuyCredits/BuyCredits.utils.tsx:56 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:201 msgid "Retirement permanently removes used credits from circulation to prevent their reuse, ensuring that the environmental benefit claimed is real and not double-counted." msgstr "La retirada elimina permanentemente de circulación los créditos usados para evitar su reutilización, garantizando así que el beneficio ambiental reclamado sea real y no se contabilice dos veces." @@ -3665,6 +3702,10 @@ msgstr "Escanee con la aplicación móvil Keplr" msgid "SDGs" msgstr "ODS" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:128 +msgid "search for new credits" +msgstr "buscar nuevos creditos" + #: src/pages/CreditClassDetails/CreditClassDetails.AdditionalInfo.tsx:88 msgid "sectoral scopes" msgstr "ámbitos sectoriales" @@ -3713,8 +3754,8 @@ msgstr "Seleccione una billetera" msgid "Select all" msgstr "Seleccionar todo" -#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:252 -#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:253 +#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:262 +#: src/components/molecules/CreditsAmount/CreditsAmount.tsx:263 msgid "Select option" msgstr "Seleccionar opción" @@ -3874,6 +3915,18 @@ msgstr "Índice social y cultural" msgid "Sold Out" msgstr "Agotado" +#: src/pages/BuyCredits/BuyCredits.utils.tsx:115 +msgid "Sorry, another user has purchased all of the available credits from this project" +msgstr "Lo sentimos, otro usuario ha comprado todos los créditos disponibles de este proyecto." + +#: src/pages/BuyCredits/BuyCredits.utils.tsx:86 +msgid "Sorry, another user has purchased all of the USD credits you selected!" +msgstr "Lo sentimos, ¡otro usuario ha comprado todos los créditos USD que seleccionaste!" + +#: src/pages/BuyCredits/BuyCredits.utils.tsx:140 +msgid "Sorry, another user has purchased some or all of the credits you selected!" +msgstr "Lo sentimos, otro usuario ha comprado algunos o todos los créditos que seleccionaste." + #: src/config/errors.tsx:29 msgid "Sorry, someone has purchased this sell order!" msgstr "Lo sentimos, ¡alguien ha comprado esta orden de venta!" @@ -4373,7 +4426,7 @@ msgstr "total de créditos que has comprado" msgid "total price" msgstr "Precio total" -#: src/pages/BuyCredits/BuyCredits.utils.tsx:139 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:284 msgid "total purchase price" msgstr "Precio total de compra" diff --git a/web-marketplace/src/lib/queries/react-query/ecocredit/marketplace/getSellOrdersExtendedQuery/getSellOrdersExtendedQuery.ts b/web-marketplace/src/lib/queries/react-query/ecocredit/marketplace/getSellOrdersExtendedQuery/getSellOrdersExtendedQuery.ts index 7fc50cfd1f..dbc3ec1f6f 100644 --- a/web-marketplace/src/lib/queries/react-query/ecocredit/marketplace/getSellOrdersExtendedQuery/getSellOrdersExtendedQuery.ts +++ b/web-marketplace/src/lib/queries/react-query/ecocredit/marketplace/getSellOrdersExtendedQuery/getSellOrdersExtendedQuery.ts @@ -29,16 +29,16 @@ export const getSellOrdersExtendedQuery = ({ queryKey: [SELL_ORDERS_EXTENTED_KEY], queryFn: async () => { if (!client) return undefined; - + let _request = { ...request }; // Fetching all sell orders // TODO this could potentially be improved with pagination for the storefront page let sellOrders: SellOrderInfo[] = []; let response: QuerySellOrdersResponse | undefined; while (!response || response.pagination?.nextKey?.length) { if (response?.pagination?.nextKey?.length) { - request.pagination = { key: response.pagination.nextKey }; + _request.pagination = { key: response.pagination.nextKey }; } - response = await client.SellOrders(request); + response = await client.SellOrders(_request); sellOrders.push(...response.sellOrders); } diff --git a/web-marketplace/src/pages/BuyCredits/BuyCredits.Form.tsx b/web-marketplace/src/pages/BuyCredits/BuyCredits.Form.tsx index 07487b0a8e..5811e1b0e2 100644 --- a/web-marketplace/src/pages/BuyCredits/BuyCredits.Form.tsx +++ b/web-marketplace/src/pages/BuyCredits/BuyCredits.Form.tsx @@ -1,5 +1,6 @@ -import { useCallback, useEffect, useMemo } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useNavigate } from 'react-router-dom'; +import { useLingui } from '@lingui/react'; import { Elements } from '@stripe/react-stripe-js'; import { loadStripe, Stripe, StripeElements } from '@stripe/stripe-js'; import { useQuery } from '@tanstack/react-query'; @@ -23,7 +24,9 @@ import { getPaymentMethodsQuery } from 'lib/queries/react-query/registry-server/ import { useWallet } from 'lib/wallet/wallet'; import { useFetchUserBalance } from 'pages/BuyCredits/hooks/useFetchUserBalance'; +import { useFetchSellOrders } from 'pages/Marketplace/Storefront/hooks/useFetchSellOrders'; import { UISellOrderInfo } from 'pages/Projects/AllProjects/AllProjects.types'; +import { normalizeToUISellOrderInfo } from 'pages/Projects/hooks/useProjectsSellOrders.utils'; import { CREDIT_VINTAGE_OPTIONS, CREDITS_AMOUNT, @@ -40,6 +43,9 @@ import { OrderSummaryCard } from 'components/molecules/OrderSummaryCard/OrderSum import { AgreePurchaseForm } from 'components/organisms/AgreePurchaseForm/AgreePurchaseForm'; import { AgreePurchaseFormSchemaType } from 'components/organisms/AgreePurchaseForm/AgreePurchaseForm.schema'; import { AgreePurchaseFormFiat } from 'components/organisms/AgreePurchaseForm/AgreePurchaseFormFiat'; +import { BuyWarningModal } from 'components/organisms/BuyWarningModal/BuyWarningModal'; +import { KEPLR_LOGIN_REQUIRED } from 'components/organisms/BuyWarningModal/BuyWarningModal.constants'; +import { BuyWarningModalContent } from 'components/organisms/BuyWarningModal/BuyWarningModal.types'; import { ChooseCreditsForm } from 'components/organisms/ChooseCreditsForm/ChooseCreditsForm'; import { ChooseCreditsFormSchemaType } from 'components/organisms/ChooseCreditsForm/ChooseCreditsForm.schema'; import { CardSellOrder } from 'components/organisms/ChooseCreditsForm/ChooseCreditsForm.types'; @@ -59,8 +65,12 @@ import { import { PAYMENT_OPTIONS, stripeKey } from './BuyCredits.constants'; import { BuyCreditsSchemaTypes, CardDetails } from './BuyCredits.types'; import { + findMatchingSellOrders, getCreditsAvailableBannerText, getCryptoCurrencies, + getOrderedSellOrders, + getSellOrdersCredits, + getWarningModalContent, } from './BuyCredits.utils'; import { usePurchase } from './hooks/usePurchase'; @@ -78,6 +88,10 @@ type Props = { projectHref: string; cardDetails?: CardDetails; project?: NormalizeProject; + projectId: string | undefined; + loadingSanityProject: boolean; + isBuyFlowDisabled: boolean; + loadingBuySellOrders: boolean; }; const stripe = loadStripe(stripeKey); @@ -96,10 +110,14 @@ export const BuyCreditsForm = ({ projectHref, cardDetails, project, + projectId, + loadingSanityProject, + isBuyFlowDisabled, + loadingBuySellOrders, }: Props) => { const { data, activeStep, handleSaveNext, handleSave, handleActiveStep } = useMultiStep(); - const { wallet, isConnected, activeWalletAddr } = useWallet(); + const { wallet, isConnected, activeWalletAddr, loaded } = useWallet(); const { activeAccount, privActiveAccount } = useAuth(); const [paymentOption, setPaymentOption] = useAtom(paymentOptionAtom); const { @@ -110,7 +128,8 @@ export const BuyCreditsForm = ({ onButtonClick, } = useLoginData({}); const navigate = useNavigate(); - + const { _ } = useLingui(); + const warningModalContent = useRef(); const setErrorBannerTextAtom = useSetAtom(errorBannerTextAtom); const setWarningBannerTextAtom = useSetAtom(warningBannerTextAtom); const setConnectWalletModal = useSetAtom(connectWalletModalAtom); @@ -118,6 +137,13 @@ export const BuyCreditsForm = ({ const [paymentOptionCryptoClicked, setPaymentOptionCryptoClicked] = useAtom( paymentOptionCryptoClickedAtom, ); + const [warningModalState, setWarningModalState] = useState({ + openModal: false, + creditsAvailable: 0, + }); + + const { refetchSellOrders } = useFetchSellOrders(); + const cardDisabled = cardSellOrders.length === 0; const { marketplaceClient, ecocreditClient } = useLedger(); @@ -161,6 +187,28 @@ export const BuyCreditsForm = ({ setPaymentOption(prev => data?.paymentOption || prev); }, [data, setPaymentOption, setRetiring]); + useEffect(() => { + if ( + !loadingSanityProject && + !loadingBuySellOrders && + cardSellOrders.length === 0 && + ((loaded && !wallet?.address) || isBuyFlowDisabled) && + !warningModalContent.current + ) { + // Else if there's no connected wallet address or buy disabled, redirect to project page + navigate(`/project/${projectId}`, { replace: true }); + } + }, [ + loadingSanityProject, + loadingBuySellOrders, + loaded, + wallet?.address, + navigate, + projectId, + cardSellOrders.length, + isBuyFlowDisabled, + ]); + const paymentInfoFormSubmit = useCallback( async (values: PaymentInfoFormSchemaType) => { const { paymentMethodId, ...others } = values; @@ -186,6 +234,25 @@ export const BuyCreditsForm = ({ const currencyAmount = data?.[CURRENCY_AMOUNT]; const creditTypePrecision = creditTypeData?.creditType?.precision; + const filteredCryptoSellOrders = useMemo( + () => + getFilteredCryptoSellOrders({ + askDenom: currency?.askDenom, + cryptoSellOrders, + retiring, + }), + [cryptoSellOrders, currency?.askDenom, retiring], + ); + const orderedSellOrders = useMemo( + () => + getOrderedSellOrders( + paymentOption === PAYMENT_OPTIONS.CARD, + cardSellOrders, + filteredCryptoSellOrders, + ), + [cardSellOrders, filteredCryptoSellOrders, paymentOption], + ); + const purchase = usePurchase({ paymentOption, retiring, @@ -201,38 +268,74 @@ export const BuyCreditsForm = ({ stripe?: Stripe | null, elements?: StripeElements | null, ) => { - const { retirementReason, country, stateProvince, postalCode } = values; - const { - sellOrders: selectedSellOrders, - savePaymentMethod, - createAccount: createActiveAccount, - // subscribeNewsletter, TODO - // followProject, - } = data; + if (project) { + const sellOrders = await refetchSellOrders(); + const creditsInAllSellOrders = getSellOrdersCredits(sellOrders); + const creditsToBuy = data?.creditsAmount; + const requestedSellOrders = findMatchingSellOrders( + data, + sellOrders?.map(normalizeToUISellOrderInfo), + ); + const creditsInRequestedSellOrders = + getSellOrdersCredits(requestedSellOrders); + + const sellCanProceed = + creditsToBuy && creditsToBuy <= creditsInRequestedSellOrders; - if (selectedSellOrders && creditsAmount) - purchase({ - selectedSellOrders, - retiring, - retirementReason, - country, - stateProvince, - postalCode, - savePaymentMethod, - createActiveAccount, - paymentMethodId, - stripe, - elements, - confirmationTokenId, - }); + if (sellCanProceed) { + const { retirementReason, country, stateProvince, postalCode } = + values; + const { + sellOrders: selectedSellOrders, + savePaymentMethod, + createAccount: createActiveAccount, + // subscribeNewsletter, TODO + // followProject, + } = data; + + if (selectedSellOrders && creditsAmount) + purchase({ + selectedSellOrders, + retiring, + retirementReason, + country, + stateProvince, + postalCode, + savePaymentMethod, + createActiveAccount, + paymentMethodId, + stripe, + elements, + confirmationTokenId, + }); + } else { + setWarningModalState({ + openModal: true, + creditsAvailable: creditsInRequestedSellOrders, + }); + warningModalContent.current = getWarningModalContent( + currency, + creditsInRequestedSellOrders, + _, + allowedDenomsData, + data, + creditsInAllSellOrders, + ); + } + } }, [ - confirmationTokenId, - creditsAmount, + project, + refetchSellOrders, data, - paymentMethodId, + creditsAmount, purchase, retiring, + paymentMethodId, + confirmationTokenId, + currency, + _, + allowedDenomsData, ], ); @@ -245,25 +348,6 @@ export const BuyCreditsForm = ({ () => paymentOption === PAYMENT_OPTIONS.CARD, [paymentOption], ); - const filteredCryptoSellOrders = useMemo( - () => - getFilteredCryptoSellOrders({ - askDenom: currency?.askDenom, - cryptoSellOrders, - retiring, - }), - [cryptoSellOrders, currency?.askDenom, retiring], - ); - const orderedSellOrders = useMemo( - () => - card - ? cardSellOrders.sort((a, b) => a.usdPrice - b.usdPrice) - : filteredCryptoSellOrders?.sort( - (a, b) => Number(a.askAmount) - Number(b.askAmount), - ) || [], - - [card, cardSellOrders, filteredCryptoSellOrders], - ); const creditsAvailable = useMemo( () => @@ -473,6 +557,62 @@ export const BuyCreditsForm = ({ modalState={modalState} redirectRoute={`${projectHref.replace(/^\//, '')}/buy`} /> + {warningModalContent.current && ( + { + if (action === KEPLR_LOGIN_REQUIRED) { + if (!activeWalletAddr) { + // no connected wallet address + setConnectWalletModal(atom => void (atom.open = true)); + } else if (!isConnected) { + // user logged in with web2 but not connected to the wallet address associated to his/er account + setSwitchWalletModalAtom(atom => void (atom.open = true)); + } else { + // web3 account connected + handleSave( + { ...data, paymentOption: PAYMENT_OPTIONS.CRYPTO }, + 0, + ); + setWarningModalState({ + ...warningModalState, + openModal: false, + }); + window.scrollTo(0, 0); + handleActiveStep(0); + } + } else if (action) { + navigate(action); + } else { + setWarningModalState({ + ...warningModalState, + openModal: false, + }); + const amounts = getCurrencyAmount({ + currentCreditsAmount: warningModalState.creditsAvailable, + card: paymentOption === PAYMENT_OPTIONS.CARD, + orderedSellOrders, + creditTypePrecision: creditTypeData?.creditType?.precision, + }); + // After a purchase attempt where there's partial credits availability, + // we need to update the form with the new credits, currency amount and sell orders. + handleSave( + { + ...data, + [CREDITS_AMOUNT]: warningModalState.creditsAvailable, + [CURRENCY_AMOUNT]: amounts.currencyAmount, + [SELL_ORDERS]: amounts.sellOrders, + }, + 0, + ); + window.scrollTo(0, 0); + handleActiveStep(0); + } + }} + /> + )}
); }; diff --git a/web-marketplace/src/pages/BuyCredits/BuyCredits.tsx b/web-marketplace/src/pages/BuyCredits/BuyCredits.tsx index 048feb8ad7..a9c87e8d82 100644 --- a/web-marketplace/src/pages/BuyCredits/BuyCredits.tsx +++ b/web-marketplace/src/pages/BuyCredits/BuyCredits.tsx @@ -1,9 +1,7 @@ import { useEffect, useState } from 'react'; -import { useNavigate, useParams } from 'react-router-dom'; +import { useParams } from 'react-router-dom'; import { useAtomValue } from 'jotai'; -import { useWallet } from 'lib/wallet/wallet'; - import NotFoundPage from 'pages/NotFound'; import WithLoader from 'components/atoms/WithLoader'; import { MultiStepTemplate } from 'components/templates/MultiStepTemplate'; @@ -19,7 +17,6 @@ import { useSummarizePayment } from './hooks/useSummarizePayment'; export const BuyCredits = () => { const { projectId } = useParams(); - const navigate = useNavigate(); const { loadingSanityProject, @@ -38,27 +35,6 @@ export const BuyCredits = () => { useNavigateToSlug(slug, '/buy'); const paymentOption = useAtomValue(paymentOptionAtom); - const { wallet, loaded } = useWallet(); - - useEffect(() => { - if ( - !loadingSanityProject && - !loadingBuySellOrders && - cardSellOrders.length === 0 && - ((loaded && !wallet?.address) || isBuyFlowDisabled) - ) - // Else if there's no connected wallet address or buy disabled, redirect to project page - navigate(`/project/${projectId}`, { replace: true }); - }, [ - loadingSanityProject, - loadingBuySellOrders, - loaded, - wallet?.address, - navigate, - projectId, - cardSellOrders.length, - isBuyFlowDisabled, - ]); const [retiring, setRetiring] = useState(true); const [confirmationTokenId, setConfirmationTokenId] = useState< @@ -116,6 +92,10 @@ export const BuyCredits = () => { setCardDetails={setCardDetails} cardDetails={cardDetails} project={projectsWithOrderData[0]} + projectId={projectId} + loadingSanityProject={loadingSanityProject} + isBuyFlowDisabled={isBuyFlowDisabled} + loadingBuySellOrders={loadingBuySellOrders} /> diff --git a/web-marketplace/src/pages/BuyCredits/BuyCredits.utils.tsx b/web-marketplace/src/pages/BuyCredits/BuyCredits.utils.tsx index 10f0514cf5..b8bfed9d28 100644 --- a/web-marketplace/src/pages/BuyCredits/BuyCredits.utils.tsx +++ b/web-marketplace/src/pages/BuyCredits/BuyCredits.utils.tsx @@ -1,14 +1,28 @@ import { i18n } from '@lingui/core'; -import { msg, plural } from '@lingui/macro'; +import { msg, plural, Trans } from '@lingui/macro'; +// import { Box } from '@mui/material'; +import { QueryAllowedDenomsResponse } from '@regen-network/api/lib/generated/regen/ecocredit/marketplace/v1/query'; +import { USD_DENOM } from 'config/allowedBaseDenoms'; -import { getFormattedNumber } from 'web-components/src/utils/format'; +// import { quantityFormatNumberOptions } from 'config/decimals'; +import { + // formatNumber, + getFormattedNumber, +} from 'web-components/src/utils/format'; +// import { microToDenom } from 'lib/denom.utils'; +import { TranslatorType } from 'lib/i18n/i18n.types'; import { NormalizeProject } from 'lib/normalizers/projects/normalizeProjectsWithMetadata'; import { UISellOrderInfo } from 'pages/Projects/AllProjects/AllProjects.types'; import { AmountWithCurrency } from 'components/molecules/AmountWithCurrency/AmountWithCurrency'; import { Currency } from 'components/molecules/CreditsAmount/CreditsAmount.types'; +import { findDisplayDenom } from 'components/molecules/DenomLabel/DenomLabel.utils'; +import { KEPLR_LOGIN_REQUIRED } from 'components/organisms/BuyWarningModal/BuyWarningModal.constants'; +import { BuyWarningModalContent } from 'components/organisms/BuyWarningModal/BuyWarningModal.types'; +import { CardSellOrder } from 'components/organisms/ChooseCreditsForm/ChooseCreditsForm.types'; import { HandleSaveType } from 'components/templates/MultiStepTemplate/MultiStep.context'; +import { SellOrderInfoExtented } from 'hooks/useQuerySellOrders'; import { AGREE_PURCHASE, @@ -27,6 +41,137 @@ type GetFormModelParams = { projectId: string; }; +export const findMatchingSellOrders = ( + data: BuyCreditsSchemaTypes, + sellOrders: UISellOrderInfo[] | undefined, +) => { + if (!sellOrders) return []; + + const sellOrderIds = data?.sellOrders?.map(order => order.sellOrderId); + + return sellOrders.filter(order => sellOrderIds?.includes(order.id)); +}; + +export const getOrderedSellOrders = ( + isCard: boolean, + cardSellOrders: CardSellOrder[], + filteredCryptoSellOrders: UISellOrderInfo[], +): UISellOrderInfo[] => { + return isCard + ? cardSellOrders.sort((a, b) => a.usdPrice - b.usdPrice) + : filteredCryptoSellOrders?.sort( + (a, b) => Number(a.askAmount) - Number(b.askAmount), + ) || []; +}; + +export const getWarningModalContent = ( + currency: { askDenom: string; askBaseDenom: string } | undefined, + creditsInRequestedSellOrders: number, + _: TranslatorType, + allowedDenomsData: QueryAllowedDenomsResponse | undefined, + data: BuyCreditsSchemaTypes, + creditsInAllSellOrders: number | undefined, +): BuyWarningModalContent | undefined => { + if ( + currency?.askDenom === USD_DENOM && + !creditsInRequestedSellOrders && + creditsInAllSellOrders + ) { + return { + modalContent: { + title: _( + msg`Sorry, another user has purchased all of the USD credits you selected!`, + ), + content: ( + <> +

+ amount now available in usd +

+ {creditsInRequestedSellOrders} + + ), + buttons: [ + { + text: _(msg`find another credit card project`), + action: '/projects', + type: 'contained', + }, + { + text: _(msg`or, buy with crypto`), + action: KEPLR_LOGIN_REQUIRED, + type: 'outlined', + }, + ], + }, + }; + } else if (!creditsInAllSellOrders) { + // no credits available + return { + modalContent: { + title: _( + msg`Sorry, another user has purchased all of the available credits from this project`, + ), + content: ( +

+ + Because we use blockchain technology, if another user purchases + the credits before you check out, you’ll need to choose different + credits. + +

+ ), + buttons: [ + { + text: _(msg`search for new credits`), + action: '/projects', + type: 'outlined', + }, + ], + }, + }; + } else if (creditsInRequestedSellOrders >= 0) { + // some credits available + return { + modalContent: { + title: _( + msg`Sorry, another user has purchased some or all of the credits you selected!`, + ), + content: ( + <> +

+ amount now available in + {` ${findDisplayDenom({ + allowedDenoms: allowedDenomsData?.allowedDenoms, + bankDenom: data?.currency?.askDenom!, + baseDenom: data?.currency?.askBaseDenom!, + })}`} +

+ {creditsInRequestedSellOrders} + + ), + buttons: [ + { + text: _(msg`Choose new credits`), + action: null, + type: 'outlined', + }, + ], + }, + }; + } +}; + +export const getSellOrdersCredits = ( + sellOrders: UISellOrderInfo[] | SellOrderInfoExtented[] | undefined, +) => { + return ( + sellOrders?.reduce( + (credits, sellOrder) => credits + Number(sellOrder.quantity), + 0, + ) || 0 + ); +}; + const getStep2Name = (card: boolean) => card ? i18n._(PAYMENT_INFO) : i18n._(CUSTOMER_INFO);