-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
302b7ee
commit c88b2b6
Showing
7 changed files
with
28 additions
and
300 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
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
92 changes: 6 additions & 86 deletions
92
src/components/CombinationCard/components/HelpText/HelpText.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 |
---|---|---|
@@ -1,96 +1,16 @@ | ||
import React, {useRef} from 'react'; | ||
import {Button, Text, Link, BlockStack} from '@shopify/polaris'; | ||
import React from 'react'; | ||
import {Text, BlockStack} from '@shopify/polaris'; | ||
import {useI18n} from '@shopify/react-i18n'; | ||
import {useAppBridge} from '@shopify/app-bridge-react'; | ||
// import {Modal} from '@shopify/app-bridge/actions'; | ||
// import {Action} from '@shopify/app-bridge/actions/Modal'; | ||
// import {useAppBridge} from '@shopify/app-bridge-react'; | ||
|
||
import {DiscountClass} from '../../../../constants'; | ||
|
||
const DISCOUNT_COMBINATION_MODAL_APP_BRIDGE_URL = | ||
'shopify://app-bridge/modal/discounts-combinations'; | ||
|
||
interface Props { | ||
currentDiscountClass: DiscountClass; | ||
targetDiscountClass: DiscountClass; | ||
count: number; | ||
currentDiscountName: string; | ||
currentDiscountId?: string; | ||
} | ||
|
||
export function HelpText({ | ||
currentDiscountClass, | ||
targetDiscountClass, | ||
currentDiscountId, | ||
count, | ||
currentDiscountName, | ||
}: Props) { | ||
const buttonWrapperRef = useRef<HTMLSpanElement>(null); | ||
export function HelpText({}) { | ||
const [i18n] = useI18n(); | ||
const shopify = useAppBridge(); | ||
|
||
const targetDiscountClassLabel = targetDiscountClass.toLocaleLowerCase(); | ||
const scope = `DiscountAppComponents.CombinationCard.HelpText`; | ||
|
||
const handleModalOpen = () => { | ||
shopify.modal.show(DISCOUNT_COMBINATION_MODAL_APP_BRIDGE_URL); | ||
const test = { | ||
discountOptions: { | ||
currentDiscountName, | ||
currentDiscountClass, | ||
currentDiscountId, | ||
targetDiscountClass, | ||
}, | ||
}; | ||
console.log('test', test); | ||
|
||
shopify.modal.hide(DISCOUNT_COMBINATION_MODAL_APP_BRIDGE_URL); | ||
}; | ||
|
||
return count > 0 ? ( | ||
return ( | ||
<BlockStack> | ||
<Text as="span" tone="subdued"> | ||
{i18n.translate( | ||
'combinations.info', | ||
{scope}, | ||
{ | ||
count, | ||
discountCountLink: ( | ||
<span ref={buttonWrapperRef}> | ||
<Button onClick={handleModalOpen} variant="plain"> | ||
{i18n.translate( | ||
`combinations.counts.${targetDiscountClassLabel}`, | ||
{scope}, | ||
{ | ||
count, | ||
}, | ||
)} | ||
</Button> | ||
</span> | ||
), | ||
}, | ||
)} | ||
</Text> | ||
<Text as="span" tone="subdued"> | ||
{i18n.translate('combinations.multipleEligibleDiscounts', {scope})} | ||
{i18n.translate('combinations.info', {scope})} | ||
</Text> | ||
</BlockStack> | ||
) : ( | ||
<> | ||
<Text as="span" tone="subdued"> | ||
{i18n.translate('title', { | ||
scope: `${scope}.emptyState.${targetDiscountClass.toLowerCase()}`, | ||
})}{' '} | ||
{i18n.translate(`warning.with${currentDiscountClass.toLowerCase()}`, { | ||
scope: `${scope}.emptyState.${targetDiscountClass.toLowerCase()}`, | ||
})}{' '} | ||
<Link | ||
url={`https://help.shopify.com/${i18n.locale}/manual/discounts/combining-discounts`} | ||
external | ||
> | ||
{i18n.translate(`${scope}.emptyState.link`)} | ||
</Link> | ||
</Text> | ||
</> | ||
); | ||
} |
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.