diff --git a/public/images/arrowGroup.svg b/public/images/arrowGroup.svg
new file mode 100644
index 00000000..59b845d9
--- /dev/null
+++ b/public/images/arrowGroup.svg
@@ -0,0 +1,4 @@
+
diff --git a/src/features/AddCardForm/components/Form/hooks/index.tsx b/src/features/AddCardForm/components/Form/hooks/index.tsx
index 370ff9eb..a427617d 100644
--- a/src/features/AddCardForm/components/Form/hooks/index.tsx
+++ b/src/features/AddCardForm/components/Form/hooks/index.tsx
@@ -32,6 +32,7 @@ export type Props = {
children?: ReactNode,
initialformOpen?: boolean,
inputsBackground?: string,
+ loader?: boolean,
onAddSuccess?: () => void,
}
@@ -54,6 +55,7 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => {
const [name, setName] = useState('')
const [inputStates, setInputStates] = useObjectState(initialState)
const [error, setError] = useState('')
+ const [loader, setLoader] = useState(false)
const onNameChange = (e: ChangeEvent) => {
const { value } = e.target
@@ -104,7 +106,7 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => {
const cardNumberElement = elements.getElement(CardNumberElement)
if (!cardNumberElement) return
-
+ setLoader(true)
const { error: tokenError, token } = await stripe.createToken(
cardNumberElement,
{ name },
@@ -112,8 +114,12 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => {
if (tokenError) {
setError(tokenError.message || '')
+ setLoader(false)
} else if (token) {
- onAddCard(token.id).then(onAddSuccess)
+ setLoader(true)
+ onAddCard(token.id)
+ .then(onAddSuccess)
+ .then(() => setLoader(false))
}
}
@@ -125,6 +131,7 @@ export const useFormSubmit = ({ onAddSuccess }: Props) => {
error,
handleSubmit,
isLabelVisible,
+ loader,
name,
onInputsBlur,
onInputsChange,
diff --git a/src/features/AddCardForm/components/Form/index.tsx b/src/features/AddCardForm/components/Form/index.tsx
index 424b24f7..57b8e8b8 100644
--- a/src/features/AddCardForm/components/Form/index.tsx
+++ b/src/features/AddCardForm/components/Form/index.tsx
@@ -8,7 +8,7 @@ import { isMobileDevice } from 'config/userAgent'
import { T9n } from 'features/T9n'
import { useCardsStore } from 'features/CardsStore'
-import { SolidButton } from 'features/UserAccount/styled'
+import { ArrowLoader } from 'features/ArrowLoader'
import { ElementContainer } from '../ElementContainer'
@@ -51,6 +51,7 @@ export const AddCardFormInner = (props: Props) => {
error: formError,
handleSubmit,
isLabelVisible,
+ loader,
name,
onInputsBlur,
onInputsChange,
@@ -121,12 +122,7 @@ export const AddCardFormInner = (props: Props) => {
) }
-
- {children || (
-
- Сохранить
-
- )}
+ {loader ? : children}
)
diff --git a/src/features/AddCardForm/index.tsx b/src/features/AddCardForm/index.tsx
index 68e68d07..965e35e8 100644
--- a/src/features/AddCardForm/index.tsx
+++ b/src/features/AddCardForm/index.tsx
@@ -3,13 +3,16 @@ import type { MouseEvent } from 'react'
import { useToggle } from 'hooks'
import { T9n } from 'features/T9n'
-import { OutlineButton, Icon } from 'features/UserAccount/styled'
+import {
+ OutlineButton,
+ Icon,
+ SolidButton,
+} from 'features/UserAccount/styled'
import type { Props } from './components/Form/hooks'
import { AddCardFormInner } from './components/Form'
export const AddCardForm = ({
- children,
initialformOpen,
inputsBackground,
onAddSuccess,
@@ -33,7 +36,9 @@ export const AddCardForm = ({
inputsBackground={inputsBackground}
onAddSuccess={onSuccess}
>
- {children}
+
+ Сохранить
+
)
: (
diff --git a/src/features/ArrowLoader/index.tsx b/src/features/ArrowLoader/index.tsx
new file mode 100644
index 00000000..8e432a21
--- /dev/null
+++ b/src/features/ArrowLoader/index.tsx
@@ -0,0 +1,19 @@
+import { ArrowLoaderProps } from './types'
+import { Wrapper, Arrows } from './styled'
+
+export const ArrowLoader = ({
+ backgroundColor,
+ backgroundSize,
+ disabled,
+ width,
+}: ArrowLoaderProps) => (
+
+
+
+)
+
+export const ArrowLoaderUI = { ArrowLoader, Arrows }
diff --git a/src/features/ArrowLoader/styled.tsx b/src/features/ArrowLoader/styled.tsx
new file mode 100644
index 00000000..9f960bb5
--- /dev/null
+++ b/src/features/ArrowLoader/styled.tsx
@@ -0,0 +1,39 @@
+import styled from 'styled-components/macro'
+import { keyframes } from 'styled-components'
+
+import { ArrowLoaderProps } from './types'
+
+const rotate = keyframes`
+ from {
+ transform: rotate(360deg);
+ }
+
+ to {
+ transform: rotate(0deg);
+ }
+`
+
+export const Wrapper = styled.button`
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
+ border-color: transparent;
+ width: ${({ width = 'auto' }) => width};
+ height: 50px;
+ background-color: ${({ backgroundColor = '#294fc4' }) => backgroundColor};
+ border-radius: 5px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ :disabled {
+ opacity: 0.5;
+ }
+`
+
+export const Arrows = styled.div`
+ width: 36px;
+ height: 34px;
+ background-size: ${({ backgroundSize = 'contain' }) => backgroundSize};
+ background-image: url(/images/arrowGroup.svg);
+ background-repeat: no-repeat;
+ background-position: center;
+ animation: ${rotate} 1s linear infinite;
+ `
diff --git a/src/features/ArrowLoader/types.tsx b/src/features/ArrowLoader/types.tsx
new file mode 100644
index 00000000..48b657a1
--- /dev/null
+++ b/src/features/ArrowLoader/types.tsx
@@ -0,0 +1,6 @@
+export type ArrowLoaderProps = {
+ backgroundColor?: string,
+ backgroundSize?: string,
+ disabled?: boolean,
+ width?:string,
+}
diff --git a/src/features/BuyMatchPopup/components/SubscriptionSelectionStep/index.tsx b/src/features/BuyMatchPopup/components/SubscriptionSelectionStep/index.tsx
index 48496fbf..14a694f4 100644
--- a/src/features/BuyMatchPopup/components/SubscriptionSelectionStep/index.tsx
+++ b/src/features/BuyMatchPopup/components/SubscriptionSelectionStep/index.tsx
@@ -11,6 +11,7 @@ import {
import { T9n } from 'features/T9n'
import { Name } from 'features/Name'
import { useCardsStore } from 'features/CardsStore'
+import { ArrowLoader } from 'features/ArrowLoader'
import { useBuyMatchPopupStore } from '../../store'
import { SelectedCard } from '../SelectedCard'
@@ -32,6 +33,7 @@ export const SubscriptionSelectionStep = () => {
const {
close,
+ loader,
match,
onBuyClick,
selectedSubscription,
@@ -62,12 +64,16 @@ export const SubscriptionSelectionStep = () => {