@suflon/rnmd-reporting 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.tsx +69 -0
- package/README.md +97 -0
- package/app.json +4 -0
- package/babel.config.js +18 -0
- package/global.css +143 -0
- package/index.js +9 -0
- package/metro.config.js +209 -0
- package/nativewind-env.d.ts +1 -0
- package/package.json +106 -0
- package/patches/@react-navigation+stack+7.6.16.patch +11 -0
- package/patches/@suflon+native-ui+0.0.18.patch +26020 -0
- package/patches/react-native+0.83.1.patch +52 -0
- package/react-native.config.js +27 -0
- package/scripts/fix-suflon-native-ui.js +25 -0
- package/scripts/link-react-native-pnpm.js +42 -0
- package/src/config/index.ts +10 -0
- package/src/context/ConnectionI18nContext.tsx +61 -0
- package/src/modules/Reporting/component/README.md +3 -0
- package/src/modules/Reporting/component/ReportChart.tsx +882 -0
- package/src/modules/Reporting/component/ReportFilterModal.tsx +403 -0
- package/src/modules/Reporting/component/ReportingDetail.tsx +481 -0
- package/src/modules/Reporting/index.tsx +239 -0
- package/src/modules/Reporting/utils.tsx +14 -0
- package/src/navigation/index.tsx +31 -0
- package/src/screens/ConnectionListScreen.tsx +471 -0
- package/src/screens/DevToolsCorner.tsx +810 -0
- package/src/screens/NewConnectionModal.tsx +282 -0
- package/src/services/ApiService.ts +22 -0
- package/src/services/ConnectionService.ts +81 -0
- package/src/services/api.ts +83 -0
- package/src/stores/connection.store.ts +3 -0
- package/src/stores/language.store.ts +54 -0
- package/src/theme/colors.ts +56 -0
- package/src/types/connection.ts +69 -0
- package/src/utils/AsyncStorageUtils.ts +56 -0
- package/src/utils/connectionStrings.ts +158 -0
- package/src/utils/errorMessage.ts +11 -0
- package/tailwind.config.js +196 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Modal,
|
|
5
|
+
ScrollView,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
Text,
|
|
8
|
+
StyleSheet,
|
|
9
|
+
useWindowDimensions,
|
|
10
|
+
TextInput,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import { useColorScheme } from 'nativewind';
|
|
13
|
+
import { useNavigation } from '@react-navigation/native';
|
|
14
|
+
import { useAuthStore, getData, saveData, removeData } from '@suflon/native-ui';
|
|
15
|
+
import { useConnectionI18n } from '@/context/ConnectionI18nContext';
|
|
16
|
+
import { useLanguageStore } from '@/stores/language.store';
|
|
17
|
+
|
|
18
|
+
type LanguageCode = 'en' | 'hi' | 'ar';
|
|
19
|
+
|
|
20
|
+
const DEV_STRINGS: Record<LanguageCode, Record<string, string>> = {
|
|
21
|
+
en: {
|
|
22
|
+
fabLabel: 'DEV',
|
|
23
|
+
title: 'Dev Settings',
|
|
24
|
+
apiBaseUrl: 'API Base URL',
|
|
25
|
+
authToken: 'Auth Token',
|
|
26
|
+
companyId: 'Company ID',
|
|
27
|
+
staffId: 'Staff ID',
|
|
28
|
+
theme: 'Theme',
|
|
29
|
+
themeLight: 'Light',
|
|
30
|
+
themeDark: 'Dark',
|
|
31
|
+
apply: 'Apply',
|
|
32
|
+
clear: 'Clear',
|
|
33
|
+
useCodeDefaults: 'Use code defaults',
|
|
34
|
+
saved: 'Config saved. Restart app if needed.',
|
|
35
|
+
cleared: 'Cleared.',
|
|
36
|
+
defaultsLoaded: 'Loaded code defaults and saved.',
|
|
37
|
+
language: 'Language',
|
|
38
|
+
lang_en: 'English',
|
|
39
|
+
lang_hi: 'Hindi',
|
|
40
|
+
lang_ar: 'Arabic',
|
|
41
|
+
},
|
|
42
|
+
hi: {
|
|
43
|
+
fabLabel: 'DEV',
|
|
44
|
+
title: 'डेव सेटिंग्स',
|
|
45
|
+
apiBaseUrl: 'API बेस URL',
|
|
46
|
+
authToken: 'ऑथ टोकन',
|
|
47
|
+
companyId: 'कंपनी आईडी',
|
|
48
|
+
staffId: 'स्टाफ आईडी',
|
|
49
|
+
theme: 'थीम',
|
|
50
|
+
themeLight: 'लाइट',
|
|
51
|
+
themeDark: 'डार्क',
|
|
52
|
+
apply: 'अप्लाई',
|
|
53
|
+
clear: 'क्लियर',
|
|
54
|
+
useCodeDefaults: 'कोड डिफॉल्ट्स उपयोग करें',
|
|
55
|
+
saved: 'सेटिंग्स सेव हो गईं। जरूरत हो तो ऐप रीस्टार्ट करें।',
|
|
56
|
+
cleared: 'क्लीयर किया गया।',
|
|
57
|
+
defaultsLoaded: 'कोड डिफॉल्ट्स लोड और सेव हो गए हैं।',
|
|
58
|
+
language: 'भाषा',
|
|
59
|
+
lang_en: 'अंग्रेज़ी',
|
|
60
|
+
lang_hi: 'हिंदी',
|
|
61
|
+
lang_ar: 'अरबी',
|
|
62
|
+
},
|
|
63
|
+
ar: {
|
|
64
|
+
fabLabel: 'DEV',
|
|
65
|
+
title: 'إعدادات التطوير',
|
|
66
|
+
apiBaseUrl: 'رابط واجهة برمجة التطبيقات',
|
|
67
|
+
authToken: 'رمز المصادقة',
|
|
68
|
+
companyId: 'معرّف الشركة',
|
|
69
|
+
staffId: 'معرّف الموظف',
|
|
70
|
+
theme: 'الوضع',
|
|
71
|
+
themeLight: 'فاتح',
|
|
72
|
+
themeDark: 'داكن',
|
|
73
|
+
apply: 'تطبيق',
|
|
74
|
+
clear: 'مسح',
|
|
75
|
+
useCodeDefaults: 'استخدام القيم الافتراضية',
|
|
76
|
+
saved: 'تم حفظ الإعدادات. أعد تشغيل التطبيق إذا لزم الأمر.',
|
|
77
|
+
cleared: 'تم المسح.',
|
|
78
|
+
defaultsLoaded: 'تم تحميل القيم الافتراضية والحفظ.',
|
|
79
|
+
language: 'اللغة',
|
|
80
|
+
lang_en: 'الإنجليزية',
|
|
81
|
+
lang_hi: 'الهندية',
|
|
82
|
+
lang_ar: 'العربية',
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Default dev values
|
|
87
|
+
const DEFAULT_VALUES = {
|
|
88
|
+
authToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiZXhwIjoxOTQxNjg3Nzk1LCJ0aWQiOiJ5aDRsa2pkbiIsImNsdCI6IldFQiIsInNjb3BlIjoiQ09NUEFOWSIsImNvbXBhbnlfaWQiOjIsInJlZ2lvbl9pZCI6MSwic3RhZmZfaWQiOjF9.-Z6cH67dOnYJOoG1Gx49nAOeWrA1wKMO5jMFAbaBjeQ',
|
|
89
|
+
companyId: '2',
|
|
90
|
+
regionId: '1',
|
|
91
|
+
staffId: '1',
|
|
92
|
+
userId: '1',
|
|
93
|
+
apiBaseUrl: 'https://api-local.woctor.com',
|
|
94
|
+
permissionKey: 'clinic_owner'
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const DEV_KEYS = ['token', 'company_id', 'region_id', 'staff_id', 'user_id', 'api_base_url', 'permission_key'];
|
|
98
|
+
|
|
99
|
+
export const MOCK_ROLES: Record<string, any> = {
|
|
100
|
+
clinic_owner: {
|
|
101
|
+
core_dashboard: { app: "core", module: "dashboard", read: true },
|
|
102
|
+
patient_patient: { app: "patient", module: "patient", read: true, create: true, update: true, delete: true },
|
|
103
|
+
patient_patient_group: { app: "patient", module: "patient_group", read: true, create: true, update: true, delete: true },
|
|
104
|
+
opd_appointment: { app: "opd", module: "appointment", read: true, create: true, update: true, delete: true },
|
|
105
|
+
opd_prescription: { app: "opd", module: "prescription", read: true, create: true, update: true, delete: true },
|
|
106
|
+
opd_prescription_template: { app: "opd", module: "prescription_template", read: true, create: true, update: true, delete: true },
|
|
107
|
+
opd_treatment_plan: { app: "opd", module: "treatment_plan", read: true, create: true, update: true, delete: true },
|
|
108
|
+
opd_treatment_plan_template: { app: "opd", module: "treatment_plan_template", read: true, create: true, update: true, delete: true },
|
|
109
|
+
inventory_inventory: { app: "inventory", module: "inventory", read: true, create: true, update: true, delete: true },
|
|
110
|
+
inventory_pricing: { app: "inventory", module: "pricing", read: true, create: true, update: true, delete: true },
|
|
111
|
+
inventory_products: { app: "inventory", module: "products", read: true, create: true, update: true, delete: true },
|
|
112
|
+
inventory_ledgers: { app: "inventory", module: "ledgers", read: true, create: true, update: true, delete: true },
|
|
113
|
+
inventory_shortbook: { app: "inventory", module: "shortbook", read: true, create: true, update: true, delete: true },
|
|
114
|
+
billing_billing: { app: "billing", module: "billing", read: true, create: true, update: true, delete: true },
|
|
115
|
+
package_packages: { app: "package", module: "packages", read: true, create: true, update: true, delete: true },
|
|
116
|
+
reports_reports: { app: "reports", module: "reports", read: true },
|
|
117
|
+
account_account: { app: "account", module: "account", read: true, update: true },
|
|
118
|
+
account_account_license: { app: "account", module: "account_license", read: true, update: true },
|
|
119
|
+
account_account_subscription: { app: "account", module: "account_subscription", read: true, update: true },
|
|
120
|
+
account_platform_payment: { app: "account", module: "platform_payment", read: true, update: true, delete: true },
|
|
121
|
+
account_platform_bill: { app: "account", module: "platform_bill", read: true, update: true, delete: true },
|
|
122
|
+
connection_company_connection: { app: "connection", module: "company_connection", read: true, create: true, update: true, delete: true },
|
|
123
|
+
credit_coin_credit: { app: "credit", module: "coin_credit", read: true, create: true, update: true, delete: true },
|
|
124
|
+
account_bank: { app: "account", module: "bank", read: true, create: true, update: true, delete: true },
|
|
125
|
+
content_content: { app: "content", module: "content", read: true, create: true, update: true, delete: true },
|
|
126
|
+
promotion_promotion: { app: "promotion", module: "promotion", read: true, create: true, update: true, delete: true },
|
|
127
|
+
promotion_promotion_template: { app: "promotion", module: "promotion_template", read: true, create: true, update: true, delete: true },
|
|
128
|
+
promotion_contact: { app: "promotion", module: "contact", read: true, create: true, update: true, delete: true },
|
|
129
|
+
promotion_contact_group: { app: "promotion", module: "contact_group", read: true, create: true, update: true, delete: true },
|
|
130
|
+
settings_profile: { app: "settings", module: "profile", read: true, update: true },
|
|
131
|
+
settings_company: { app: "settings", module: "company", read: true, update: true },
|
|
132
|
+
settings_notification_setting: { app: "settings", module: "notification_setting", read: true, update: true },
|
|
133
|
+
settings_staff_setting: { app: "settings", module: "staff_setting", read: true, update: true },
|
|
134
|
+
settings_appearance: { app: "settings", module: "appearance", read: true, update: true },
|
|
135
|
+
settings_notification: { app: "settings", module: "notification", read: true, update: true },
|
|
136
|
+
staff_doctor_staff: { app: "staff", module: "doctor_staff", read: true, create: true, update: true, delete: true },
|
|
137
|
+
staff_general_staff: { app: "staff", module: "general_staff", read: true, create: true, update: true, delete: true },
|
|
138
|
+
staff_refer_doctor: { app: "staff", module: "refer_doctor", read: true, create: true, update: true, delete: true },
|
|
139
|
+
staff_department: { app: "staff", module: "department", read: true, create: true, update: true, delete: true },
|
|
140
|
+
crm_lead: { app: "crm", module: "lead", read: true, create: true, update: true, delete: true },
|
|
141
|
+
crm_lead_activity: { app: "crm", module: "lead_activity", read: true, create: true, update: true, delete: true },
|
|
142
|
+
crm_lead_task: { app: "crm", module: "lead_task", read: true, create: true, update: true, delete: true },
|
|
143
|
+
crm_lead_call_log: { app: "crm", module: "lead_call_log", read: true, create: true, update: true, delete: true },
|
|
144
|
+
crm_lead_note: { app: "crm", module: "lead_note", read: true, create: true, update: true, delete: true },
|
|
145
|
+
crm_lead_document: { app: "crm", module: "lead_document", read: true, create: true, update: true, delete: true },
|
|
146
|
+
crm_notes: { app: "notes", module: "notes", read: true, create: true, update: true, delete: true },
|
|
147
|
+
crm_task: { app: "task", module: "task", read: true, create: true, update: true, delete: true }
|
|
148
|
+
},
|
|
149
|
+
clinic_admin: {
|
|
150
|
+
core_dashboard: { app: "core", module: "dashboard", read: true },
|
|
151
|
+
patient_patient: { app: "patient", module: "patient", read: true, create: true, update: true, delete: true },
|
|
152
|
+
patient_patient_group: { app: "patient", module: "patient_group", read: true, create: true, update: true, delete: true },
|
|
153
|
+
opd_appointment: { app: "opd", module: "appointment", read: true, create: true, update: true, delete: true },
|
|
154
|
+
opd_prescription: { app: "opd", module: "prescription", read: true, create: true, update: true, delete: true },
|
|
155
|
+
opd_prescription_template: { app: "opd", module: "prescription_template", read: true, create: true, update: true, delete: true },
|
|
156
|
+
opd_treatment_plan: { app: "opd", module: "treatment_plan", read: true, create: true, update: true, delete: true },
|
|
157
|
+
opd_treatment_plan_template: { app: "opd", module: "treatment_plan_template", read: true, create: true, update: true, delete: true },
|
|
158
|
+
inventory_inventory: { app: "inventory", module: "inventory", read: true, create: true, update: true, delete: true },
|
|
159
|
+
inventory_pricing: { app: "inventory", module: "pricing", read: true, create: true, update: true, delete: true },
|
|
160
|
+
inventory_products: { app: "inventory", module: "products", read: true, create: true, update: true, delete: true },
|
|
161
|
+
inventory_ledgers: { app: "inventory", module: "ledgers", read: true, create: true, update: true, delete: true },
|
|
162
|
+
inventory_shortbook: { app: "inventory", module: "shortbook", read: true, create: true, update: true, delete: true },
|
|
163
|
+
billing_billing: { app: "billing", module: "billing", read: true, create: true, update: true, delete: true },
|
|
164
|
+
package_packages: { app: "package", module: "packages", read: true, create: true, update: true, delete: true },
|
|
165
|
+
reports_reports: { app: "reports", module: "reports", read: true },
|
|
166
|
+
account_account: { app: "account", module: "account", read: true, update: true },
|
|
167
|
+
account_account_license: { app: "account", module: "account_license", read: true, update: true },
|
|
168
|
+
account_account_subscription: { app: "account", module: "account_subscription", read: true, update: true },
|
|
169
|
+
account_platform_payment: { app: "account", module: "platform_payment", read: true, update: true, delete: true },
|
|
170
|
+
account_platform_bill: { app: "account", module: "platform_bill", read: true, update: true, delete: true },
|
|
171
|
+
connection_company_connection: { app: "connection", module: "company_connection", read: true, create: true, update: true, delete: true },
|
|
172
|
+
credit_coin_credit: { app: "credit", module: "coin_credit", read: true, create: true, update: true, delete: true },
|
|
173
|
+
account_bank: { app: "account", module: "bank", read: true, create: true, update: true, delete: true },
|
|
174
|
+
content_content: { app: "content", module: "content", read: true, create: true, update: true, delete: true },
|
|
175
|
+
promotion_promotion: { app: "promotion", module: "promotion", read: true, create: true, update: true, delete: true },
|
|
176
|
+
promotion_promotion_template: { app: "promotion", module: "promotion_template", read: true, create: true, update: true, delete: true },
|
|
177
|
+
promotion_contact: { app: "promotion", module: "contact", read: true, create: true, update: true, delete: true },
|
|
178
|
+
promotion_contact_group: { app: "promotion", module: "contact_group", read: true, create: true, update: true, delete: true },
|
|
179
|
+
settings_profile: { app: "settings", module: "profile", read: true, update: true },
|
|
180
|
+
settings_company: { app: "settings", module: "company", read: true, update: true },
|
|
181
|
+
settings_notification_setting: { app: "settings", module: "notification_setting", read: true, update: true },
|
|
182
|
+
settings_staff_setting: { app: "settings", module: "staff_setting", read: true, update: true },
|
|
183
|
+
settings_appearance: { app: "settings", module: "appearance", read: true, update: true },
|
|
184
|
+
settings_notification: { app: "settings", module: "notification", read: true, update: true },
|
|
185
|
+
staff_doctor_staff: { app: "staff", module: "doctor_staff", read: true, create: true, update: true, delete: true },
|
|
186
|
+
staff_general_staff: { app: "staff", module: "general_staff", read: true, create: true, update: true, delete: true },
|
|
187
|
+
staff_refer_doctor: { app: "staff", module: "refer_doctor", read: true, create: true, update: true, delete: true },
|
|
188
|
+
staff_department: { app: "staff", module: "department", read: true, create: true, update: true, delete: true },
|
|
189
|
+
crm_lead: { app: "crm", module: "lead", read: true, create: true, update: true, delete: true },
|
|
190
|
+
crm_lead_activity: { app: "crm", module: "lead_activity", read: true, create: true, update: true, delete: true },
|
|
191
|
+
crm_lead_task: { app: "crm", module: "lead_task", read: true, create: true, update: true, delete: true },
|
|
192
|
+
crm_lead_call_log: { app: "crm", module: "lead_call_log", read: true, create: true, update: true, delete: true },
|
|
193
|
+
crm_lead_note: { app: "crm", module: "lead_note", read: true, create: true, update: true, delete: true },
|
|
194
|
+
crm_lead_document: { app: "crm", module: "lead_document", read: true, create: true, update: true, delete: true },
|
|
195
|
+
crm_notes: { app: "notes", module: "notes", read: true, create: true, update: true, delete: true },
|
|
196
|
+
crm_task: { app: "task", module: "task", read: true, create: true, update: true, delete: true }
|
|
197
|
+
},
|
|
198
|
+
clinic_manager: {
|
|
199
|
+
core_dashboard: { app: "core", module: "dashboard", read: true },
|
|
200
|
+
patient_patient: { app: "patient", module: "patient", read: true, create: true, update: true, delete: true },
|
|
201
|
+
patient_patient_group: { app: "patient", module: "patient_group", read: true, create: true, update: true, delete: true },
|
|
202
|
+
opd_appointment: { app: "opd", module: "appointment", read: true, create: true, update: true, delete: true },
|
|
203
|
+
opd_prescription: { app: "opd", module: "prescription", read: true, create: true, update: true, delete: true },
|
|
204
|
+
opd_prescription_template: { app: "opd", module: "prescription_template", read: true, create: true, update: true, delete: true },
|
|
205
|
+
opd_treatment_plan: { app: "opd", module: "treatment_plan", read: true, create: true, update: true, delete: true },
|
|
206
|
+
opd_treatment_plan_template: { app: "opd", module: "treatment_plan_template", read: true, create: true, update: true, delete: true },
|
|
207
|
+
inventory_medicines: { app: "inventory", module: "medicines", read: true, create: true, update: true, delete: true },
|
|
208
|
+
inventory_vaccinations: { app: "inventory", module: "vaccinations", read: true, create: true, update: true, delete: true },
|
|
209
|
+
inventory_generals: { app: "inventory", module: "generals", read: true, create: true, update: true, delete: true },
|
|
210
|
+
pricing_medicines: { app: "pricing", module: "medicines", read: true, create: true, update: true, delete: true },
|
|
211
|
+
pricing_vaccinations: { app: "pricing", module: "vaccinations", read: true, create: true, update: true, delete: true },
|
|
212
|
+
pricing_generals: { app: "pricing", module: "generals", read: true, create: true, update: true, delete: true },
|
|
213
|
+
pricing_reports: { app: "pricing", module: "reports", read: true, create: true, update: true, delete: true },
|
|
214
|
+
pricing_treatments: { app: "pricing", module: "treatments", read: true, create: true, update: true, delete: true },
|
|
215
|
+
pricing_services: { app: "pricing", module: "services", read: true, create: true, update: true, delete: true },
|
|
216
|
+
billing_billing: { app: "billing", module: "billing", read: true, create: true, update: true, delete: true },
|
|
217
|
+
package_packages: { app: "package", module: "packages", read: true },
|
|
218
|
+
reports_reports: { app: "reports", module: "reports", read: true },
|
|
219
|
+
credit_coin_credit: { app: "credit", module: "coin_credit", read: true, create: true, update: true, delete: true },
|
|
220
|
+
account_bank: { app: "account", module: "bank", read: true, create: true, update: true, delete: true },
|
|
221
|
+
content_content: { app: "content", module: "content", read: true, create: true, update: true, delete: true },
|
|
222
|
+
settings_profile: { app: "settings", module: "profile", read: true, update: true },
|
|
223
|
+
settings_notification_setting: { app: "settings", module: "notification_setting", read: true, update: true },
|
|
224
|
+
settings_appearance: { app: "settings", module: "appearance", read: true, update: true },
|
|
225
|
+
settings_notification: { app: "settings", module: "notification", read: true, update: true },
|
|
226
|
+
staff_doctor_staff: { app: "staff", module: "doctor_staff", read: true, create: true },
|
|
227
|
+
staff_general_staff: { app: "staff", module: "general_staff", read: true, create: true },
|
|
228
|
+
crm_lead: { app: "crm", module: "lead", read: true, create: true, update: true, delete: true },
|
|
229
|
+
crm_lead_activity: { app: "crm", module: "lead_activity", read: true, create: true, update: true, delete: true },
|
|
230
|
+
crm_lead_task: { app: "crm", module: "lead_task", read: true, create: true, update: true, delete: true },
|
|
231
|
+
crm_lead_call_log: { app: "crm", module: "lead_call_log", read: true, create: true, update: true, delete: true },
|
|
232
|
+
crm_lead_note: { app: "crm", module: "lead_note", read: true, create: true, update: true, delete: true },
|
|
233
|
+
crm_lead_document: { app: "crm", module: "lead_document", read: true, create: true, update: true, delete: true },
|
|
234
|
+
crm_notes: { app: "notes", module: "notes", read: true, create: true, update: true, delete: true },
|
|
235
|
+
crm_task: { app: "task", module: "task", read: true, create: true, update: true, delete: true }
|
|
236
|
+
},
|
|
237
|
+
clinic_editor: {
|
|
238
|
+
core_dashboard: { app: "core", module: "dashboard", read: true },
|
|
239
|
+
patient_patient: { app: "patient", module: "patient", read: true, create: true, update: true, delete: true },
|
|
240
|
+
patient_patient_group: { app: "patient", module: "patient_group", read: true, create: true, update: true, delete: true },
|
|
241
|
+
opd_appointment: { app: "opd", module: "appointment", read: true, create: true, update: true, delete: true },
|
|
242
|
+
opd_prescription: { app: "opd", module: "prescription", read: true, create: true, update: true, delete: true },
|
|
243
|
+
opd_prescription_template: { app: "opd", module: "prescription_template", read: true, create: true, update: true, delete: true },
|
|
244
|
+
opd_treatment_plan: { app: "opd", module: "treatment_plan", read: true, create: true, update: true, delete: true },
|
|
245
|
+
opd_treatment_plan_template: { app: "opd", module: "treatment_plan_template", read: true, create: true, update: true, delete: true },
|
|
246
|
+
inventory_medicines: { app: "inventory", module: "medicines", read: true, create: true, update: true, delete: true },
|
|
247
|
+
inventory_vaccinations: { app: "inventory", module: "vaccinations", read: true, create: true, update: true, delete: true },
|
|
248
|
+
inventory_generals: { app: "inventory", module: "generals", read: true, create: true, update: true, delete: true },
|
|
249
|
+
pricing_medicines: { app: "pricing", module: "medicines", read: true, create: true, update: true, delete: true },
|
|
250
|
+
pricing_vaccinations: { app: "pricing", module: "vaccinations", read: true, create: true, update: true, delete: true },
|
|
251
|
+
pricing_generals: { app: "pricing", module: "generals", read: true, create: true, update: true, delete: true },
|
|
252
|
+
pricing_reports: { app: "pricing", module: "reports", read: true, create: true, update: true, delete: true },
|
|
253
|
+
pricing_treatments: { app: "pricing", module: "treatments", read: true, create: true, update: true, delete: true },
|
|
254
|
+
pricing_services: { app: "pricing", module: "services", read: true, create: true, update: true, delete: true },
|
|
255
|
+
billing_billing: { app: "billing", module: "billing", read: true },
|
|
256
|
+
reports_reports: { app: "reports", module: "reports", read: true },
|
|
257
|
+
package_packages: { app: "package", module: "packages", read: true },
|
|
258
|
+
content_content: { app: "content", module: "content", read: true, create: true, update: true, delete: true },
|
|
259
|
+
settings_profile: { app: "settings", module: "profile", read: true, update: true },
|
|
260
|
+
settings_appearance: { app: "settings", module: "appearance", read: true, update: true },
|
|
261
|
+
settings_notification: { app: "settings", module: "notification", read: true, update: true },
|
|
262
|
+
crm_lead: { app: "crm", module: "lead", read: true },
|
|
263
|
+
crm_lead_activity: { app: "crm", module: "lead_activity", read: true },
|
|
264
|
+
crm_lead_task: { app: "crm", module: "lead_task", read: true },
|
|
265
|
+
crm_lead_call_log: { app: "crm", module: "lead_call_log", read: true, create: true, update: true, delete: true },
|
|
266
|
+
crm_lead_note: { app: "crm", module: "lead_note", read: true },
|
|
267
|
+
crm_lead_document: { app: "crm", module: "lead_document", read: true },
|
|
268
|
+
crm_notes: { app: "notes", module: "notes", read: true },
|
|
269
|
+
crm_task: { app: "task", module: "task", read: true }
|
|
270
|
+
},
|
|
271
|
+
clinic_viewer: {
|
|
272
|
+
core_dashboard: { app: "core", module: "dashboard", read: true },
|
|
273
|
+
patient_patient: { app: "patient", module: "patient", read: true, create: false, update: false, delete: false },
|
|
274
|
+
patient_patient_group: { app: "patient", module: "patient_group", read: true, create: false, update: false, delete: false },
|
|
275
|
+
opd_appointment: { app: "opd", module: "appointment", read: true, create: false, update: false, delete: false },
|
|
276
|
+
opd_prescription: { app: "opd", module: "prescription", read: true, create: false, update: false, delete: false },
|
|
277
|
+
opd_prescription_template: { app: "opd", module: "prescription_template", read: true, create: false, update: false, delete: false },
|
|
278
|
+
opd_treatment_plan: { app: "opd", module: "treatment_plan", read: true, create: false, update: false, delete: false },
|
|
279
|
+
opd_treatment_plan_template: { app: "opd", module: "treatment_plan_template", read: true, create: false, update: false, delete: false },
|
|
280
|
+
inventory_medicines: { app: "inventory", module: "medicines", read: true, create: false, update: false, delete: false },
|
|
281
|
+
inventory_vaccination: { app: "inventory", module: "vaccination", read: true, create: false, update: false, delete: false },
|
|
282
|
+
inventory_general: { app: "inventory", module: "general", read: true, create: false, update: false, delete: false },
|
|
283
|
+
pricing_medicines: { app: "pricing", module: "medicines", read: true, create: false, update: false, delete: false },
|
|
284
|
+
pricing_vaccination: { app: "pricing", module: "vaccination", read: true, create: false, update: false, delete: false },
|
|
285
|
+
pricing_general: { app: "pricing", module: "general", read: true, create: false, update: false, delete: false },
|
|
286
|
+
pricing_services: { app: "pricing", module: "services", read: true, create: false, update: false, delete: false },
|
|
287
|
+
billing_billing: { app: "billing", module: "billing", read: true, create: false, update: false, delete: false },
|
|
288
|
+
package_packages: { app: "package", module: "packages", read: true, create: false, update: false, delete: false },
|
|
289
|
+
reports_reports: { app: "reports", module: "reports", read: true },
|
|
290
|
+
account_account: { app: "account", module: "account", read: true, update: false },
|
|
291
|
+
account_account_license: { app: "account", module: "account_license", read: true, update: false },
|
|
292
|
+
account_account_subscription: { app: "account", module: "account_subscription", read: true, update: false },
|
|
293
|
+
account_platform_payment: { app: "account", module: "platform_payment", read: true, update: false, delete: false },
|
|
294
|
+
account_platform_bill: { app: "account", module: "platform_bill", read: true, update: false, delete: false },
|
|
295
|
+
connection_company_connection: { app: "connection", module: "company_connection", read: true, create: false, update: false, delete: false },
|
|
296
|
+
credit_coin_credit: { app: "credit", module: "coin_credit", read: true, create: false, update: false, delete: false },
|
|
297
|
+
account_bank: { app: "account", module: "bank", read: true, create: false, update: false, delete: false },
|
|
298
|
+
content_content: { app: "content", module: "content", read: true, create: false, update: false, delete: false },
|
|
299
|
+
settings_profile: { app: "settings", module: "profile", read: true, update: false },
|
|
300
|
+
settings_company: { app: "settings", module: "company", read: true, update: false },
|
|
301
|
+
settings_notification_setting: { app: "settings", module: "notification_setting", read: true, update: false },
|
|
302
|
+
settings_appearance: { app: "settings", module: "appearance", read: true, update: false },
|
|
303
|
+
settings_notification: { app: "settings", module: "notification", read: true, update: false },
|
|
304
|
+
staff_doctor_staff: { app: "staff", module: "doctor_staff", read: true, create: false, update: false, delete: false },
|
|
305
|
+
staff_general_staff: { app: "staff", module: "general_staff", read: true, create: false, update: false, delete: false },
|
|
306
|
+
crm_lead: { app: "crm", module: "lead", read: true, create: false, update: false, delete: false },
|
|
307
|
+
crm_lead_activity: { app: "crm", module: "lead_activity", read: true, create: false, update: false, delete: false },
|
|
308
|
+
crm_lead_task: { app: "crm", module: "lead_task", read: true, create: false, update: false, delete: false },
|
|
309
|
+
crm_lead_call_log: { app: "crm", module: "lead_call_log", read: true, create: false, update: false, delete: false },
|
|
310
|
+
crm_lead_note: { app: "crm", module: "lead_note", read: true, create: false, update: false, delete: false },
|
|
311
|
+
crm_lead_document: { app: "crm", module: "lead_document", read: true, create: false, update: false, delete: false },
|
|
312
|
+
crm_notes: { app: "notes", module: "notes", read: true, create: false, update: false, delete: false },
|
|
313
|
+
crm_task: { app: "task", module: "task", read: true, create: false, update: false, delete: false }
|
|
314
|
+
},
|
|
315
|
+
no_access: {
|
|
316
|
+
settings_profile: { app: 'settings', module: 'profile', read: false, create: false, update: false, delete: false },
|
|
317
|
+
settings_company: { app: 'settings', module: 'company', read: false, create: false, update: false, delete: false },
|
|
318
|
+
settings_notification: { app: 'settings', module: 'notification', read: false, create: false, update: false, delete: false },
|
|
319
|
+
package_packages: { app: 'package', module: 'packages', read: false, create: false, update: false, delete: false },
|
|
320
|
+
appointment_opd: { app: 'appointment', module: 'opd', read: false, create: false, update: false, delete: false },
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export function DevToolsCorner() {
|
|
325
|
+
const { width, height } = useWindowDimensions();
|
|
326
|
+
const { colorScheme, setColorScheme } = useColorScheme();
|
|
327
|
+
const [visible, setVisible] = useState(false);
|
|
328
|
+
const [authToken, setAuthToken] = useState(DEFAULT_VALUES.authToken);
|
|
329
|
+
const [companyId, setCompanyId] = useState(DEFAULT_VALUES.companyId);
|
|
330
|
+
const [regionId, setRegionId] = useState(DEFAULT_VALUES.regionId);
|
|
331
|
+
const [staffId, setStaffId] = useState(DEFAULT_VALUES.staffId);
|
|
332
|
+
const [userId, setUserId] = useState(DEFAULT_VALUES.userId);
|
|
333
|
+
const [apiBaseUrl, setApiBaseUrl] = useState(DEFAULT_VALUES.apiBaseUrl);
|
|
334
|
+
const [permissionKey, setPermissionKey] = useState(DEFAULT_VALUES.permissionKey);
|
|
335
|
+
const [statusMessage, setStatusMessage] = useState('');
|
|
336
|
+
const setAuthData = useAuthStore((s) => s.setAuthData);
|
|
337
|
+
const isDark = colorScheme === 'dark';
|
|
338
|
+
|
|
339
|
+
const { language, controlledByHost } = useConnectionI18n();
|
|
340
|
+
const setLanguageFromStore = useLanguageStore((s) => s.setLanguage);
|
|
341
|
+
|
|
342
|
+
const navigation = useNavigation<any>();
|
|
343
|
+
|
|
344
|
+
const handleNavigateReporting = useCallback(() => {
|
|
345
|
+
setVisible(false);
|
|
346
|
+
try {
|
|
347
|
+
navigation.navigate('ReportingList');
|
|
348
|
+
} catch (e) {
|
|
349
|
+
console.error('Navigation error:', e);
|
|
350
|
+
}
|
|
351
|
+
}, [navigation]);
|
|
352
|
+
|
|
353
|
+
const tDev = useCallback(
|
|
354
|
+
(key: string): string => {
|
|
355
|
+
const dict = DEV_STRINGS[language] ?? DEV_STRINGS.en;
|
|
356
|
+
return dict[key] ?? DEV_STRINGS.en[key] ?? key;
|
|
357
|
+
},
|
|
358
|
+
[language],
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
// RBAC store hooks
|
|
362
|
+
const setPermissionScenario = useAuthStore((s) => s.setPermissionScenario);
|
|
363
|
+
const setPermissions = useAuthStore((s) => s.setPermissions);
|
|
364
|
+
const clearPermissions = useAuthStore((s) => s.clearPermissions);
|
|
365
|
+
const fetchPermissions = useAuthStore((s) => s.fetchPermissions);
|
|
366
|
+
|
|
367
|
+
const handleApplyMockRole = useCallback(async (roleKey: string) => {
|
|
368
|
+
const mockPerms = MOCK_ROLES[roleKey];
|
|
369
|
+
if (!mockPerms) return;
|
|
370
|
+
|
|
371
|
+
let newStaffId = '1';
|
|
372
|
+
let newCompanyId = '2';
|
|
373
|
+
let newUserId = '1';
|
|
374
|
+
|
|
375
|
+
if (roleKey === 'clinic_editor') {
|
|
376
|
+
newStaffId = '27';
|
|
377
|
+
newCompanyId = '15';
|
|
378
|
+
newUserId = '67';
|
|
379
|
+
} else if (roleKey === 'clinic_viewer') {
|
|
380
|
+
newStaffId = '26';
|
|
381
|
+
newCompanyId = '21';
|
|
382
|
+
newUserId = '61';
|
|
383
|
+
} else if (roleKey === 'clinic_owner') {
|
|
384
|
+
newStaffId = '1';
|
|
385
|
+
newCompanyId = '2';
|
|
386
|
+
newUserId = '1';
|
|
387
|
+
} else if (roleKey === 'clinic_admin') {
|
|
388
|
+
newStaffId = '14';
|
|
389
|
+
newCompanyId = '2';
|
|
390
|
+
newUserId = '49';
|
|
391
|
+
} else if (roleKey === 'clinic_manager') {
|
|
392
|
+
newStaffId = '13';
|
|
393
|
+
newCompanyId = '2';
|
|
394
|
+
newUserId = '48';
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
setStaffId(newStaffId);
|
|
398
|
+
setCompanyId(newCompanyId);
|
|
399
|
+
setUserId(newUserId);
|
|
400
|
+
|
|
401
|
+
setPermissionKey(roleKey);
|
|
402
|
+
await saveData('permission_key', roleKey);
|
|
403
|
+
await saveData('rbac_permission_scenario', roleKey);
|
|
404
|
+
await saveData('rbac_permissions', mockPerms);
|
|
405
|
+
|
|
406
|
+
await saveData('staff_id', newStaffId);
|
|
407
|
+
await saveData('company_id', newCompanyId);
|
|
408
|
+
await saveData('user_id', newUserId);
|
|
409
|
+
|
|
410
|
+
setPermissionScenario(roleKey);
|
|
411
|
+
|
|
412
|
+
await setAuthData({
|
|
413
|
+
company_id: Number(newCompanyId) || 0,
|
|
414
|
+
region_id: Number(regionId) || 0,
|
|
415
|
+
staff_id: Number(newStaffId) || 0,
|
|
416
|
+
user_id: Number(newUserId) || 0,
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
await setPermissions(mockPerms, Number(newStaffId));
|
|
420
|
+
|
|
421
|
+
setStatusMessage(`Mock role '${roleKey}' applied (Staff: ${newStaffId}, Co: ${newCompanyId}, User: ${newUserId}).`);
|
|
422
|
+
setTimeout(() => setStatusMessage(''), 2000);
|
|
423
|
+
}, [regionId, setPermissionScenario, setPermissions, setAuthData]);
|
|
424
|
+
|
|
425
|
+
const loadStored = useCallback(async () => {
|
|
426
|
+
const [token, company, region, staff, user, base, perm, storedScenario] = await Promise.all([
|
|
427
|
+
getData('token'),
|
|
428
|
+
getData('company_id'),
|
|
429
|
+
getData('region_id'),
|
|
430
|
+
getData('staff_id'),
|
|
431
|
+
getData('user_id'),
|
|
432
|
+
getData('api_base_url'),
|
|
433
|
+
getData('permission_key'),
|
|
434
|
+
getData('rbac_permission_scenario'),
|
|
435
|
+
]);
|
|
436
|
+
if (token) setAuthToken(String(token));
|
|
437
|
+
if (company && company !== 'NaN' && company !== '"NaN"') setCompanyId(String(company));
|
|
438
|
+
if (region && region !== 'NaN' && region !== '"NaN"') setRegionId(String(region));
|
|
439
|
+
if (staff && staff !== 'NaN' && staff !== '"NaN"') setStaffId(String(staff));
|
|
440
|
+
if (user && user !== 'NaN' && user !== '"NaN"') setUserId(String(user));
|
|
441
|
+
|
|
442
|
+
if (base && String(base).includes('ngrok-free.dev')) {
|
|
443
|
+
setApiBaseUrl(DEFAULT_VALUES.apiBaseUrl);
|
|
444
|
+
saveData('api_base_url', DEFAULT_VALUES.apiBaseUrl);
|
|
445
|
+
} else if (base) {
|
|
446
|
+
setApiBaseUrl(String(base));
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const activeScenario = storedScenario || perm || '';
|
|
450
|
+
if (activeScenario) {
|
|
451
|
+
setPermissionKey(String(activeScenario));
|
|
452
|
+
}
|
|
453
|
+
}, []);
|
|
454
|
+
|
|
455
|
+
useEffect(() => {
|
|
456
|
+
if (visible) loadStored();
|
|
457
|
+
}, [visible, loadStored]);
|
|
458
|
+
|
|
459
|
+
const handleApply = useCallback(async () => {
|
|
460
|
+
const token = authToken.trim();
|
|
461
|
+
const company = companyId.trim();
|
|
462
|
+
const region = regionId.trim();
|
|
463
|
+
const staff = staffId.trim();
|
|
464
|
+
const user = userId.trim();
|
|
465
|
+
const baseUrl = apiBaseUrl.trim();
|
|
466
|
+
const perm = permissionKey.trim();
|
|
467
|
+
|
|
468
|
+
await saveData('token', token);
|
|
469
|
+
await saveData('company_id', company);
|
|
470
|
+
await saveData('region_id', region);
|
|
471
|
+
await saveData('staff_id', staff);
|
|
472
|
+
await saveData('user_id', user);
|
|
473
|
+
await saveData('api_base_url', baseUrl);
|
|
474
|
+
await saveData('permission_key', perm);
|
|
475
|
+
await saveData('rbac_permission_scenario', perm);
|
|
476
|
+
|
|
477
|
+
setPermissionScenario(perm);
|
|
478
|
+
|
|
479
|
+
await setAuthData({
|
|
480
|
+
token,
|
|
481
|
+
company_id: Number(company) || 0,
|
|
482
|
+
region_id: Number(region) || 0,
|
|
483
|
+
staff_id: Number(staff) || 0,
|
|
484
|
+
user_id: Number(user) || 0,
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
if (staff) {
|
|
488
|
+
if (MOCK_ROLES[perm]) {
|
|
489
|
+
const mockPerms = MOCK_ROLES[perm];
|
|
490
|
+
await saveData('rbac_permissions', mockPerms);
|
|
491
|
+
await setPermissions(mockPerms, Number(staff));
|
|
492
|
+
} else {
|
|
493
|
+
await fetchPermissions(Number(staff));
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
setStatusMessage(tDev('saved'));
|
|
498
|
+
setTimeout(() => setVisible(false), 1500);
|
|
499
|
+
}, [authToken, companyId, regionId, staffId, userId, apiBaseUrl, permissionKey, setAuthData, setPermissionScenario, fetchPermissions, setPermissions, tDev]);
|
|
500
|
+
|
|
501
|
+
const handleClear = useCallback(async () => {
|
|
502
|
+
for (const key of DEV_KEYS) {
|
|
503
|
+
await removeData(key).catch(() => { });
|
|
504
|
+
}
|
|
505
|
+
await clearPermissions();
|
|
506
|
+
setLanguageFromStore('en');
|
|
507
|
+
setAuthToken(DEFAULT_VALUES.authToken);
|
|
508
|
+
setCompanyId(DEFAULT_VALUES.companyId);
|
|
509
|
+
setRegionId(DEFAULT_VALUES.regionId);
|
|
510
|
+
setStaffId(DEFAULT_VALUES.staffId);
|
|
511
|
+
setUserId(DEFAULT_VALUES.userId);
|
|
512
|
+
setApiBaseUrl(DEFAULT_VALUES.apiBaseUrl);
|
|
513
|
+
setPermissionKey(DEFAULT_VALUES.permissionKey);
|
|
514
|
+
setAuthData({
|
|
515
|
+
token: DEFAULT_VALUES.authToken,
|
|
516
|
+
company_id: Number(DEFAULT_VALUES.companyId) || 0,
|
|
517
|
+
region_id: Number(DEFAULT_VALUES.regionId) || 0,
|
|
518
|
+
staff_id: Number(DEFAULT_VALUES.staffId) || 0,
|
|
519
|
+
user_id: Number(DEFAULT_VALUES.userId) || 0,
|
|
520
|
+
});
|
|
521
|
+
setStatusMessage(tDev('cleared'));
|
|
522
|
+
}, [setAuthData, clearPermissions, setLanguageFromStore, tDev]);
|
|
523
|
+
|
|
524
|
+
const handleLanguageChange = useCallback(
|
|
525
|
+
(lang: LanguageCode) => {
|
|
526
|
+
setLanguageFromStore(lang);
|
|
527
|
+
},
|
|
528
|
+
[setLanguageFromStore],
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
if (!__DEV__) return null;
|
|
532
|
+
|
|
533
|
+
return (
|
|
534
|
+
<>
|
|
535
|
+
<View style={styles.fabContainer} pointerEvents="box-none">
|
|
536
|
+
<TouchableOpacity
|
|
537
|
+
onPress={() => setVisible(true)}
|
|
538
|
+
activeOpacity={0.8}
|
|
539
|
+
className="w-[50px] h-[50px] rounded-full bg-red-500 items-center justify-center shadow-lg"
|
|
540
|
+
style={styles.fabShadow}
|
|
541
|
+
>
|
|
542
|
+
<Text className="text-white font-bold text-xs">{tDev('fabLabel')}</Text>
|
|
543
|
+
</TouchableOpacity>
|
|
544
|
+
</View>
|
|
545
|
+
|
|
546
|
+
<Modal visible={visible} transparent animationType="fade">
|
|
547
|
+
<View className="flex-1 bg-background-lightGray items-center justify-center">
|
|
548
|
+
<View
|
|
549
|
+
className="bg-white dark:bg-zinc-900 rounded-2xl overflow-hidden"
|
|
550
|
+
style={{ width: width - 32, maxHeight: height * 0.9 }}
|
|
551
|
+
>
|
|
552
|
+
<View className="flex-row items-center justify-between bg-red-600 p-4">
|
|
553
|
+
<Text className="text-lg font-bold text-white">{tDev('title')}</Text>
|
|
554
|
+
<TouchableOpacity onPress={() => setVisible(false)}>
|
|
555
|
+
<Text className="text-white text-2xl">✕</Text>
|
|
556
|
+
</TouchableOpacity>
|
|
557
|
+
</View>
|
|
558
|
+
|
|
559
|
+
<ScrollView contentContainerStyle={styles.modalBodyContent}>
|
|
560
|
+
|
|
561
|
+
{/* UI Configuration Section */}
|
|
562
|
+
<View style={styles.section}>
|
|
563
|
+
<Text style={[styles.sectionTitle, { color: isDark ? '#F3F4F6' : '#333' }]}>Navigation & Configuration</Text>
|
|
564
|
+
|
|
565
|
+
<TouchableOpacity
|
|
566
|
+
onPress={handleNavigateReporting}
|
|
567
|
+
style={{
|
|
568
|
+
backgroundColor: '#7c3aed',
|
|
569
|
+
paddingVertical: 12,
|
|
570
|
+
paddingHorizontal: 16,
|
|
571
|
+
borderRadius: 10,
|
|
572
|
+
alignItems: 'center',
|
|
573
|
+
marginBottom: 12,
|
|
574
|
+
}}
|
|
575
|
+
>
|
|
576
|
+
<Text style={{ color: '#ffffff', fontWeight: 'bold', fontSize: 14 }}>
|
|
577
|
+
📊 Open Reporting Screen
|
|
578
|
+
</Text>
|
|
579
|
+
</TouchableOpacity>
|
|
580
|
+
|
|
581
|
+
<View style={styles.row}>
|
|
582
|
+
<Text style={{ color: isDark ? '#FFFFFF' : '#111827', fontWeight: '700' }}>Theme ({colorScheme})</Text>
|
|
583
|
+
<View className="flex-row gap-2">
|
|
584
|
+
<TouchableOpacity
|
|
585
|
+
onPress={() => setColorScheme('light')}
|
|
586
|
+
style={[
|
|
587
|
+
styles.toggleBtn,
|
|
588
|
+
colorScheme === 'light'
|
|
589
|
+
? styles.toggleBtnActive
|
|
590
|
+
: { backgroundColor: isDark ? '#374151' : '#E5E7EB' },
|
|
591
|
+
]}
|
|
592
|
+
>
|
|
593
|
+
<Text style={colorScheme === 'light' ? styles.toggleTextActive : styles.toggleTextInactive}>Light</Text>
|
|
594
|
+
</TouchableOpacity>
|
|
595
|
+
<TouchableOpacity
|
|
596
|
+
onPress={() => setColorScheme('dark')}
|
|
597
|
+
style={[
|
|
598
|
+
styles.toggleBtn,
|
|
599
|
+
colorScheme === 'dark'
|
|
600
|
+
? styles.toggleBtnActive
|
|
601
|
+
: { backgroundColor: isDark ? '#374151' : '#E5E7EB' },
|
|
602
|
+
]}
|
|
603
|
+
>
|
|
604
|
+
<Text style={colorScheme === 'dark' ? styles.toggleTextActive : styles.toggleTextInactive}>Dark</Text>
|
|
605
|
+
</TouchableOpacity>
|
|
606
|
+
</View>
|
|
607
|
+
</View>
|
|
608
|
+
|
|
609
|
+
{/* Language toggle: only when host app does not control language (standalone mode) */}
|
|
610
|
+
{!controlledByHost && (
|
|
611
|
+
<View style={[styles.row, { marginTop: 10 }]}>
|
|
612
|
+
<Text style={{ color: isDark ? '#FFFFFF' : '#111827', fontWeight: '700' }}>Language ({language})</Text>
|
|
613
|
+
<View className="flex-row gap-2">
|
|
614
|
+
{(['en', 'hi', 'ar'] as LanguageCode[]).map(lang => (
|
|
615
|
+
<TouchableOpacity
|
|
616
|
+
key={lang}
|
|
617
|
+
onPress={() => handleLanguageChange(lang)}
|
|
618
|
+
style={[
|
|
619
|
+
styles.toggleBtnSmall,
|
|
620
|
+
language === lang
|
|
621
|
+
? styles.toggleBtnActive
|
|
622
|
+
: { backgroundColor: isDark ? '#374151' : '#E5E7EB' },
|
|
623
|
+
]}
|
|
624
|
+
>
|
|
625
|
+
<Text style={language === lang ? styles.toggleTextActive : styles.toggleTextInactive}>
|
|
626
|
+
{lang === 'en' ? 'EN' : lang === 'hi' ? 'HI' : 'AR'}
|
|
627
|
+
</Text>
|
|
628
|
+
</TouchableOpacity>
|
|
629
|
+
))}
|
|
630
|
+
</View>
|
|
631
|
+
</View>
|
|
632
|
+
)}
|
|
633
|
+
</View>
|
|
634
|
+
|
|
635
|
+
<View style={styles.divider} />
|
|
636
|
+
|
|
637
|
+
<View style={styles.inputGroup}>
|
|
638
|
+
<Text className="text-xs font-bold text-gray-500 mb-1">{tDev('apiBaseUrl')}</Text>
|
|
639
|
+
<TextInput
|
|
640
|
+
className="border border-gray-300 rounded-lg px-3 py-2 text-sm text-black dark:text-white"
|
|
641
|
+
value={apiBaseUrl}
|
|
642
|
+
onChangeText={setApiBaseUrl}
|
|
643
|
+
placeholder="https://..."
|
|
644
|
+
placeholderTextColor="#999"
|
|
645
|
+
/>
|
|
646
|
+
</View>
|
|
647
|
+
|
|
648
|
+
<View style={styles.inputGroup}>
|
|
649
|
+
<Text className="text-xs font-bold text-gray-500 mb-1">{tDev('authToken')}</Text>
|
|
650
|
+
<TextInput
|
|
651
|
+
className="border border-gray-300 rounded-lg px-3 py-2 text-sm text-black dark:text-white"
|
|
652
|
+
value={authToken}
|
|
653
|
+
onChangeText={setAuthToken}
|
|
654
|
+
multiline
|
|
655
|
+
style={{ height: 80, textAlignVertical: 'top' }}
|
|
656
|
+
placeholder="Paste token here"
|
|
657
|
+
placeholderTextColor="#999"
|
|
658
|
+
/>
|
|
659
|
+
</View>
|
|
660
|
+
|
|
661
|
+
<View style={styles.inputGroup}>
|
|
662
|
+
<Text className="text-xs font-bold text-gray-500 mb-1">Permission Key</Text>
|
|
663
|
+
<TextInput
|
|
664
|
+
className="border border-gray-300 rounded-lg px-3 py-2 text-sm text-black dark:text-white"
|
|
665
|
+
value={permissionKey}
|
|
666
|
+
onChangeText={setPermissionKey}
|
|
667
|
+
placeholder="e.g. clinic_owner"
|
|
668
|
+
placeholderTextColor="#999"
|
|
669
|
+
/>
|
|
670
|
+
<View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 6, marginTop: 6 }}>
|
|
671
|
+
{Object.keys(MOCK_ROLES).map((role) => (
|
|
672
|
+
<TouchableOpacity
|
|
673
|
+
key={role}
|
|
674
|
+
onPress={() => handleApplyMockRole(role)}
|
|
675
|
+
style={[
|
|
676
|
+
styles.rolePresetBtn,
|
|
677
|
+
permissionKey === role
|
|
678
|
+
? styles.rolePresetBtnActive
|
|
679
|
+
: { backgroundColor: isDark ? '#374151' : '#E5E7EB' }
|
|
680
|
+
]}
|
|
681
|
+
>
|
|
682
|
+
<Text
|
|
683
|
+
style={{
|
|
684
|
+
fontSize: 10,
|
|
685
|
+
fontWeight: '700',
|
|
686
|
+
color: permissionKey === role ? '#FFFFFF' : (isDark ? '#E5E7EB' : '#4B5563')
|
|
687
|
+
}}
|
|
688
|
+
>
|
|
689
|
+
{role === 'clinic_owner' ? 'Owner' :
|
|
690
|
+
role === 'clinic_editor' ? 'Editor' :
|
|
691
|
+
role === 'clinic_viewer' ? 'Viewer' :
|
|
692
|
+
role === 'clinic_admin' ? 'Admin' :
|
|
693
|
+
role === 'clinic_manager' ? 'Manager' : 'No Access'}
|
|
694
|
+
</Text>
|
|
695
|
+
</TouchableOpacity>
|
|
696
|
+
))}
|
|
697
|
+
</View>
|
|
698
|
+
</View>
|
|
699
|
+
|
|
700
|
+
<View className="flex-row gap-2">
|
|
701
|
+
<View style={[styles.inputGroup, { flex: 1 }]}>
|
|
702
|
+
<Text className="text-xs font-bold text-gray-500 mb-1">{tDev('companyId')}</Text>
|
|
703
|
+
<TextInput
|
|
704
|
+
className="border border-gray-300 rounded-lg px-3 py-2 text-sm text-black dark:text-white"
|
|
705
|
+
value={companyId}
|
|
706
|
+
onChangeText={setCompanyId}
|
|
707
|
+
keyboardType="numeric"
|
|
708
|
+
placeholderTextColor="#999"
|
|
709
|
+
/>
|
|
710
|
+
</View>
|
|
711
|
+
<View style={[styles.inputGroup, { flex: 1 }]}>
|
|
712
|
+
<Text className="text-xs font-bold text-gray-500 mb-1">Region ID</Text>
|
|
713
|
+
<TextInput
|
|
714
|
+
className="border border-gray-300 rounded-lg px-3 py-2 text-sm text-black dark:text-white"
|
|
715
|
+
value={regionId}
|
|
716
|
+
onChangeText={setRegionId}
|
|
717
|
+
keyboardType="numeric"
|
|
718
|
+
placeholderTextColor="#999"
|
|
719
|
+
/>
|
|
720
|
+
</View>
|
|
721
|
+
</View>
|
|
722
|
+
|
|
723
|
+
<View className="flex-row gap-2">
|
|
724
|
+
<View style={[styles.inputGroup, { flex: 1 }]}>
|
|
725
|
+
<Text className="text-xs font-bold text-gray-500 mb-1">{tDev('staffId')}</Text>
|
|
726
|
+
<TextInput
|
|
727
|
+
className="border border-gray-300 rounded-lg px-3 py-2 text-sm text-black dark:text-white"
|
|
728
|
+
value={staffId}
|
|
729
|
+
onChangeText={setStaffId}
|
|
730
|
+
keyboardType="numeric"
|
|
731
|
+
placeholderTextColor="#999"
|
|
732
|
+
/>
|
|
733
|
+
</View>
|
|
734
|
+
<View style={[styles.inputGroup, { flex: 1 }]}>
|
|
735
|
+
<Text className="text-xs font-bold text-gray-500 mb-1">User ID</Text>
|
|
736
|
+
<TextInput
|
|
737
|
+
className="border border-gray-300 rounded-lg px-3 py-2 text-sm text-black dark:text-white"
|
|
738
|
+
value={userId}
|
|
739
|
+
onChangeText={setUserId}
|
|
740
|
+
keyboardType="numeric"
|
|
741
|
+
placeholderTextColor="#999"
|
|
742
|
+
/>
|
|
743
|
+
</View>
|
|
744
|
+
</View>
|
|
745
|
+
|
|
746
|
+
<View style={styles.buttonRow}>
|
|
747
|
+
<TouchableOpacity onPress={handleApply} style={styles.primaryBtn}>
|
|
748
|
+
<Text className="text-white font-bold">{tDev('apply')}</Text>
|
|
749
|
+
</TouchableOpacity>
|
|
750
|
+
<View style={{ width: 12 }} />
|
|
751
|
+
<TouchableOpacity
|
|
752
|
+
onPress={handleClear}
|
|
753
|
+
style={[
|
|
754
|
+
styles.secondaryBtn,
|
|
755
|
+
{ borderColor: isDark ? '#4B5563' : '#D1D5DB', backgroundColor: isDark ? '#1F2937' : '#FFFFFF' },
|
|
756
|
+
]}
|
|
757
|
+
>
|
|
758
|
+
<Text style={{ color: isDark ? '#E5E7EB' : '#4B5563', fontWeight: '700' }}>{tDev('clear')}</Text>
|
|
759
|
+
</TouchableOpacity>
|
|
760
|
+
</View>
|
|
761
|
+
|
|
762
|
+
{statusMessage ? (
|
|
763
|
+
<Text className="mt-3 text-center text-red-500 font-semibold">{statusMessage}</Text>
|
|
764
|
+
) : null}
|
|
765
|
+
</ScrollView>
|
|
766
|
+
</View>
|
|
767
|
+
</View>
|
|
768
|
+
</Modal>
|
|
769
|
+
</>
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
const styles = StyleSheet.create({
|
|
774
|
+
fabContainer: { position: 'absolute', right: 16, bottom: 100, zIndex: 9999 },
|
|
775
|
+
modalBodyContent: { padding: 16 },
|
|
776
|
+
inputGroup: { marginBottom: 12 },
|
|
777
|
+
fabShadow: { elevation: 5 },
|
|
778
|
+
buttonRow: { flexDirection: 'row', alignItems: 'center', marginTop: 16 },
|
|
779
|
+
section: { marginBottom: 16 },
|
|
780
|
+
sectionTitle: { fontSize: 16, fontStyle: 'normal', fontWeight: 'bold', marginBottom: 8, color: '#333' },
|
|
781
|
+
divider: { height: 1, backgroundColor: '#eee', marginVertical: 12 },
|
|
782
|
+
row: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
|
|
783
|
+
toggleBtn: { paddingHorizontal: 12, paddingVertical: 6, borderRadius: 8 },
|
|
784
|
+
toggleBtnSmall: { paddingHorizontal: 10, paddingVertical: 6, borderRadius: 8 },
|
|
785
|
+
toggleBtnActive: { backgroundColor: '#3B82F6' },
|
|
786
|
+
toggleTextActive: { color: '#FFFFFF', fontWeight: '700' },
|
|
787
|
+
toggleTextInactive: { color: '#111827', fontWeight: '600' },
|
|
788
|
+
primaryBtn: {
|
|
789
|
+
flex: 1,
|
|
790
|
+
backgroundColor: '#DC2626',
|
|
791
|
+
borderRadius: 10,
|
|
792
|
+
paddingVertical: 12,
|
|
793
|
+
alignItems: 'center',
|
|
794
|
+
},
|
|
795
|
+
secondaryBtn: {
|
|
796
|
+
flex: 1,
|
|
797
|
+
borderWidth: 1,
|
|
798
|
+
borderRadius: 10,
|
|
799
|
+
paddingVertical: 12,
|
|
800
|
+
alignItems: 'center',
|
|
801
|
+
},
|
|
802
|
+
rolePresetBtn: {
|
|
803
|
+
paddingHorizontal: 8,
|
|
804
|
+
paddingVertical: 4,
|
|
805
|
+
borderRadius: 6,
|
|
806
|
+
},
|
|
807
|
+
rolePresetBtnActive: {
|
|
808
|
+
backgroundColor: '#3B82F6',
|
|
809
|
+
},
|
|
810
|
+
});
|