-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A4A: Show referral order confirmation message. (#91675)
* Add NewReferralOrderNotification component. * Make official A4A layout banner and use it in the new Referral order notification. * Update Referral checkout to use refferal email to show new referral order notification. * Fix typo.
- Loading branch information
1 parent
aebf6a0
commit 0002f95
Showing
8 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
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,24 @@ | ||
import NoticeBanner from '@automattic/components/src/notice-banner'; | ||
import clsx from 'clsx'; | ||
import { ReactNode } from 'react'; | ||
|
||
type Props = { | ||
actions?: React.ReactNode[]; | ||
className?: string; | ||
children: ReactNode; | ||
level: 'error' | 'warning' | 'info' | 'success'; | ||
onClose?: () => void; | ||
title?: string; | ||
}; | ||
|
||
export default function LayoutBanner( { className, children, onClose, title, actions }: Props ) { | ||
const wrapperClass = clsx( className, 'a4a-layout__banner' ); | ||
|
||
return ( | ||
<div className={ wrapperClass }> | ||
<NoticeBanner level="success" onClose={ onClose } title={ title } actions={ actions }> | ||
{ children } | ||
</NoticeBanner> | ||
</div> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useCallback } from 'react'; | ||
import { useURLQueryParams } from 'calypso/jetpack-cloud/sections/partner-portal/hooks'; | ||
|
||
export default function useUrlQueryParam( key: string ) { | ||
const { setParams, resetParams, getParamValue } = useURLQueryParams(); | ||
|
||
const setValue = useCallback( | ||
( value: string ) => { | ||
if ( value ) { | ||
setParams( [ | ||
{ | ||
key: key, | ||
value, | ||
}, | ||
] ); | ||
} else { | ||
resetParams( [ key ] ); | ||
} | ||
}, | ||
[ key, resetParams, setParams ] | ||
); | ||
|
||
return { | ||
value: getParamValue( key ), | ||
setValue, | ||
}; | ||
} |
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
30 changes: 30 additions & 0 deletions
30
...gencies/sections/referrals/primary/referrals-overview/new-referral-order-notification.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,30 @@ | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { useState } from 'react'; | ||
import LayoutBanner from 'calypso/a8c-for-agencies/components/layout/banner'; | ||
|
||
type Props = { | ||
email: string; | ||
onClose?: () => void; | ||
}; | ||
|
||
export default function NewReferralOrderNotification( { email, onClose }: Props ) { | ||
const [ showBanner, setShowBanner ] = useState( true ); | ||
|
||
const translate = useTranslate(); | ||
|
||
const onCloseClick = () => { | ||
setShowBanner( false ); | ||
onClose?.(); | ||
}; | ||
|
||
return ( | ||
showBanner && ( | ||
<LayoutBanner level="success" onClose={ onCloseClick }> | ||
{ translate( 'Your referral order was emailed to %(referralEmail)s for payment.', { | ||
args: { referralEmail: email }, | ||
comment: 'The %(referralEmail)s is the email where referral order was sent.', | ||
} ) } | ||
</LayoutBanner> | ||
) | ||
); | ||
} |
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