mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
<img width="1439" alt="Screenshot 2024-10-30 at 8 58 12 PM" src="https://github.com/user-attachments/assets/26231270-5e73-40fb-9efa-c661585ebe7c"> Fixes https://linear.app/chatwoot/project/campaign-redesign-f82bede26ca7/overview --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
76 lines
2.5 KiB
Vue
76 lines
2.5 KiB
Vue
<script setup>
|
|
import { computed, ref } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useToggle } from '@vueuse/core';
|
|
import { useStoreGetters, useMapGetter } from 'dashboard/composables/store';
|
|
import { CAMPAIGN_TYPES } from 'shared/constants/campaign.js';
|
|
|
|
import Spinner from 'dashboard/components-next/spinner/Spinner.vue';
|
|
import CampaignLayout from 'dashboard/components-next/Campaigns/CampaignLayout.vue';
|
|
import CampaignList from 'dashboard/components-next/Campaigns/Pages/CampaignPage/CampaignList.vue';
|
|
import SMSCampaignDialog from 'dashboard/components-next/Campaigns/Pages/CampaignPage/SMSCampaign/SMSCampaignDialog.vue';
|
|
import ConfirmDeleteCampaignDialog from 'dashboard/components-next/Campaigns/Pages/CampaignPage/ConfirmDeleteCampaignDialog.vue';
|
|
import SMSCampaignEmptyState from 'dashboard/components-next/Campaigns/EmptyState/SMSCampaignEmptyState.vue';
|
|
|
|
const { t } = useI18n();
|
|
const getters = useStoreGetters();
|
|
|
|
const selectedCampaign = ref(null);
|
|
const [showSMSCampaignDialog, toggleSMSCampaignDialog] = useToggle();
|
|
|
|
const uiFlags = useMapGetter('campaigns/getUIFlags');
|
|
const isFetchingCampaigns = computed(() => uiFlags.value.isFetching);
|
|
|
|
const confirmDeleteCampaignDialogRef = ref(null);
|
|
|
|
const SMSCampaigns = computed(() =>
|
|
getters['campaigns/getCampaigns'].value(CAMPAIGN_TYPES.ONE_OFF)
|
|
);
|
|
|
|
const hasNoSMSCampaigns = computed(
|
|
() => SMSCampaigns.value?.length === 0 && !isFetchingCampaigns.value
|
|
);
|
|
|
|
const handleDelete = campaign => {
|
|
selectedCampaign.value = campaign;
|
|
confirmDeleteCampaignDialogRef.value.dialogRef.open();
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<CampaignLayout
|
|
:header-title="t('CAMPAIGN.SMS.HEADER_TITLE')"
|
|
:button-label="t('CAMPAIGN.SMS.NEW_CAMPAIGN')"
|
|
@click="toggleSMSCampaignDialog()"
|
|
@close="toggleSMSCampaignDialog(false)"
|
|
>
|
|
<template #action>
|
|
<SMSCampaignDialog
|
|
v-if="showSMSCampaignDialog"
|
|
@close="toggleSMSCampaignDialog(false)"
|
|
/>
|
|
</template>
|
|
<div
|
|
v-if="isFetchingCampaigns"
|
|
class="flex items-center justify-center py-10 text-n-slate-11"
|
|
>
|
|
<Spinner />
|
|
</div>
|
|
<CampaignList
|
|
v-else-if="!hasNoSMSCampaigns"
|
|
:campaigns="SMSCampaigns"
|
|
@delete="handleDelete"
|
|
/>
|
|
<SMSCampaignEmptyState
|
|
v-else
|
|
:title="t('CAMPAIGN.SMS.EMPTY_STATE.TITLE')"
|
|
:subtitle="t('CAMPAIGN.SMS.EMPTY_STATE.SUBTITLE')"
|
|
class="pt-14"
|
|
/>
|
|
<ConfirmDeleteCampaignDialog
|
|
ref="confirmDeleteCampaignDialogRef"
|
|
:selected-campaign="selectedCampaign"
|
|
/>
|
|
</CampaignLayout>
|
|
</template>
|