Modals
1 month ago
skeletons
4 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
4 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
FormsSection.vue
112 lines
| 1 | <script setup lang="ts"> |
| 2 | import { computed } from 'vue'; |
| 3 | |
| 4 | import reachOverviewBannerBackground from '@/assets/images/backgrounds/overview-banner-background.png'; |
| 5 | import Banner from '@/components/Banner.vue'; |
| 6 | import PluginEntriesTable from '@/components/PluginEntriesTable.vue'; |
| 7 | import { useModal } from '@/composables/useModal'; |
| 8 | import { useIntegrationsStore } from '@/stores/integrationsStore'; |
| 9 | import { ModalName } from '@/types/enums'; |
| 10 | import type { Form } from '@/types/models'; |
| 11 | import { translate } from '@/utils/translate'; |
| 12 | |
| 13 | const emit = defineEmits<{ |
| 14 | goToPlugin: [id: string]; |
| 15 | disconnectPlugin: [id: string]; |
| 16 | toggleFormStatus: [form: Form, status: boolean]; |
| 17 | viewForm: [form: Form]; |
| 18 | editForm: [form: Form]; |
| 19 | addForm: [id: string]; |
| 20 | }>(); |
| 21 | |
| 22 | const { openModal } = useModal(); |
| 23 | const integrationsStore = useIntegrationsStore(); |
| 24 | |
| 25 | const handleAddForm = () => { |
| 26 | openModal(ModalName.ADD_FORM_MODAL, {}, { hasCloseButton: true }); |
| 27 | }; |
| 28 | |
| 29 | const shouldShowTable = computed( |
| 30 | () => integrationsStore?.activeIntegrations?.length > 1 || integrationsStore.hasAnyForms |
| 31 | ); |
| 32 | const isBannerVisible = computed(() => !integrationsStore.isLoading && !shouldShowTable.value); |
| 33 | const isTableVisible = computed(() => integrationsStore.isLoading || shouldShowTable.value); |
| 34 | const isAddButtonVisible = computed(() => !integrationsStore.isLoading && shouldShowTable.value); |
| 35 | </script> |
| 36 | |
| 37 | <template> |
| 38 | <div class="forms-section"> |
| 39 | <div class="forms-section__header"> |
| 40 | <HText as="h1" variant="heading-1"> |
| 41 | {{ translate('hostinger_reach_forms_title') }} |
| 42 | </HText> |
| 43 | <span> |
| 44 | <HButton |
| 45 | v-if="isAddButtonVisible" |
| 46 | variant="outline" |
| 47 | color="neutral" |
| 48 | size="small" |
| 49 | icon-prepend="ic-plus-16" |
| 50 | :is-loading="integrationsStore.isLoading" |
| 51 | @click="handleAddForm" |
| 52 | > |
| 53 | {{ translate('hostinger_reach_forms_add_more_button_text') }} |
| 54 | </HButton> |
| 55 | </span> |
| 56 | </div> |
| 57 | |
| 58 | <Banner |
| 59 | v-if="isBannerVisible" |
| 60 | :title="translate('hostinger_reach_forms_card_title')" |
| 61 | :description="translate('hostinger_reach_forms_card_description')" |
| 62 | :button-text="translate('hostinger_reach_forms_card_button_text')" |
| 63 | :on-button-click="handleAddForm" |
| 64 | :is-button-loading="integrationsStore.isLoading" |
| 65 | :background-image="reachOverviewBannerBackground" |
| 66 | /> |
| 67 | |
| 68 | <PluginEntriesTable |
| 69 | v-if="isTableVisible" |
| 70 | :integrations="integrationsStore.integrations" |
| 71 | :is-loading="integrationsStore.isLoading" |
| 72 | @go-to-plugin="emit('goToPlugin', $event)" |
| 73 | @disconnect-plugin="emit('disconnectPlugin', $event)" |
| 74 | @toggle-form-status="(form, status) => emit('toggleFormStatus', form, status)" |
| 75 | @view-form="emit('viewForm', $event)" |
| 76 | @edit-form="emit('editForm', $event)" |
| 77 | @add-form="emit('addForm', $event)" |
| 78 | /> |
| 79 | </div> |
| 80 | </template> |
| 81 | |
| 82 | <style scoped lang="scss"> |
| 83 | .forms-section { |
| 84 | display: flex; |
| 85 | flex-direction: column; |
| 86 | align-self: stretch; |
| 87 | gap: 20px; |
| 88 | |
| 89 | &__header { |
| 90 | display: flex; |
| 91 | justify-content: space-between; |
| 92 | align-items: center; |
| 93 | align-self: stretch; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | @media (max-width: 1023px) { |
| 98 | .forms-section { |
| 99 | &__header { |
| 100 | flex-direction: column; |
| 101 | align-items: flex-start; |
| 102 | gap: 12px; |
| 103 | |
| 104 | > :last-child { |
| 105 | align-self: stretch; |
| 106 | justify-content: flex-end; |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | </style> |
| 112 |