Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: APP-368 add user balance error in buy credits form #2501

Open
wants to merge 59 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
7919f31
feat: add BuyCredits flow wip
blushi Sep 10, 2024
1b3a45b
feat: add more props to ChooseCreditsForm
blushi Sep 11, 2024
9434257
feat: update CreditsAmounts and tests
blushi Sep 16, 2024
22a7257
feat: useGetProject
blushi Sep 17, 2024
b264a96
feat: show correct display denom
blushi Sep 17, 2024
a1e457e
feat: Update OrderSummaryCard
blushi Sep 17, 2024
0de46ee
feat: add prev/next buttons ChooseCreditForm
blushi Sep 18, 2024
dbc8345
fix: text input overflow
blushi Sep 18, 2024
f71e27f
feat: add prev/next btn to PaymentInfo and use stripe key
blushi Sep 18, 2024
ab32bd7
feat: add more props to PaymentInfoForm, payment methods query and s…
blushi Sep 19, 2024
9d5c620
feat: add login to PaymentInfoForm
blushi Sep 19, 2024
607afdf
refactor: mv stripe Elements up and get confirmation token
blushi Sep 19, 2024
bc505fb
refactor: address review comments and add PaymentInfoFormFiat
blushi Sep 23, 2024
e1c5572
fix: ChooseCreditsForm validation
blushi Sep 23, 2024
a481f6a
feat: use initial values on ChooseCreditsForm
blushi Sep 23, 2024
434ec8e
feat: add initialValues to PaymentInfoForm
blushi Sep 23, 2024
407be32
test: fix CreditsAmount test
blushi Sep 23, 2024
eb4d207
fix: ts error
blushi Sep 23, 2024
40b561b
chore: rename to withLocalStorage
blushi Sep 25, 2024
dc47e58
feat: get card details from confirmation token id
blushi Sep 24, 2024
b470e1c
feat: get card details from payment method id and some refactor
blushi Sep 24, 2024
dedab28
fix: AgreePurchaseForm validation
blushi Sep 24, 2024
10de68b
feat: add usePurchase and crypto buy
blushi Sep 24, 2024
a5a49b7
test: ignore TODO test
blushi Sep 24, 2024
2c128f1
feat: fiat buy and few fixes
blushi Sep 25, 2024
f8848ed
feat: manually handleCardAction
blushi Sep 25, 2024
7acc679
fix: add missing returns
blushi Sep 25, 2024
02fb0eb
feat: default to fiat if any or redirect to project page if not conne…
blushi Sep 25, 2024
9908522
feat: logic for buy button on ProjectDetails page
blushi Sep 25, 2024
907b901
feat: only show wallets
blushi Sep 25, 2024
a530b7a
fix: handle case where sell order id in sanity not available anymore
blushi Sep 25, 2024
1423a49
fix: redirect to project page if buy disabled
blushi Sep 25, 2024
5a3fe5d
feat: show modal when clicking buy with crypto
blushi Sep 25, 2024
62faedd
chore: i18n
blushi Sep 25, 2024
0b71b80
chore: use find
blushi Sep 26, 2024
2e0b659
chore: clean up
blushi Sep 26, 2024
4d94ad4
fix: validation in ChooseCreditsForm
blushi Sep 26, 2024
475af39
fix: filter seller sell orders
blushi Sep 26, 2024
3cd2aaa
feat: set amounts when choosing tradable credits
blushi Oct 1, 2024
95d1b6a
chore: use formatted number
blushi Oct 1, 2024
4fc1281
feat: add retirement info to /create-payment-intent
blushi Oct 2, 2024
cd42113
chore: i18n:extract
blushi Oct 2, 2024
5f77609
fix: update fields on currency/payment option change
blushi Oct 3, 2024
4adbb73
fix: error msg UI
blushi Oct 3, 2024
c0e0c2f
feat: set initial credits amount to min(1,available)
blushi Oct 3, 2024
d8a08fc
fix: choose credits form initial values
blushi Oct 3, 2024
9c6e79f
chore: remove leading 0 from input
blushi Oct 3, 2024
2438387
fix: initialization and validation choose credits form
blushi Oct 3, 2024
715096f
fix: update GET_PAYMENT_METHODS_QUERY_KEY
blushi Oct 7, 2024
d02db21
chore: address reviewcomments
blushi Oct 7, 2024
caf39a5
fix: entering decimal values
blushi Oct 10, 2024
cde9ef2
fix: setting max unneeded microToDenom
blushi Oct 10, 2024
6eb76bf
feat: add form error when user doesn't have enough balance to buy cre…
r41ph Oct 10, 2024
ce8193a
chore: generate .po files
r41ph Oct 10, 2024
3c1d023
fix: CreditsAmount stories
r41ph Oct 10, 2024
b9c8bcf
refactor: useFetchUserBalance to get a single param and return loadin…
r41ph Oct 14, 2024
e14e655
feat: add loading animation while fetching userBalance
r41ph Oct 14, 2024
86a009b
chore: generate .po files
r41ph Oct 14, 2024
de58032
chore: remove unneeded high number in userBalance state
r41ph Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Default.args = {
root: '',
label: '',
},
bodyTexts: { prefinance: 'prefinance' },
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const PrefinanceTag = ({
height: '19',
},
}: {
bodyTexts: ProjectCardBodyTextsMapping;
bodyTexts: Pick<ProjectCardBodyTextsMapping, 'prefinance'>;
classNames?: { root?: string; label?: string };
iconSize?: {
width: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Meta, StoryObj } from '@storybook/react';

import { CURRENCIES } from '../DenomIconWithCurrency/DenomIconWithCurrency.constants';
import { SupCurrencyAndAmount } from './SupCurrencyAndAmount';

export default {
Expand All @@ -16,5 +15,5 @@ export const Default: Story = {

Default.args = {
price: 5,
currencyCode: CURRENCIES.usd,
currencyCode: 'usd',
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { render } from '@testing-library/react';
import { SupCurrencyAndAmount } from 'web-components/src/components/SupCurrencyAndAmount/SupCurrencyAndAmount';

import { CURRENCIES } from '../DenomIconWithCurrency/DenomIconWithCurrency.constants';
import { USD_DENOM } from 'web-marketplace/src/config/allowedBaseDenoms';

describe('SupCurrencyAndAmount', () => {
it('renders the currency symbol and amount', () => {
const currency = CURRENCIES.usd;
const currency = USD_DENOM;
const amount = '100.00';

const { getByText } = render(
Expand Down

This file was deleted.

This file was deleted.

55 changes: 12 additions & 43 deletions web-components/src/components/fixed-footer/SaveFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import LinearProgress from '@mui/material/LinearProgress';
import { Theme } from '@mui/material/styles';
import { makeStyles, withStyles } from 'tss-react/mui';

import { cn } from '../../utils/styles/cn';
import ContainedButton from '../buttons/ContainedButton';
import OutlinedButton from '../buttons/OutlinedButton';
import { TextButton } from '../buttons/TextButton';
import ArrowDownIcon from '../icons/ArrowDownIcon';
import { PrevNextButtons } from '../molecules/PrevNextButtons/PrevNextButtons';
import FixedFooter from './';

const StyledLinearProgress = withStyles(LinearProgress, theme => ({
Expand Down Expand Up @@ -40,14 +37,14 @@ interface Props {
onSave?: () => void;
saveDisabled: boolean;
saveText: string;
saveExitText: string;
saveExitText?: string;
hideProgress?: boolean;
// TODO: we should probably use a helper function to calculate this, or it would
// be hard to manage. One idea is to have an array with all routes which contain
// steps, and use the order of a route in that array to determine the percentage
// of overall completion, but that would depend on each step living in its own
// route. Another would just be to pass total steps + current step
percentComplete: number;
percentComplete?: number;
saveAndExit?: () => Promise<void>;
}

Expand All @@ -60,25 +57,14 @@ const useStyles = makeStyles<StyleProps>()((theme, { hideProgress }) => ({
arrows: {
margin: theme.spacing(0, 2, 0, 0),
},
btn: {
padding: theme.spacing(2, 4),
minWidth: 0,
height: '100%',
[theme.breakpoints.up('sm')]: {
fontSize: theme.spacing(4),
},
[theme.breakpoints.down('sm')]: {
fontSize: theme.spacing(3),
height: theme.spacing(11),
},
},
}));

const SaveFooter: React.FC<React.PropsWithChildren<Props>> = ({
saveText,
saveExitText,
hideProgress = false,
saveAndExit,
percentComplete,
...props
}) => {
const { classes } = useStyles({ hideProgress });
Expand Down Expand Up @@ -106,33 +92,16 @@ const SaveFooter: React.FC<React.PropsWithChildren<Props>> = ({
</Grid>

<Grid item className={classes.arrows}>
{props.onPrev && (
<OutlinedButton
className={cn(classes.btn, 'mr-10 sm:mr-20')}
onClick={props.onPrev}
>
<ArrowDownIcon
fontSize="small"
direction="prev"
color={theme.palette.secondary.main}
/>
</OutlinedButton>
)}
<ContainedButton
type="submit"
className={classes.btn}
onClick={props.onSave}
disabled={props.saveDisabled}
>
{saveText}
</ContainedButton>
<PrevNextButtons
saveDisabled={props.saveDisabled}
saveText={saveText}
onPrev={props.onPrev}
onSave={props.onSave}
/>
</Grid>
</Grid>
{!hideProgress && (
<StyledLinearProgress
variant="determinate"
value={props.percentComplete}
/>
{!hideProgress && typeof percentComplete !== 'undefined' && (
<StyledLinearProgress variant="determinate" value={percentComplete} />
)}
</FixedFooter>
);
Expand Down
14 changes: 7 additions & 7 deletions web-components/src/components/icons/CogIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export const CogIcon = ({ linearGradient, ...props }: Props) => (
? '#8F8F8F'
: 'currentColor'
}
stroke-width="2"
stroke-linejoin="round"
strokeWidth="2"
strokeLinejoin="round"
/>
<path
d="M8.71875 11.66C8.71875 13.2837 10.035 14.6 11.6587 14.6C13.2825 14.6 14.5987 13.2837 14.5987 11.66C14.5987 10.0363 13.2825 8.71997 11.6587 8.71997C10.035 8.71997 8.71875 10.0363 8.71875 11.66Z"
Expand All @@ -35,7 +35,7 @@ export const CogIcon = ({ linearGradient, ...props }: Props) => (
? '#8F8F8F'
: 'currentColor'
}
stroke-linejoin="round"
strokeLinejoin="round"
/>
<defs>
<linearGradient
Expand All @@ -48,9 +48,9 @@ export const CogIcon = ({ linearGradient, ...props }: Props) => (
>
<stop
offset="0.00458717"
stop-color={props.disabled ? '#8F8F8F' : '#7BC796'}
stopColor={props.disabled ? '#8F8F8F' : '#7BC796'}
/>
<stop offset="1" stop-color={props.disabled ? '#EFEFEF' : '#C5E6D1'} />
<stop offset="1" stopColor={props.disabled ? '#EFEFEF' : '#C5E6D1'} />
</linearGradient>
<linearGradient
id="linear1_cog_icon"
Expand All @@ -62,9 +62,9 @@ export const CogIcon = ({ linearGradient, ...props }: Props) => (
>
<stop
offset="0.00458717"
stop-color={props.disabled ? '#8F8F8F' : '#7BC796'}
stopColor={props.disabled ? '#8F8F8F' : '#7BC796'}
/>
<stop offset="1" stop-color={props.disabled ? '#EFEFEF' : '#C5E6D1'} />
<stop offset="1" stopColor={props.disabled ? '#EFEFEF' : '#C5E6D1'} />
</linearGradient>
</defs>
</svg>
Expand Down
37 changes: 16 additions & 21 deletions web-components/src/components/icons/CreditCardIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
/* eslint-disable lingui/no-unlocalized-strings */
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
import React from 'react';

interface IconProps extends SvgIconProps {}

export default function CreditCardIcon({
sx = [],
...props
}: IconProps): JSX.Element {
export default function CreditCardIcon(
props: React.SVGProps<SVGSVGElement>,
): JSX.Element {
return (
<SvgIcon
<svg
data-testid="CreditCardIcon"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 29 16"
sx={[{ fill: 'none' }, ...(Array.isArray(sx) ? sx : [sx])]}
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
{...props}
>
<g id="icon/card">
<path
id="Vector"
fill-rule="evenodd"
clip-rule="evenodd"
d="M16 4H0V3.25C0 2.56 0.448 2 1 2H15C15.552 2 16 2.56 16 3.25V4ZM16 6.5V13C16 13.2652 15.8946 13.5196 15.7071 13.7071C15.5196 13.8946 15.2652 14 15 14H1C0.734784 14 0.48043 13.8946 0.292893 13.7071C0.105357 13.5196 0 13.2652 0 13V6.5H16ZM4 10C3.73478 10 3.48043 10.1054 3.29289 10.2929C3.10536 10.4804 3 10.7348 3 11C3 11.2652 3.10536 11.5196 3.29289 11.7071C3.48043 11.8946 3.73478 12 4 12H5C5.26522 12 5.51957 11.8946 5.70711 11.7071C5.89464 11.5196 6 11.2652 6 11C6 10.7348 5.89464 10.4804 5.70711 10.2929C5.51957 10.1054 5.26522 10 5 10H4Z"
fill="#4FB573"
/>
</g>
</SvgIcon>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M16 4H0V3.25C0 2.56 0.448 2 1 2H15C15.552 2 16 2.56 16 3.25V4ZM16 6.5V13C16 13.2652 15.8946 13.5196 15.7071 13.7071C15.5196 13.8946 15.2652 14 15 14H1C0.734784 14 0.48043 13.8946 0.292893 13.7071C0.105357 13.5196 0 13.2652 0 13V6.5H16ZM4 10C3.73478 10 3.48043 10.1054 3.29289 10.2929C3.10536 10.4804 3 10.7348 3 11C3 11.2652 3.10536 11.5196 3.29289 11.7071C3.48043 11.8946 3.73478 12 4 12H5C5.26522 12 5.51957 11.8946 5.70711 11.7071C5.89464 11.5196 6 11.2652 6 11C6 10.7348 5.89464 10.4804 5.70711 10.2929C5.51957 10.1054 5.26522 10 5 10H4Z"
fill="currentColor"
/>
</svg>
);
}
Loading