Chat settings in Super Admin and changing the chat title and position.
This commit is contained in:
@@ -4,10 +4,12 @@ import axios from 'axios';
|
||||
import type {
|
||||
ApplyBillingPlanRequest,
|
||||
BillingPlanCode,
|
||||
ConversationSettingsDto,
|
||||
CreatePlatformOrganizationRequest,
|
||||
OrgModuleKey,
|
||||
PlatformOrganizationDto,
|
||||
PlatformUserDto,
|
||||
UpdateConversationSettingsRequest,
|
||||
UpdatePlatformOrganizationRequest,
|
||||
UserRole,
|
||||
} from '@mento/shared';
|
||||
@@ -55,6 +57,16 @@ const editForm = reactive({
|
||||
const moduleDraft = ref<OrgModuleKey[]>([]);
|
||||
const savingModules = ref(false);
|
||||
|
||||
const chatForm = reactive({
|
||||
chatHost: '',
|
||||
apiKey: '',
|
||||
uploadUrl: '',
|
||||
downloadUrl: '',
|
||||
});
|
||||
const chatApiKeySet = ref(false);
|
||||
const savingChat = ref(false);
|
||||
const chatLoadedFor = ref<string | null>(null);
|
||||
|
||||
function fieldLabel(value?: string | null) {
|
||||
if (!value) return '—';
|
||||
return isBusinessField(value) ? BUSINESS_FIELD_LABELS[value] : value;
|
||||
@@ -98,6 +110,7 @@ async function toggleOpen(org: PlatformOrganizationDto) {
|
||||
openId.value = null;
|
||||
detail.value = null;
|
||||
editingId.value = null;
|
||||
chatLoadedFor.value = null;
|
||||
return;
|
||||
}
|
||||
openId.value = org.id;
|
||||
@@ -108,11 +121,56 @@ async function toggleOpen(org: PlatformOrganizationDto) {
|
||||
);
|
||||
detail.value = data;
|
||||
moduleDraft.value = [...(data.enabledModules ?? [])];
|
||||
await loadChatSettings(org.id);
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'بارگذاری اعضا ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
async function loadChatSettings(orgId: string) {
|
||||
try {
|
||||
const { data } = await platformApi.get<ConversationSettingsDto>(
|
||||
`/platform/organizations/${orgId}/conversations/settings`,
|
||||
);
|
||||
chatForm.chatHost = data.chatHost;
|
||||
chatForm.uploadUrl = data.uploadUrl;
|
||||
chatForm.downloadUrl = data.downloadUrl;
|
||||
chatApiKeySet.value = data.apiKeySet;
|
||||
chatForm.apiKey = '';
|
||||
chatLoadedFor.value = orgId;
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'بارگذاری تنظیمات گفتگو ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
async function saveChatSettings(orgId: string) {
|
||||
savingChat.value = true;
|
||||
error.value = '';
|
||||
success.value = '';
|
||||
try {
|
||||
const payload: UpdateConversationSettingsRequest = {
|
||||
chatHost: chatForm.chatHost.trim(),
|
||||
uploadUrl: chatForm.uploadUrl.trim() || undefined,
|
||||
downloadUrl: chatForm.downloadUrl.trim() || undefined,
|
||||
};
|
||||
if (chatForm.apiKey.trim()) payload.apiKey = chatForm.apiKey.trim();
|
||||
const { data } = await platformApi.patch<ConversationSettingsDto>(
|
||||
`/platform/organizations/${orgId}/conversations/settings`,
|
||||
payload,
|
||||
);
|
||||
chatApiKeySet.value = data.apiKeySet;
|
||||
chatForm.apiKey = '';
|
||||
chatForm.chatHost = data.chatHost;
|
||||
chatForm.uploadUrl = data.uploadUrl;
|
||||
chatForm.downloadUrl = data.downloadUrl;
|
||||
success.value = 'تنظیمات گفتگو ذخیره شد';
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'ذخیره تنظیمات گفتگو ناموفق بود');
|
||||
} finally {
|
||||
savingChat.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function startEdit(org: PlatformOrganizationDto) {
|
||||
editingId.value = org.id;
|
||||
editForm.name = org.name;
|
||||
@@ -469,6 +527,51 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="chat-settings">
|
||||
<div class="modules-head">
|
||||
<strong>تنظیمات گفتگو</strong>
|
||||
<button
|
||||
class="btn"
|
||||
type="button"
|
||||
:disabled="savingChat || chatLoadedFor !== org.id"
|
||||
@click="saveChatSettings(org.id)"
|
||||
>
|
||||
{{ savingChat ? 'ذخیره…' : 'ذخیره گفتگو' }}
|
||||
</button>
|
||||
</div>
|
||||
<p class="chat-hint">
|
||||
Host، API Key و آدرس آپلود/دانلود — فقط از سوپرادمین و برای همین محیط.
|
||||
</p>
|
||||
<div class="chat-grid">
|
||||
<label>
|
||||
<span>Host سرویس چت</span>
|
||||
<input
|
||||
v-model="chatForm.chatHost"
|
||||
dir="ltr"
|
||||
placeholder="chat.example.ir"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ chatApiKeySet ? 'API Key (برای تغییر وارد کنید)' : 'API Key' }}</span>
|
||||
<input
|
||||
v-model="chatForm.apiKey"
|
||||
type="password"
|
||||
dir="ltr"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>آدرس آپلود فایل</span>
|
||||
<input v-model="chatForm.uploadUrl" dir="ltr" />
|
||||
</label>
|
||||
<label>
|
||||
<span>آدرس پایه دانلود فایل</span>
|
||||
<input v-model="chatForm.downloadUrl" dir="ltr" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="!detail?.members?.length" class="muted">عضوی ثبت نشده.</p>
|
||||
<ul v-else>
|
||||
<li v-for="member in detail.members" :key="member.membershipId">
|
||||
@@ -716,6 +819,33 @@ label span {
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.chat-settings {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
padding: 0.85rem;
|
||||
border-radius: 12px;
|
||||
background: #f5f3ff;
|
||||
border: 1px solid #e9e5ff;
|
||||
}
|
||||
|
||||
.chat-hint {
|
||||
margin: 0;
|
||||
font-size: 0.82rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.chat-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.chat-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.modules-head,
|
||||
.mod-group-head {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user