Modals
1 month ago
skeletons
5 months ago
ActionButton.vue
5 months ago
ActionButtonsSection.vue
5 months ago
Banner.vue
3 months ago
FAQ.vue
5 months ago
FormItem.vue
2 months ago
FormsSection.vue
11 months ago
Hero.vue
1 month ago
Integrations.vue
4 months ago
Pagination.vue
10 months ago
PluginEntriesTable.vue
4 months ago
PluginEntry.vue
5 months ago
PluginExpansion.vue
8 months ago
ReachContactsSummary.vue
2 weeks ago
SyncStatusLabel.vue
6 months ago
Tabs.vue
9 months ago
Toggle.vue
10 months ago
UsageCard.vue
10 months ago
UsageCardsRow.vue
1 year ago
UsageCardsSection.vue
1 year ago
WooCommerce.vue
2 weeks ago
WooCommerceEntriesTable.vue
4 months ago
WooCommerce.vue
97 lines
| 1 | <script setup lang="ts"> |
| 2 | import { HNotificationRow } from '@hostinger/hcomponents'; |
| 3 | import { computed } from 'vue'; |
| 4 | |
| 5 | import Banner from '@/components/Banner.vue'; |
| 6 | import ReachContactsSummary from '@/components/ReachContactsSummary.vue'; |
| 7 | import WooCommerceEntriesTable from '@/components/WooCommerceEntriesTable.vue'; |
| 8 | import { useModal } from '@/composables'; |
| 9 | import { WOOCOMMERCE_ID } from '@/data/pluginData'; |
| 10 | import { TABS_KEYS } from '@/data/tabs'; |
| 11 | import { useIntegrationsStore } from '@/stores/integrationsStore'; |
| 12 | import { ModalName } from '@/types'; |
| 13 | import type { Form } from '@/types/models'; |
| 14 | import { translate } from '@/utils/translate'; |
| 15 | |
| 16 | const emit = defineEmits({ |
| 17 | goToPlugin: (_id: string) => true, |
| 18 | disconnectPlugin: (_id: string) => true, |
| 19 | toggleFormStatus: (_form: Form, _status: boolean) => true, |
| 20 | viewForm: (_form: Form) => true, |
| 21 | editForm: (_form: Form) => true, |
| 22 | addForm: (_id: string) => true |
| 23 | }); |
| 24 | |
| 25 | const { openModal } = useModal(); |
| 26 | const integrationsStore = useIntegrationsStore(); |
| 27 | |
| 28 | const shouldShowTable = computed( |
| 29 | () => |
| 30 | !!integrationsStore?.activeIntegrations.find((i) => i.id === WOOCOMMERCE_ID) || |
| 31 | integrationsStore.hasAnyForms(TABS_KEYS.OVERVIEW_TAB_ECOMMERCE) |
| 32 | ); |
| 33 | |
| 34 | const isBannerVisible = computed(() => !integrationsStore.isLoading && !shouldShowTable.value); |
| 35 | const isTableVisible = computed(() => integrationsStore.isLoading || shouldShowTable.value); |
| 36 | |
| 37 | const connectAndInstallWooCommerce = async () => { |
| 38 | const success = await integrationsStore.toggleIntegrationStatus(WOOCOMMERCE_ID, true); |
| 39 | if (success) { |
| 40 | openModal( |
| 41 | ModalName.SYNC_CONTACTS_MODAL, |
| 42 | { |
| 43 | title: translate('hostinger_reach_contacts_modal_title'), |
| 44 | subtitle: translate('hostinger_reach_contacts_modal_subtitle'), |
| 45 | data: { integrations: [integrationsStore?.activeIntegrations.find((i) => i.id === WOOCOMMERCE_ID)] } |
| 46 | }, |
| 47 | { hasCloseButton: true } |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | return; |
| 52 | }; |
| 53 | </script> |
| 54 | |
| 55 | <template> |
| 56 | <div class="woocommerce"> |
| 57 | <Banner |
| 58 | v-if="isBannerVisible" |
| 59 | :title="translate(`hostinger_reach_ecommerce_banner_title`)" |
| 60 | :description="translate(`hostinger_reach_ecommerce_banner_description`)" |
| 61 | :button-text="translate(`hostinger_reach_ecommerce_banner_button_text`)" |
| 62 | :on-button-click="connectAndInstallWooCommerce" |
| 63 | :is-button-loading="integrationsStore.isLoading" |
| 64 | /> |
| 65 | |
| 66 | <ReachContactsSummary v-if="isTableVisible" /> |
| 67 | |
| 68 | <WooCommerceEntriesTable |
| 69 | v-if="isTableVisible" |
| 70 | @go-to-plugin="emit('goToPlugin', $event)" |
| 71 | @disconnect-plugin="emit('disconnectPlugin', $event)" |
| 72 | @toggle-form-status="(form, status) => emit('toggleFormStatus', form, status)" |
| 73 | /> |
| 74 | |
| 75 | <HNotificationRow |
| 76 | v-if="shouldShowTable" |
| 77 | :show-close-icon="false" |
| 78 | :label="translate('hostinger_reach_woocommerce_connected_title')" |
| 79 | :description="translate('hostinger_reach_woocommerce_connected_text')" |
| 80 | :primary-action-text="translate('hostinger_reach_woocommerce_connected_button')" |
| 81 | variant="info" |
| 82 | :primary-action-props="{ iconAppend: 'ic-arrow-up-right-square-16', variant: 'outlineStrong' }" |
| 83 | @primary-action-click="emit('goToPlugin', WOOCOMMERCE_ID)" |
| 84 | /> |
| 85 | </div> |
| 86 | </template> |
| 87 | |
| 88 | <style scoped lang="scss"> |
| 89 | .woocommerce { |
| 90 | display: flex; |
| 91 | flex-direction: column; |
| 92 | align-self: stretch; |
| 93 | gap: 20px; |
| 94 | margin-bottom: 40px; |
| 95 | } |
| 96 | </style> |
| 97 |