@@ -11,6 +11,9 @@ import {
1111 faGlobe ,
1212 faPenToSquare ,
1313 faTrash ,
14+ faCirclePause ,
15+ faCirclePlay ,
16+ faCircleCheck ,
1417} from ' @fortawesome/free-solid-svg-icons'
1518import { FontAwesomeIcon } from ' @fortawesome/vue-fontawesome'
1619import {
@@ -34,9 +37,12 @@ import { computed, ref, watch } from 'vue'
3437import CreateOrEditDistributorDrawer from ' ./CreateOrEditDistributorDrawer.vue'
3538import { useI18n } from ' vue-i18n'
3639import DeleteDistributorModal from ' ./DeleteDistributorModal.vue'
40+ import SuspendDistributorModal from ' ./SuspendDistributorModal.vue'
41+ import ReactivateDistributorModal from ' ./ReactivateDistributorModal.vue'
3742import { savePageSizeToStorage } from ' @/lib/tablePageSize'
3843import { useDistributors } from ' @/queries/distributors'
3944import { canManageDistributors } from ' @/lib/permissions'
45+ import { useLoginStore } from ' @/stores/login'
4046
4147const { isShownCreateDistributorDrawer = false } = defineProps <{
4248 isShownCreateDistributorDrawer: boolean
@@ -45,6 +51,7 @@ const { isShownCreateDistributorDrawer = false } = defineProps<{
4551const emit = defineEmits ([' close-drawer' ])
4652
4753const { t } = useI18n ()
54+ const loginStore = useLoginStore ()
4855const {
4956 state,
5057 asyncStatus,
@@ -59,6 +66,8 @@ const {
5966const currentDistributor = ref <Distributor | undefined >()
6067const isShownCreateOrEditDistributorDrawer = ref (false )
6168const isShownDeleteDistributorDrawer = ref (false )
69+ const isShownSuspendDistributorModal = ref (false )
70+ const isShownReactivateDistributorModal = ref (false )
6271
6372const distributorsPage = computed (() => {
6473 return state .value .data ?.distributors
@@ -113,22 +122,56 @@ function showDeleteDistributorDrawer(distributor: Distributor) {
113122 isShownDeleteDistributorDrawer .value = true
114123}
115124
125+ function showSuspendDistributorModal(distributor : Distributor ) {
126+ currentDistributor .value = distributor
127+ isShownSuspendDistributorModal .value = true
128+ }
129+
130+ function showReactivateDistributorModal(distributor : Distributor ) {
131+ currentDistributor .value = distributor
132+ isShownReactivateDistributorModal .value = true
133+ }
134+
116135function onCloseDrawer() {
117136 isShownCreateOrEditDistributorDrawer .value = false
118137 emit (' close-drawer' )
119138}
120139
121140function getKebabMenuItems(distributor : Distributor ) {
122- return [
123- {
141+ const items = []
142+
143+ if (loginStore .isOwner ) {
144+ if (distributor .suspended_at ) {
145+ items .push ({
146+ id: ' reactivateDistributor' ,
147+ label: t (' common.reactivate' ),
148+ icon: faCirclePlay ,
149+ action : () => showReactivateDistributorModal (distributor ),
150+ disabled: asyncStatus .value === ' loading' ,
151+ })
152+ } else {
153+ items .push ({
154+ id: ' suspendDistributor' ,
155+ label: t (' common.suspend' ),
156+ icon: faCirclePause ,
157+ action : () => showSuspendDistributorModal (distributor ),
158+ disabled: asyncStatus .value === ' loading' ,
159+ })
160+ }
161+ }
162+
163+ if (canManageDistributors ()) {
164+ items .push ({
124165 id: ' deleteDistributor' ,
125166 label: t (' common.delete' ),
126167 icon: faTrash ,
127168 danger: true ,
128169 action : () => showDeleteDistributorDrawer (distributor ),
129170 disabled: asyncStatus .value === ' loading' ,
130- },
131- ]
171+ })
172+ }
173+
174+ return items
132175}
133176
134177const onSort = (payload : SortEvent ) => {
@@ -188,6 +231,7 @@ const onSort = (payload: SortEvent) => {
188231 :options =" [
189232 { id: 'name', label: t('organizations.name') },
190233 { id: 'description', label: t('organizations.description') },
234+ { id: 'suspended_at', label: t('common.status') },
191235 ]"
192236 :open-menu-aria-label =" t('ne_dropdown.open_menu')"
193237 :sort-by-label =" t('sort.sort_by')"
@@ -235,6 +279,9 @@ const onSort = (payload: SortEvent) => {
235279 <NeTableHeadCell sortable column-key =" description" @sort =" onSort" >{{
236280 $t('organizations.description')
237281 }}</NeTableHeadCell >
282+ <NeTableHeadCell sortable column-key =" suspended_at" @sort =" onSort" >{{
283+ $t('common.status')
284+ }}</NeTableHeadCell >
238285 <NeTableHeadCell >
239286 <!-- no header for actions -->
240287 </NeTableHeadCell >
@@ -247,6 +294,30 @@ const onSort = (payload: SortEvent) => {
247294 <NeTableCell :data-label =" $t('organizations.description')" >
248295 {{ item.description || '-' }}
249296 </NeTableCell >
297+ <NeTableCell :data-label =" $t('common.status')" >
298+ <div class =" flex items-center gap-2" >
299+ <template v-if =" item .suspended_at " >
300+ <FontAwesomeIcon
301+ :icon =" faCirclePause"
302+ class =" size-4 text-gray-700 dark:text-gray-400"
303+ aria-hidden =" true"
304+ />
305+ <span >
306+ {{ t('common.suspended') }}
307+ </span >
308+ </template >
309+ <template v-else >
310+ <FontAwesomeIcon
311+ :icon =" faCircleCheck"
312+ class =" size-4 text-green-600 dark:text-green-400"
313+ aria-hidden =" true"
314+ />
315+ <span >
316+ {{ t('common.enabled') }}
317+ </span >
318+ </template >
319+ </div >
320+ </NeTableCell >
250321 <NeTableCell :data-label =" $t('common.actions')" >
251322 <div v-if =" canManageDistributors()" class =" -ml-2.5 flex gap-2 xl:ml-0 xl:justify-end" >
252323 <NeButton
@@ -303,5 +374,17 @@ const onSort = (payload: SortEvent) => {
303374 :distributor =" currentDistributor"
304375 @close =" isShownDeleteDistributorDrawer = false"
305376 />
377+ <!-- suspend distributor modal -->
378+ <SuspendDistributorModal
379+ :visible =" isShownSuspendDistributorModal"
380+ :distributor =" currentDistributor"
381+ @close =" isShownSuspendDistributorModal = false"
382+ />
383+ <!-- reactivate distributor modal -->
384+ <ReactivateDistributorModal
385+ :visible =" isShownReactivateDistributorModal"
386+ :distributor =" currentDistributor"
387+ @close =" isShownReactivateDistributorModal = false"
388+ />
306389 </div >
307390</template >
0 commit comments