Files
crater/resources/scripts/admin/components/dropdowns/CustomerIndexDropdown.vue
Yash Kanakiya f6639f5863 add dark dropdown & company switch (#1167)
* add dark mode in basedropdown

* dark mod add in global search, header

* add dark mode in company switch

* indentation issue fix company switch

* fix dropdown issues

---------

Co-authored-by: yogesh-gohil <yogeshgohil1611@gmail.com>
2023-03-28 11:30:00 +05:30

115 lines
3.0 KiB
Vue

<template>
<BaseDropdown :content-loading="customerStore.isFetchingViewData">
<template #activator>
<BaseButton v-if="route.name === 'customers.view'" variant="primary">
<BaseIcon name="DotsHorizontalIcon" class="h-5 text-white" />
</BaseButton>
<BaseIcon v-else name="DotsHorizontalIcon" class="h-5 text-gray-500" />
</template>
<!-- Edit Customer -->
<router-link
v-if="userStore.hasAbilities(abilities.EDIT_CUSTOMER)"
:to="`/admin/customers/${row.id}/edit`"
>
<BaseDropdownItem v-slot="slotProps">
<BaseIcon
name="PencilIcon"
:class="slotProps.class"
/>
{{ $t('general.edit') }}
</BaseDropdownItem>
</router-link>
<!-- View Customer -->
<router-link
v-if="
route.name !== 'customers.view' &&
userStore.hasAbilities(abilities.VIEW_CUSTOMER)
"
:to="`customers/${row.id}/view`"
>
<BaseDropdownItem v-slot="slotProps">
<BaseIcon
name="EyeIcon"
:class="slotProps.class"
/>
{{ $t('general.view') }}
</BaseDropdownItem>
</router-link>
<!-- Delete Customer -->
<BaseDropdownItem
v-if="userStore.hasAbilities(abilities.DELETE_CUSTOMER)"
v-slot="slotProps"
@click="removeCustomer(row.id)"
>
<BaseIcon
name="TrashIcon"
:class="slotProps.class"
/>
{{ $t('general.delete') }}
</BaseDropdownItem>
</BaseDropdown>
</template>
<script setup>
import { useCustomerStore } from '@/scripts/admin/stores/customer'
import { useNotificationStore } from '@/scripts/stores/notification'
import { useDialogStore } from '@/scripts/stores/dialog'
import { useModalStore } from '@/scripts/stores/modal'
import { useI18n } from 'vue-i18n'
import { useRoute, useRouter } from 'vue-router'
import { useUserStore } from '@/scripts/admin/stores/user'
import { inject } from 'vue'
import abilities from '@/scripts/admin/stub/abilities'
const props = defineProps({
row: {
type: Object,
default: null,
},
table: {
type: Object,
default: null,
},
loadData: {
type: Function,
default: () => {},
},
})
const customerStore = useCustomerStore()
const notificationStore = useNotificationStore()
const dialogStore = useDialogStore()
const userStore = useUserStore()
const { t } = useI18n()
const route = useRoute()
const router = useRouter()
const utils = inject('utils')
function removeCustomer(id) {
dialogStore
.openDialog({
title: t('general.are_you_sure'),
message: t('customers.confirm_delete', 1),
yesLabel: t('general.ok'),
noLabel: t('general.cancel'),
variant: 'danger',
hideNoButton: false,
size: 'lg',
})
.then((res) => {
if (res) {
customerStore.deleteCustomer({ ids: [id] }).then((response) => {
if (response.data.success) {
props.loadData && props.loadData()
return true
}
})
}
})
}
</script>