-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tackle pr comments and revert some incorrect changes
- Loading branch information
1 parent
ec61a8f
commit a3b6c71
Showing
14 changed files
with
213 additions
and
106 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
@use '@jwp/ott-ui-react/src/styles/variables'; | ||
@use '@jwp/ott-ui-react/src/styles/theme'; | ||
|
||
.topContainer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
padding-top: 40px; | ||
row-gap: 32px; | ||
|
||
.circleHug { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 80px; | ||
height: 80px; | ||
border: 2px solid variables.$green; | ||
border-radius: 50%; | ||
} | ||
} | ||
|
||
.innerContainer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
row-gap: 8px; | ||
|
||
.title { | ||
font-weight: var(--body-font-weight-bold); | ||
font-size: 24px; | ||
} | ||
|
||
.message { | ||
margin: 0; | ||
font-size: 16px; | ||
text-align: center; | ||
} | ||
} | ||
|
||
.buttonContainer { | ||
align-self: stretch; | ||
} | ||
|
||
.welcome { | ||
h2 { | ||
font-weight: var(--body-font-weight-bold); | ||
font-size: 24px; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { act, fireEvent, render } from '@testing-library/react'; | ||
|
||
import PaymentSuccessful from './PaymentSuccessful'; | ||
|
||
describe('<PaymentSuccessful>', () => { | ||
test('renders and matches snapshot', () => { | ||
const { container } = render(<PaymentSuccessful siteName="Sitename!" />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
test('calls the onCloseButtonClick callback when clicking the close button', () => { | ||
const onCloseButtonClick = vi.fn(); | ||
const { getByText } = render(<PaymentSuccessful onCloseButtonClick={onCloseButtonClick} siteName="Sitename!" />); | ||
|
||
fireEvent.click(getByText('checkout.start_watching')); | ||
|
||
expect(onCloseButtonClick).toBeCalled(); | ||
}); | ||
|
||
test('calls the onCloseButtonClick callback when clicking the close button', () => { | ||
vi.useFakeTimers(); | ||
const onCountdownCompleted = vi.fn(); | ||
|
||
render(<PaymentSuccessful onCountdownCompleted={onCountdownCompleted} siteName="Sitename!" />); | ||
|
||
let i = 10; | ||
while (i--) { | ||
act(() => { | ||
vi.runAllTimers(); | ||
}); | ||
} | ||
|
||
expect(onCountdownCompleted).toBeCalled(); | ||
vi.useRealTimers(); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import CheckmarkSVG from '@jwp/ott-theme/assets/icons/check-green.svg?react'; | ||
import useCountdown from '@jwp/ott-hooks-react/src/useCountdown'; | ||
|
||
import Button from '../Button/Button'; | ||
|
||
import styles from './PaymentSuccessful.module.scss'; | ||
|
||
type Props = { | ||
onCloseButtonClick?: () => void; | ||
onCountdownCompleted?: () => void; | ||
siteName?: string; | ||
}; | ||
|
||
const PaymentSuccessful: React.FC<Props> = ({ onCloseButtonClick, onCountdownCompleted, siteName }) => { | ||
const { t } = useTranslation('account'); | ||
const countdown = useCountdown(10, 1, onCountdownCompleted); | ||
|
||
return ( | ||
<div className={styles.topContainer}> | ||
<div className={styles.circleHug}> | ||
<CheckmarkSVG /> | ||
</div> | ||
<div className={styles.innerContainer}> | ||
<h2 className={styles.title}>{t('checkout.payment_successful_title')}</h2> | ||
<p className={styles.message}>{t('checkout.payment_successful_description', { siteName })}</p> | ||
</div> | ||
<div className={styles.buttonContainer}> | ||
<Button label={t('checkout.start_watching', { countdown })} onClick={onCloseButtonClick} color="primary" variant="contained" size="large" fullWidth /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PaymentSuccessful; |
55 changes: 55 additions & 0 deletions
55
...s/ui-react/src/components/PaymentSuccessful/__snapshots__/PaymentSuccessful.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`<PaymentSuccessful> > renders and matches snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="_topContainer_4874d7" | ||
> | ||
<div | ||
class="_circleHug_4874d7" | ||
> | ||
<svg | ||
fill="none" | ||
height="65" | ||
viewBox="0 0 64 65" | ||
width="64" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M13.3333 32.6663L26.6666 45.9997L53.3333 19.333" | ||
stroke="#5aae4a" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="1.6" | ||
/> | ||
</svg> | ||
</div> | ||
<div | ||
class="_innerContainer_4874d7" | ||
> | ||
<h2 | ||
class="_title_4874d7" | ||
> | ||
checkout.payment_successful_title | ||
</h2> | ||
<p | ||
class="_message_4874d7" | ||
> | ||
checkout.payment_successful_description | ||
</p> | ||
</div> | ||
<div | ||
class="_buttonContainer_4874d7" | ||
> | ||
<button | ||
class="_button_f8f296 _primary_f8f296 _fullWidth_f8f296 _large_f8f296" | ||
type="button" | ||
> | ||
<span> | ||
checkout.start_watching | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
42 changes: 1 addition & 41 deletions
42
packages/ui-react/src/components/Welcome/Welcome.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,9 @@ | ||
@use '@jwp/ott-ui-react/src/styles/variables'; | ||
@use '@jwp/ott-ui-react/src/styles/theme'; | ||
|
||
.topContainer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
padding-top: 40px; | ||
row-gap: 32px; | ||
|
||
.circleHug { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 80px; | ||
height: 80px; | ||
border: 2px solid variables.$green; | ||
border-radius: 50%; | ||
} | ||
} | ||
|
||
.innerContainer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
row-gap: 8px; | ||
|
||
.title { | ||
font-weight: var(--body-font-weight-bold); | ||
font-size: 24px; | ||
} | ||
|
||
.message { | ||
margin: 0; | ||
font-size: 16px; | ||
text-align: center; | ||
} | ||
} | ||
|
||
.buttonContainer { | ||
align-self: stretch; | ||
} | ||
|
||
.welcome { | ||
h2 { | ||
font-weight: var(--body-font-weight-bold); | ||
font-size: 24px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.