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-204 buy credits #2477

Merged
merged 53 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
580a54e
feat: add BuyCredits flow wip
blushi Sep 10, 2024
4e1bf35
feat: add more props to ChooseCreditsForm
blushi Sep 11, 2024
5ac0b54
feat: update CreditsAmounts and tests
blushi Sep 16, 2024
778c6c1
feat: useGetProject
blushi Sep 17, 2024
d9ffd2e
feat: show correct display denom
blushi Sep 17, 2024
574927e
feat: Update OrderSummaryCard
blushi Sep 17, 2024
5912052
feat: add prev/next buttons ChooseCreditForm
blushi Sep 18, 2024
4b34a68
fix: text input overflow
blushi Sep 18, 2024
c30308d
feat: add prev/next btn to PaymentInfo and use stripe key
blushi Sep 18, 2024
e04a982
feat: add more props to PaymentInfoForm, payment methods query and s…
blushi Sep 19, 2024
1060b14
feat: add login to PaymentInfoForm
blushi Sep 19, 2024
d3fe606
refactor: mv stripe Elements up and get confirmation token
blushi Sep 19, 2024
460dc78
refactor: address review comments and add PaymentInfoFormFiat
blushi Sep 23, 2024
f2ec750
fix: ChooseCreditsForm validation
blushi Sep 23, 2024
e1dd83a
feat: use initial values on ChooseCreditsForm
blushi Sep 23, 2024
2d20f37
feat: add initialValues to PaymentInfoForm
blushi Sep 23, 2024
2c14976
test: fix CreditsAmount test
blushi Sep 23, 2024
b947546
fix: ts error
blushi Sep 23, 2024
77bd2a2
chore: rename to withLocalStorage
blushi Sep 25, 2024
7605f8b
feat: get card details from confirmation token id
blushi Sep 24, 2024
bc0c382
feat: get card details from payment method id and some refactor
blushi Sep 24, 2024
e348ee2
fix: AgreePurchaseForm validation
blushi Sep 24, 2024
a1e82cf
feat: add usePurchase and crypto buy
blushi Sep 24, 2024
29f664a
test: ignore TODO test
blushi Sep 24, 2024
b5ec477
feat: fiat buy and few fixes
blushi Sep 25, 2024
87092b1
feat: manually handleCardAction
blushi Sep 25, 2024
dd4d7e7
fix: add missing returns
blushi Sep 25, 2024
0aff960
feat: default to fiat if any or redirect to project page if not conne…
blushi Sep 25, 2024
a6cafab
feat: logic for buy button on ProjectDetails page
blushi Sep 25, 2024
a366c5c
feat: only show wallets
blushi Sep 25, 2024
de5e2f6
fix: handle case where sell order id in sanity not available anymore
blushi Sep 25, 2024
9051bbc
fix: redirect to project page if buy disabled
blushi Sep 25, 2024
3cce4b1
feat: show modal when clicking buy with crypto
blushi Sep 25, 2024
66842c1
chore: i18n
blushi Sep 25, 2024
1cf0f48
chore: use find
blushi Sep 26, 2024
16a2255
chore: clean up
blushi Sep 26, 2024
8b2e1a5
fix: validation in ChooseCreditsForm
blushi Sep 26, 2024
94f45f7
fix: filter seller sell orders
blushi Sep 26, 2024
f47029a
feat: set amounts when choosing tradable credits
blushi Oct 1, 2024
334e535
chore: use formatted number
blushi Oct 1, 2024
d81be5d
feat: add retirement info to /create-payment-intent
blushi Oct 2, 2024
3f582e6
chore: i18n:extract
blushi Oct 2, 2024
235e1c7
fix: update fields on currency/payment option change
blushi Oct 3, 2024
524cdb8
fix: error msg UI
blushi Oct 3, 2024
3475456
feat: set initial credits amount to min(1,available)
blushi Oct 3, 2024
6b2859a
fix: choose credits form initial values
blushi Oct 3, 2024
cd96173
chore: remove leading 0 from input
blushi Oct 3, 2024
e82943c
fix: initialization and validation choose credits form
blushi Oct 3, 2024
d17b40f
fix: update GET_PAYMENT_METHODS_QUERY_KEY
blushi Oct 7, 2024
290e480
chore: address reviewcomments
blushi Oct 7, 2024
596044f
fix: entering decimal values
blushi Oct 10, 2024
b24ec41
fix: setting max unneeded microToDenom
blushi Oct 10, 2024
35ed494
fix: error with 0 credits available and paymentOptionCryptoClicked
blushi 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' && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be percentComplete !== undefined instead of using typeof?

Copy link
Member Author

@blushi blushi Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer using typeof because this is safer if the variable hasn't already been declared, it won't throw an error, but I agree in this case, we could also use percentComplete !== undefined I don't have a strong preference

<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