fix: rearrange settings items

This commit is contained in:
Shariq Ansari 2024-06-19 13:55:24 +05:30
parent 756b24038a
commit 30532fb1c3

View File

@ -3,42 +3,31 @@
<template #body>
<div class="flex h-[calc(100vh_-_8rem)]">
<div class="flex w-52 shrink-0 flex-col bg-gray-50 p-2">
<h1 class="px-2 pt-2 text-lg font-semibold">
<h1 class="mb-3 px-2 pt-2 text-lg font-semibold">
{{ __('Settings') }}
</h1>
<nav class="mt-3 space-y-1">
<SidebarLink
v-for="tab in tabs"
:icon="tab.icon"
:label="__(tab.label)"
class="w-full"
:class="
activeTab?.label == tab.label
? 'bg-white shadow-sm'
: 'hover:bg-gray-100'
"
@click="activeTab = tab"
/>
</nav>
<div
class="mb-2 mt-3 flex cursor-pointer gap-1.5 px-1 text-base font-medium text-gray-600 transition-all duration-300 ease-in-out"
>
<span>{{ __('Integrations') }}</span>
<div v-for="tab in tabs">
<div
v-if="!tab.hideLabel"
class="mb-2 mt-3 flex cursor-pointer gap-1.5 px-1 text-base font-medium text-gray-600 transition-all duration-300 ease-in-out"
>
<span>{{ __(tab.label) }}</span>
</div>
<nav class="space-y-1">
<SidebarLink
v-for="i in tab.items"
:icon="i.icon"
:label="__(i.label)"
class="w-full"
:class="
activeTab?.label == i.label
? 'bg-white shadow-sm'
: 'hover:bg-gray-100'
"
@click="activeTab = i"
/>
</nav>
</div>
<nav class="space-y-1">
<SidebarLink
v-for="i in integrations"
:icon="i.icon"
:label="__(i.label)"
class="w-full"
:class="
activeTab?.label == i.label
? 'bg-white shadow-sm'
: 'hover:bg-gray-100'
"
@click="activeTab = i"
/>
</nav>
</div>
<div class="flex flex-1 flex-col overflow-y-auto">
<component :is="activeTab.component" v-if="activeTab" />
@ -62,38 +51,53 @@ import { ref, markRaw, computed, h } from 'vue'
const show = defineModel()
let tabs = [
{
label: 'Profile',
icon: ContactsIcon,
component: markRaw(ProfileSettings),
},
{
label: 'Fields Layout',
icon: h(FeatherIcon, { name: 'grid' }),
component: markRaw(FieldsLayout),
},
]
let integrations = computed(() => {
let items = [
const tabs = computed(() => {
let _tabs = [
{
label: 'Twilio',
icon: PhoneIcon,
component: markRaw(TwilioSettings),
label: 'Settings',
hideLabel: true,
items: [
{
label: 'Profile',
icon: ContactsIcon,
component: markRaw(ProfileSettings),
},
],
},
{
label: 'Integrations',
items: [
{
label: 'Twilio',
icon: PhoneIcon,
component: markRaw(TwilioSettings),
},
{
label: 'WhatsApp',
icon: WhatsAppIcon,
component: markRaw(WhatsAppSettings),
condition: () => isWhatsappInstalled.value,
},
],
},
{
label: 'Customizations',
items: [
{
label: 'Fields Layout',
icon: h(FeatherIcon, { name: 'grid' }),
component: markRaw(FieldsLayout),
},
],
},
]
if (isWhatsappInstalled.value) {
items.push({
label: 'WhatsApp',
icon: WhatsAppIcon,
component: markRaw(WhatsAppSettings),
return _tabs.filter((tab) => {
return tab.items.some((item) => {
return item.condition ? item.condition() : true
})
}
return items
})
})
const activeTab = ref(tabs[0])
const activeTab = ref(tabs.value[0].items[0])
</script>