feat: complete settings sync, standard UI inputs, prescriptions flow, pet profile and checkout enhancements
Deploy Canina / deploy (push) Failing after 51s
Deploy Canina / deploy (push) Failing after 51s
This commit is contained in:
1 parent
b3c60a1a7d
commit
6df92f03d7
32 files changed
+61750
-59151
No files matched your search
@@ -300,6 +300,24 @@ export class SettingsService implements OnModuleInit {
|
||||
}
|
||||
|
||||
async getCategorySetting(category: string) {
|
||||
if (category === 'system') {
|
||||
const texts = await this.getUiTexts();
|
||||
const map = new Map<string, string>();
|
||||
texts.forEach((t) => map.set(t.key, t.value));
|
||||
|
||||
const isMaintenance = map.get('MAINTENANCE_MODE') === 'true' || map.get('maintenance_mode') === 'true' || map.get('maintenanceMode') === 'true';
|
||||
const allowGuestCheckout = map.get('allowGuestCheckout') !== 'false';
|
||||
const b2bRegistrationOpen = map.get('b2bRegistrationOpen') !== 'false' && map.get('b2b_enabled') !== 'false';
|
||||
const supportPhone = map.get('CONTACT_PHONE') || map.get('contact_phone') || map.get('supportPhone') || '۰۲۱-۸۸۸۸۴۴۴۴';
|
||||
|
||||
return {
|
||||
maintenanceMode: isMaintenance,
|
||||
allowGuestCheckout,
|
||||
b2bRegistrationOpen,
|
||||
supportPhone,
|
||||
};
|
||||
}
|
||||
|
||||
const setting = await this.prisma.setting.findFirst({
|
||||
where: { category },
|
||||
});
|
||||
@@ -317,23 +335,29 @@ export class SettingsService implements OnModuleInit {
|
||||
// If system config is updated, also sync individual keys into uiText for fast & reliable lookup
|
||||
if (category === 'system' && typeof value === 'object' && value !== null) {
|
||||
const obj = value as Record<string, any>;
|
||||
const promises: Promise<any>[] = [];
|
||||
if ('b2bRegistrationOpen' in obj) {
|
||||
const valStr = String(obj.b2bRegistrationOpen);
|
||||
promises.push(
|
||||
this.prisma.uiText.upsert({
|
||||
where: { key: 'b2bRegistrationOpen' },
|
||||
update: { value: valStr },
|
||||
create: { key: 'b2bRegistrationOpen', value: valStr },
|
||||
}),
|
||||
this.prisma.uiText.upsert({
|
||||
where: { key: 'b2b_enabled' },
|
||||
update: { value: valStr },
|
||||
create: { key: 'b2b_enabled', value: valStr },
|
||||
}),
|
||||
);
|
||||
const updates: Record<string, string> = {};
|
||||
|
||||
if ('maintenanceMode' in obj) {
|
||||
const valStr = String(Boolean(obj.maintenanceMode));
|
||||
updates['MAINTENANCE_MODE'] = valStr;
|
||||
updates['maintenance_mode'] = valStr;
|
||||
updates['maintenanceMode'] = valStr;
|
||||
}
|
||||
await Promise.all(promises);
|
||||
if ('supportPhone' in obj) {
|
||||
updates['CONTACT_PHONE'] = String(obj.supportPhone);
|
||||
updates['contact_phone'] = String(obj.supportPhone);
|
||||
updates['supportPhone'] = String(obj.supportPhone);
|
||||
}
|
||||
if ('b2bRegistrationOpen' in obj) {
|
||||
const valStr = String(Boolean(obj.b2bRegistrationOpen));
|
||||
updates['b2bRegistrationOpen'] = valStr;
|
||||
updates['b2b_enabled'] = valStr;
|
||||
}
|
||||
if ('allowGuestCheckout' in obj) {
|
||||
updates['allowGuestCheckout'] = String(Boolean(obj.allowGuestCheckout));
|
||||
}
|
||||
|
||||
await this.updateBulkUiTexts(updates);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
Reference in new issue
Block a user