disco
/
backend
/
views
/
components
/
Main
/
pages
/
Rules
/
Tabs
/
DesignBlock
/
BulkBundleDiscountPage
/
BulkBundleDiscountPage.jsx
BulkBundleDiscountPage.jsx in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.21, at backend/views/components/Main/pages/Rules/Tabs/DesignBlock/BulkBundleDiscountPage/BulkBundleDiscountPage.jsx
| 1 | import { __ } from '@wordpress/i18n'; |
| 2 | import { useDispatch, useSelector } from 'react-redux'; |
| 3 | import { updateTable } from '../../../../../features/discount/discountSlice'; |
| 4 | import useIsPro from '../../../../../hooks/useIsPro'; |
| 5 | import BadgeActions from '../components/BadgeActions'; |
| 6 | import BadgeComponentContainer from '../components/BadgeComponentContainer'; |
| 7 | import BadgeTitle from '../components/BadgeTitle'; |
| 8 | import ProFeatureButton from '../components/ProFeatureButton'; |
| 9 | import Status from '../components/Status'; |
| 10 | import DiscountCard from './components/DiscountCard'; |
| 11 | |
| 12 | const BulkBundleDiscountPage = () => { |
| 13 | const { table } = useSelector((state) => state.discount.design_blocks); |
| 14 | const { discount_intent } = useSelector((state) => state.discount); |
| 15 | const dispatch = useDispatch(); |
| 16 | const isPro = useIsPro(); |
| 17 | |
| 18 | const docUrl = |
| 19 | discount_intent === 'Bulk' |
| 20 | ? 'https://discoplugin.com/docs/display-woocommerce-bulk-discount-table/' |
| 21 | : 'https://discoplugin.com/docs/display-bundle-discount-table-in-woocommerce/'; |
| 22 | |
| 23 | const tryNowUrl = |
| 24 | discount_intent === 'Bulk' |
| 25 | ? 'https://discoplugin.com/pricing/?utm_source=bulk-table&utm_medium=free-to-pro&utm_campaign=from-display-page&utm_id=1' |
| 26 | : 'https://discoplugin.com/pricing/?utm_source=bundle-table&utm_medium=free-to-pro&utm_campaign=from-display-page&utm_id=1'; |
| 27 | |
| 28 | const handleStatus = (status) => { |
| 29 | dispatch(updateTable({ name: 'enable', value: status })); |
| 30 | }; |
| 31 | |
| 32 | return ( |
| 33 | <BadgeComponentContainer> |
| 34 | <DiscountCard /> |
| 35 | |
| 36 | <BadgeTitle |
| 37 | title={__(`${discount_intent} Table`, 'disco')} |
| 38 | url={docUrl} |
| 39 | className="disco:mt-3" |
| 40 | /> |
| 41 | |
| 42 | <BadgeActions> |
| 43 | <Status |
| 44 | status={table?.enable || false} |
| 45 | handleStatus={handleStatus} |
| 46 | disabled={!isPro} |
| 47 | dataTestid={`${discount_intent.toLowerCase()}-table-status`} |
| 48 | /> |
| 49 | |
| 50 | <ProFeatureButton |
| 51 | tryNowUrl={tryNowUrl} |
| 52 | componentToEdit="BulkBundleDiscountEdit" |
| 53 | testId={`${discount_intent.toLowerCase()}-table`} |
| 54 | /> |
| 55 | </BadgeActions> |
| 56 | </BadgeComponentContainer> |
| 57 | ); |
| 58 | }; |
| 59 | |
| 60 | export default BulkBundleDiscountPage; |
| 61 |