@7365admin1/layer-common 1.8.0
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/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.editorconfig +12 -0
- package/.github/workflows/main.yml +17 -0
- package/.github/workflows/publish.yml +39 -0
- package/.nuxtrc +1 -0
- package/.playground/app.vue +41 -0
- package/.playground/eslint.config.mjs +6 -0
- package/.playground/nuxt.config.ts +22 -0
- package/.playground/pages/feedback.vue +30 -0
- package/CHANGELOG.md +263 -0
- package/README.md +73 -0
- package/app.vue +3 -0
- package/components/AccessCardAddForm.vue +363 -0
- package/components/AccessManagement.vue +420 -0
- package/components/Avatar/Main.vue +68 -0
- package/components/BillingMain.vue +66 -0
- package/components/BtnUploadFile.vue +139 -0
- package/components/BuildingForm.vue +303 -0
- package/components/BuildingManagement/buildings.vue +335 -0
- package/components/BuildingManagement/units.vue +350 -0
- package/components/BuildingUnitFormAdd.vue +441 -0
- package/components/BuildingUnitFormEdit.vue +429 -0
- package/components/CameraForm.vue +264 -0
- package/components/CameraMain.vue +352 -0
- package/components/Card/DeleteConfirmation.vue +51 -0
- package/components/Card/MemberInfoSummary.vue +44 -0
- package/components/Card/Toggle.vue +25 -0
- package/components/Chat/Bubbles.vue +53 -0
- package/components/Chat/Information.vue +416 -0
- package/components/Chat/ListCard.vue +62 -0
- package/components/Chat/Message.vue +158 -0
- package/components/Chat/Navigation.vue +150 -0
- package/components/ConfirmDialog.vue +66 -0
- package/components/Container/Standard.vue +33 -0
- package/components/DashboardPlaceholder.vue +1524 -0
- package/components/Dialog/DeleteConfirmation.vue +51 -0
- package/components/Dialog/ReplaceAutofillPrompt.vue +49 -0
- package/components/Dialog/UpdateMoreAction.vue +103 -0
- package/components/DocumentForm.vue +187 -0
- package/components/DocumentManagement.vue +376 -0
- package/components/Editor.vue +95 -0
- package/components/EntryPassMain.vue +518 -0
- package/components/Feedback/Form.vue +173 -0
- package/components/FeedbackDetail.vue +599 -0
- package/components/FeedbackMain.vue +588 -0
- package/components/FormDialog.vue +65 -0
- package/components/ImageCarousel.vue +138 -0
- package/components/Input/Date.vue +177 -0
- package/components/Input/DateTimePicker.vue +131 -0
- package/components/Input/File.vue +236 -0
- package/components/Input/FileV2.vue +234 -0
- package/components/Input/InputPhoneNumberV2.vue +164 -0
- package/components/Input/ListGroupSelection.vue +96 -0
- package/components/Input/NRICNumber.vue +53 -0
- package/components/Input/NewDate.vue +123 -0
- package/components/Input/Number.vue +124 -0
- package/components/Input/Password.vue +22 -0
- package/components/Input/PhoneNumber.vue +188 -0
- package/components/Input/VehicleNumber.vue +49 -0
- package/components/InputLabel.vue +22 -0
- package/components/InvitationForm.vue +359 -0
- package/components/InvitationMain.vue +310 -0
- package/components/Layout/Header.vue +129 -0
- package/components/Layout/NavigationDrawer.vue +44 -0
- package/components/ListItem.vue +35 -0
- package/components/ListView.vue +87 -0
- package/components/LocalPagination.vue +31 -0
- package/components/MemberMain.vue +459 -0
- package/components/NFC/NFCPatrolReportMain.vue +591 -0
- package/components/NFC/NFCPatrolRouteForm.vue +596 -0
- package/components/NFC/NFCPatrolRouteMain.vue +539 -0
- package/components/NFC/NFCTagForm.vue +236 -0
- package/components/NFC/NFCTagMain.vue +337 -0
- package/components/NFC/PatrolSettings.vue +130 -0
- package/components/NavigationItem.vue +83 -0
- package/components/NumberSettingField.vue +107 -0
- package/components/OnlineFormConfigurationForm.vue +290 -0
- package/components/OnlineFormsConfiguration.vue +429 -0
- package/components/PeopleForm.vue +452 -0
- package/components/PlaceholderComponent.vue +34 -0
- package/components/RolePermissionFormCreate.vue +161 -0
- package/components/RolePermissionFormPreviewUpdate.vue +183 -0
- package/components/RolePermissionMain.vue +361 -0
- package/components/SearchVehicleNumberUser.vue +91 -0
- package/components/ServiceProviderFormCreate.vue +154 -0
- package/components/ServiceProviderMain.vue +547 -0
- package/components/SignaturePad.vue +73 -0
- package/components/Snackbar.vue +23 -0
- package/components/SpecificAttr.vue +53 -0
- package/components/SupplyManagement.vue +292 -0
- package/components/SwitchContext.vue +108 -0
- package/components/TableList.vue +150 -0
- package/components/TableListSecondary.vue +164 -0
- package/components/TableMain.vue +142 -0
- package/components/TableWithButton.vue +94 -0
- package/components/VehicleUpdateMoreAction.vue +84 -0
- package/components/VideoPlayer.vue +125 -0
- package/components/VisitorForm.vue +659 -0
- package/components/VisitorFormSelection.vue +53 -0
- package/components/VisitorManagement.vue +490 -0
- package/components/WorkOrder/Create.vue +284 -0
- package/components/WorkOrder/Detail.vue +71 -0
- package/components/WorkOrder/ListView.vue +96 -0
- package/components/WorkOrder/Main.vue +489 -0
- package/components/Workorder.vue +1 -0
- package/composables/useAddress.ts +107 -0
- package/composables/useBuilding.ts +250 -0
- package/composables/useBuildingUnit.ts +116 -0
- package/composables/useCard.ts +46 -0
- package/composables/useCommonPermission.ts +207 -0
- package/composables/useCustomer.ts +113 -0
- package/composables/useCustomerSite.ts +56 -0
- package/composables/useDashboard.ts +31 -0
- package/composables/useDashboardData.ts +425 -0
- package/composables/useDocument.ts +57 -0
- package/composables/useFacility.ts +246 -0
- package/composables/useFeedback.ts +119 -0
- package/composables/useFile.ts +55 -0
- package/composables/useInvoice.ts +18 -0
- package/composables/useLocal.ts +131 -0
- package/composables/useLocalAuth.ts +137 -0
- package/composables/useLocalSetup.ts +13 -0
- package/composables/useMember.ts +111 -0
- package/composables/useNFCPatrolRoute.ts +77 -0
- package/composables/useNFCPatrolSettings.ts +19 -0
- package/composables/useNFCPatrolTag.ts +53 -0
- package/composables/useOnlineForm.ts +67 -0
- package/composables/useOrg.ts +129 -0
- package/composables/usePDFDownload.ts +25 -0
- package/composables/usePaymentMethod.ts +101 -0
- package/composables/usePeople.ts +81 -0
- package/composables/usePermission.ts +54 -0
- package/composables/usePhoneCountries.ts +561 -0
- package/composables/usePrice.ts +15 -0
- package/composables/usePromoCode.ts +36 -0
- package/composables/useRecapPermission.ts +26 -0
- package/composables/useRole.ts +104 -0
- package/composables/useSecurityUtils.ts +18 -0
- package/composables/useServiceProvider.ts +224 -0
- package/composables/useSite.ts +109 -0
- package/composables/useSiteEntryPassSettings.ts +46 -0
- package/composables/useSiteSettings.ts +123 -0
- package/composables/useSubscription.ts +150 -0
- package/composables/useUser.ts +132 -0
- package/composables/useUtils.ts +445 -0
- package/composables/useVerification.ts +34 -0
- package/composables/useVisitor.ts +120 -0
- package/composables/useWorkOrder.ts +85 -0
- package/error.vue +41 -0
- package/layouts/plain.vue +7 -0
- package/middleware/01.auth.ts +20 -0
- package/middleware/02.org.ts +21 -0
- package/middleware/03.customer.ts +13 -0
- package/middleware/member.ts +4 -0
- package/nuxt.config.ts +54 -0
- package/package.json +39 -0
- package/pages/index.vue +3 -0
- package/pages/payment-method-linked.vue +31 -0
- package/pages/require-customer.vue +56 -0
- package/pages/require-organization-membership.vue +47 -0
- package/pages/unauthorized.vue +29 -0
- package/plugins/API.ts +21 -0
- package/plugins/iconify.client.ts +5 -0
- package/plugins/secure-member.client.ts +86 -0
- package/plugins/vuetify.ts +62 -0
- package/public/bg-camera.jpg +0 -0
- package/public/bg-city.jpg +0 -0
- package/public/bg-condo.jpg +0 -0
- package/public/images/icons/delete-icon.png +0 -0
- package/public/sprite.svg +1 -0
- package/tsconfig.json +3 -0
- package/types/address.d.ts +13 -0
- package/types/building.d.ts +27 -0
- package/types/camera.d.ts +31 -0
- package/types/card.d.ts +22 -0
- package/types/customer.d.ts +27 -0
- package/types/document.d.ts +6 -0
- package/types/feedback.d.ts +68 -0
- package/types/local.d.ts +74 -0
- package/types/member.d.ts +21 -0
- package/types/online-form.d.ts +15 -0
- package/types/org.d.ts +13 -0
- package/types/people.d.ts +24 -0
- package/types/permission.d.ts +25 -0
- package/types/phone-number.d.ts +10 -0
- package/types/price.d.ts +17 -0
- package/types/promo-code.d.ts +19 -0
- package/types/role.d.ts +11 -0
- package/types/select.d.ts +4 -0
- package/types/service-provider.d.ts +15 -0
- package/types/site.d.ts +20 -0
- package/types/subscription.d.ts +23 -0
- package/types/user.d.ts +19 -0
- package/types/verification.d.ts +20 -0
- package/types/visitor.d.ts +42 -0
- package/types/work-order.d.ts +42 -0
- package/utils/phoneMasks.ts +1703 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export default function usePermission() {
|
|
2
|
+
// Permission-Based Access Control with Dynamic Role Creation
|
|
3
|
+
|
|
4
|
+
// Utility to list all resources and their actions
|
|
5
|
+
function listPermissions(permissions: TPermissions): {
|
|
6
|
+
resource: string;
|
|
7
|
+
actions: { title: string; description: string }[];
|
|
8
|
+
}[] {
|
|
9
|
+
return Object.entries(permissions).map(([resource, actions]) => ({
|
|
10
|
+
resource,
|
|
11
|
+
actions: Object.entries(actions).map(([action, { description }]) => ({
|
|
12
|
+
title: action,
|
|
13
|
+
description,
|
|
14
|
+
})),
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Utility to check if a user has permission
|
|
19
|
+
function hasPermission(
|
|
20
|
+
user: TRole,
|
|
21
|
+
permissions: TPermissions,
|
|
22
|
+
resource: string,
|
|
23
|
+
action: string,
|
|
24
|
+
data?: any
|
|
25
|
+
): boolean {
|
|
26
|
+
const permissionKey = `${resource}:${action}`;
|
|
27
|
+
|
|
28
|
+
// Check if the permission exists in the user's permission array
|
|
29
|
+
if (!user.permissions?.includes(permissionKey)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const resourcePermissions = permissions[resource];
|
|
34
|
+
if (!resourcePermissions || !resourcePermissions[action]) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const permissionCheck = resourcePermissions[action].check;
|
|
39
|
+
|
|
40
|
+
// Evaluate the permission check
|
|
41
|
+
if (typeof permissionCheck === "boolean") {
|
|
42
|
+
return permissionCheck;
|
|
43
|
+
} else if (typeof permissionCheck === "function") {
|
|
44
|
+
return permissionCheck(user, data);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
listPermissions,
|
|
52
|
+
hasPermission,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
export default function usePhoneCountries() {
|
|
2
|
+
const countries: TPhoneCountry[] = [
|
|
3
|
+
// Asia Pacific
|
|
4
|
+
{
|
|
5
|
+
_id: "sg",
|
|
6
|
+
country: "Singapore",
|
|
7
|
+
dialCode: "+65",
|
|
8
|
+
minLength: 8,
|
|
9
|
+
maxLength: 8,
|
|
10
|
+
placeholder: "8123 4567",
|
|
11
|
+
format: /^[89]\d{7}$/,
|
|
12
|
+
label: "+65",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
_id: "my",
|
|
16
|
+
country: "Malaysia",
|
|
17
|
+
dialCode: "+60",
|
|
18
|
+
minLength: 9,
|
|
19
|
+
maxLength: 11,
|
|
20
|
+
placeholder: "12 345 6789",
|
|
21
|
+
format: /^1[0-9]\d{7,9}$/,
|
|
22
|
+
label: "+60",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
_id: "ph",
|
|
26
|
+
country: "Philippines",
|
|
27
|
+
dialCode: "+63",
|
|
28
|
+
minLength: 10,
|
|
29
|
+
maxLength: 10,
|
|
30
|
+
placeholder: "917 123 4567",
|
|
31
|
+
format: /^9\d{9}$/,
|
|
32
|
+
label: "+63",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
_id: "_id",
|
|
36
|
+
country: "Indonesia",
|
|
37
|
+
dialCode: "+62",
|
|
38
|
+
minLength: 9,
|
|
39
|
+
maxLength: 12,
|
|
40
|
+
placeholder: "812 3456 789",
|
|
41
|
+
format: /^8\d{8,11}$/,
|
|
42
|
+
label: "+62",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
_id: "th",
|
|
46
|
+
country: "Thailand",
|
|
47
|
+
dialCode: "+66",
|
|
48
|
+
minLength: 9,
|
|
49
|
+
maxLength: 9,
|
|
50
|
+
placeholder: "81 234 5678",
|
|
51
|
+
format: /^[689]\d{8}$/,
|
|
52
|
+
label: "+66",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
_id: "vn",
|
|
56
|
+
country: "Vietnam",
|
|
57
|
+
dialCode: "+84",
|
|
58
|
+
minLength: 9,
|
|
59
|
+
maxLength: 10,
|
|
60
|
+
placeholder: "912 345 678",
|
|
61
|
+
format: /^[3-9]\d{8,9}$/,
|
|
62
|
+
label: "+84",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
_id: "kh",
|
|
66
|
+
country: "Cambodia",
|
|
67
|
+
dialCode: "+855",
|
|
68
|
+
minLength: 8,
|
|
69
|
+
maxLength: 9,
|
|
70
|
+
placeholder: "12 345 678",
|
|
71
|
+
format: /^[1-9]\d{7,8}$/,
|
|
72
|
+
label: "+855",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
_id: "la",
|
|
76
|
+
country: "Laos",
|
|
77
|
+
dialCode: "+856",
|
|
78
|
+
minLength: 8,
|
|
79
|
+
maxLength: 10,
|
|
80
|
+
placeholder: "20 1234 567",
|
|
81
|
+
format: /^[2-9]\d{7,9}$/,
|
|
82
|
+
label: "+856",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
_id: "mm",
|
|
86
|
+
country: "Myanmar",
|
|
87
|
+
dialCode: "+95",
|
|
88
|
+
minLength: 9,
|
|
89
|
+
maxLength: 10,
|
|
90
|
+
placeholder: "9 1234 5678",
|
|
91
|
+
format: /^9\d{8,9}$/,
|
|
92
|
+
label: "+95",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
_id: "bn",
|
|
96
|
+
country: "Brunei",
|
|
97
|
+
dialCode: "+673",
|
|
98
|
+
minLength: 7,
|
|
99
|
+
maxLength: 7,
|
|
100
|
+
placeholder: "712 3456",
|
|
101
|
+
format: /^[2-8]\d{6}$/,
|
|
102
|
+
label: "+673",
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// Oceania
|
|
106
|
+
{
|
|
107
|
+
_id: "au",
|
|
108
|
+
country: "Australia",
|
|
109
|
+
dialCode: "+61",
|
|
110
|
+
minLength: 9,
|
|
111
|
+
maxLength: 9,
|
|
112
|
+
placeholder: "412 345 678",
|
|
113
|
+
format: /^[2-9]\d{8}$/,
|
|
114
|
+
label: "+61",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
_id: "nz",
|
|
118
|
+
country: "New Zealand",
|
|
119
|
+
dialCode: "+64",
|
|
120
|
+
minLength: 8,
|
|
121
|
+
maxLength: 9,
|
|
122
|
+
placeholder: "21 123 456",
|
|
123
|
+
format: /^[2-9]\d{7,8}$/,
|
|
124
|
+
label: "+64",
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
_id: "pg",
|
|
128
|
+
country: "Papua New Guinea",
|
|
129
|
+
dialCode: "+675",
|
|
130
|
+
minLength: 8,
|
|
131
|
+
maxLength: 8,
|
|
132
|
+
placeholder: "7012 3456",
|
|
133
|
+
format: /^[7-9]\d{7}$/,
|
|
134
|
+
label: "+675",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
_id: "fj",
|
|
138
|
+
country: "Fiji",
|
|
139
|
+
dialCode: "+679",
|
|
140
|
+
minLength: 7,
|
|
141
|
+
maxLength: 7,
|
|
142
|
+
placeholder: "712 3456",
|
|
143
|
+
format: /^[7-9]\d{6}$/,
|
|
144
|
+
label: "+679",
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
// North America
|
|
148
|
+
{
|
|
149
|
+
_id: "us",
|
|
150
|
+
country: "United States",
|
|
151
|
+
dialCode: "+1",
|
|
152
|
+
minLength: 10,
|
|
153
|
+
maxLength: 10,
|
|
154
|
+
placeholder: "(555) 123-4567",
|
|
155
|
+
format: /^\d{10}$/,
|
|
156
|
+
label: "+1 (US)",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
_id: "ca",
|
|
160
|
+
country: "Canada",
|
|
161
|
+
dialCode: "+1",
|
|
162
|
+
minLength: 10,
|
|
163
|
+
maxLength: 10,
|
|
164
|
+
placeholder: "(416) 123-4567",
|
|
165
|
+
format: /^\d{10}$/,
|
|
166
|
+
label: "+1 (CA)",
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
// Europe
|
|
170
|
+
{
|
|
171
|
+
_id: "gb",
|
|
172
|
+
country: "United Kingdom",
|
|
173
|
+
dialCode: "+44",
|
|
174
|
+
minLength: 10,
|
|
175
|
+
maxLength: 11,
|
|
176
|
+
placeholder: "7700 900123",
|
|
177
|
+
format: /^[1-9]\d{9,10}$/,
|
|
178
|
+
label: "+44",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
_id: "de",
|
|
182
|
+
country: "Germany",
|
|
183
|
+
dialCode: "+49",
|
|
184
|
+
minLength: 10,
|
|
185
|
+
maxLength: 12,
|
|
186
|
+
placeholder: "151 12345678",
|
|
187
|
+
format: /^[1-9]\d{9,11}$/,
|
|
188
|
+
label: "+49",
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
_id: "fr",
|
|
192
|
+
country: "France",
|
|
193
|
+
dialCode: "+33",
|
|
194
|
+
minLength: 9,
|
|
195
|
+
maxLength: 9,
|
|
196
|
+
placeholder: "6 12 34 56 78",
|
|
197
|
+
format: /^[1-9]\d{8}$/,
|
|
198
|
+
label: "+33",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
_id: "it",
|
|
202
|
+
country: "Italy",
|
|
203
|
+
dialCode: "+39",
|
|
204
|
+
minLength: 9,
|
|
205
|
+
maxLength: 11,
|
|
206
|
+
placeholder: "312 345 6789",
|
|
207
|
+
format: /^3\d{8,10}$/,
|
|
208
|
+
label: "+39",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
_id: "es",
|
|
212
|
+
country: "Spain",
|
|
213
|
+
dialCode: "+34",
|
|
214
|
+
minLength: 9,
|
|
215
|
+
maxLength: 9,
|
|
216
|
+
placeholder: "612 34 56 78",
|
|
217
|
+
format: /^[6-9]\d{8}$/,
|
|
218
|
+
label: "+34",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
_id: "nl",
|
|
222
|
+
country: "Netherlands",
|
|
223
|
+
dialCode: "+31",
|
|
224
|
+
minLength: 9,
|
|
225
|
+
maxLength: 9,
|
|
226
|
+
placeholder: "6 12345678",
|
|
227
|
+
format: /^6\d{8}$/,
|
|
228
|
+
label: "+31",
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
_id: "ch",
|
|
232
|
+
country: "Switzerland",
|
|
233
|
+
dialCode: "+41",
|
|
234
|
+
minLength: 9,
|
|
235
|
+
maxLength: 9,
|
|
236
|
+
placeholder: "78 123 45 67",
|
|
237
|
+
format: /^[7-9]\d{8}$/,
|
|
238
|
+
label: "+41",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
_id: "at",
|
|
242
|
+
country: "Austria",
|
|
243
|
+
dialCode: "+43",
|
|
244
|
+
minLength: 10,
|
|
245
|
+
maxLength: 11,
|
|
246
|
+
placeholder: "664 123456",
|
|
247
|
+
format: /^[6-9]\d{9,10}$/,
|
|
248
|
+
label: "+43",
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
_id: "be",
|
|
252
|
+
country: "Belgium",
|
|
253
|
+
dialCode: "+32",
|
|
254
|
+
minLength: 9,
|
|
255
|
+
maxLength: 9,
|
|
256
|
+
placeholder: "470 12 34 56",
|
|
257
|
+
format: /^4\d{8}$/,
|
|
258
|
+
label: "+32",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
_id: "se",
|
|
262
|
+
country: "Sweden",
|
|
263
|
+
dialCode: "+46",
|
|
264
|
+
minLength: 9,
|
|
265
|
+
maxLength: 9,
|
|
266
|
+
placeholder: "70 123 45 67",
|
|
267
|
+
format: /^7\d{8}$/,
|
|
268
|
+
label: "+46",
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
_id: "no",
|
|
272
|
+
country: "Norway",
|
|
273
|
+
dialCode: "+47",
|
|
274
|
+
minLength: 8,
|
|
275
|
+
maxLength: 8,
|
|
276
|
+
placeholder: "412 34 567",
|
|
277
|
+
format: /^[4-9]\d{7}$/,
|
|
278
|
+
label: "+47",
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
_id: "dk",
|
|
282
|
+
country: "Denmark",
|
|
283
|
+
dialCode: "+45",
|
|
284
|
+
minLength: 8,
|
|
285
|
+
maxLength: 8,
|
|
286
|
+
placeholder: "20 12 34 56",
|
|
287
|
+
format: /^[2-9]\d{7}$/,
|
|
288
|
+
label: "+45",
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
_id: "fi",
|
|
292
|
+
country: "Finland",
|
|
293
|
+
dialCode: "+358",
|
|
294
|
+
minLength: 9,
|
|
295
|
+
maxLength: 10,
|
|
296
|
+
placeholder: "50 123 4567",
|
|
297
|
+
format: /^[4-5]\d{8,9}$/,
|
|
298
|
+
label: "+358",
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
// Middle East
|
|
302
|
+
{
|
|
303
|
+
_id: "sa",
|
|
304
|
+
country: "Saudi Arabia",
|
|
305
|
+
dialCode: "+966",
|
|
306
|
+
minLength: 9,
|
|
307
|
+
maxLength: 9,
|
|
308
|
+
placeholder: "50 123 4567",
|
|
309
|
+
format: /^5\d{8}$/,
|
|
310
|
+
label: "+966",
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
_id: "ae",
|
|
314
|
+
country: "United Arab Emirates",
|
|
315
|
+
dialCode: "+971",
|
|
316
|
+
minLength: 9,
|
|
317
|
+
maxLength: 9,
|
|
318
|
+
placeholder: "50 123 4567",
|
|
319
|
+
format: /^5\d{8}$/,
|
|
320
|
+
label: "+971",
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
_id: "qa",
|
|
324
|
+
country: "Qatar",
|
|
325
|
+
dialCode: "+974",
|
|
326
|
+
minLength: 8,
|
|
327
|
+
maxLength: 8,
|
|
328
|
+
placeholder: "3012 3456",
|
|
329
|
+
format: /^[3-7]\d{7}$/,
|
|
330
|
+
label: "+974",
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
_id: "kw",
|
|
334
|
+
country: "Kuwait",
|
|
335
|
+
dialCode: "+965",
|
|
336
|
+
minLength: 8,
|
|
337
|
+
maxLength: 8,
|
|
338
|
+
placeholder: "5012 3456",
|
|
339
|
+
format: /^[569]\d{7}$/,
|
|
340
|
+
label: "+965",
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
_id: "bh",
|
|
344
|
+
country: "Bahrain",
|
|
345
|
+
dialCode: "+973",
|
|
346
|
+
minLength: 8,
|
|
347
|
+
maxLength: 8,
|
|
348
|
+
placeholder: "3612 3456",
|
|
349
|
+
format: /^[3-9]\d{7}$/,
|
|
350
|
+
label: "+973",
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
_id: "om",
|
|
354
|
+
country: "Oman",
|
|
355
|
+
dialCode: "+968",
|
|
356
|
+
minLength: 8,
|
|
357
|
+
maxLength: 8,
|
|
358
|
+
placeholder: "9012 3456",
|
|
359
|
+
format: /^[79]\d{7}$/,
|
|
360
|
+
label: "+968",
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
// East Asia
|
|
364
|
+
{
|
|
365
|
+
_id: "cn",
|
|
366
|
+
country: "China",
|
|
367
|
+
dialCode: "+86",
|
|
368
|
+
minLength: 11,
|
|
369
|
+
maxLength: 11,
|
|
370
|
+
placeholder: "138 0013 8000",
|
|
371
|
+
format: /^1[3-9]\d{9}$/,
|
|
372
|
+
label: "+86",
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
_id: "jp",
|
|
376
|
+
country: "Japan",
|
|
377
|
+
dialCode: "+81",
|
|
378
|
+
minLength: 10,
|
|
379
|
+
maxLength: 11,
|
|
380
|
+
placeholder: "90 1234 5678",
|
|
381
|
+
format: /^[7-9]\d{9,10}$/,
|
|
382
|
+
label: "+81",
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
_id: "kr",
|
|
386
|
+
country: "South Korea",
|
|
387
|
+
dialCode: "+82",
|
|
388
|
+
minLength: 10,
|
|
389
|
+
maxLength: 11,
|
|
390
|
+
placeholder: "10 1234 5678",
|
|
391
|
+
format: /^1[0-9]\d{8,9}$/,
|
|
392
|
+
label: "+82",
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
_id: "hk",
|
|
396
|
+
country: "Hong Kong",
|
|
397
|
+
dialCode: "+852",
|
|
398
|
+
minLength: 8,
|
|
399
|
+
maxLength: 8,
|
|
400
|
+
placeholder: "5123 4567",
|
|
401
|
+
format: /^[5-9]\d{7}$/,
|
|
402
|
+
label: "+852",
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
_id: "tw",
|
|
406
|
+
country: "Taiwan",
|
|
407
|
+
dialCode: "+886",
|
|
408
|
+
minLength: 9,
|
|
409
|
+
maxLength: 9,
|
|
410
|
+
placeholder: "912 345 678",
|
|
411
|
+
format: /^9\d{8}$/,
|
|
412
|
+
label: "+886",
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
_id: "mo",
|
|
416
|
+
country: "Macau",
|
|
417
|
+
dialCode: "+853",
|
|
418
|
+
minLength: 8,
|
|
419
|
+
maxLength: 8,
|
|
420
|
+
placeholder: "6123 4567",
|
|
421
|
+
format: /^6\d{7}$/,
|
|
422
|
+
label: "+853",
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
// South Asia
|
|
426
|
+
{
|
|
427
|
+
_id: "in",
|
|
428
|
+
country: "India",
|
|
429
|
+
dialCode: "+91",
|
|
430
|
+
minLength: 10,
|
|
431
|
+
maxLength: 10,
|
|
432
|
+
placeholder: "98765 43210",
|
|
433
|
+
format: /^[6-9]\d{9}$/,
|
|
434
|
+
label: "+91",
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
_id: "pk",
|
|
438
|
+
country: "Pakistan",
|
|
439
|
+
dialCode: "+92",
|
|
440
|
+
minLength: 10,
|
|
441
|
+
maxLength: 10,
|
|
442
|
+
placeholder: "301 2345678",
|
|
443
|
+
format: /^3\d{9}$/,
|
|
444
|
+
label: "+92",
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
_id: "bd",
|
|
448
|
+
country: "Bangladesh",
|
|
449
|
+
dialCode: "+880",
|
|
450
|
+
minLength: 10,
|
|
451
|
+
maxLength: 10,
|
|
452
|
+
placeholder: "1712 345678",
|
|
453
|
+
format: /^1[3-9]\d{8}$/,
|
|
454
|
+
label: "+880",
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
_id: "lk",
|
|
458
|
+
country: "Sri Lanka",
|
|
459
|
+
dialCode: "+94",
|
|
460
|
+
minLength: 9,
|
|
461
|
+
maxLength: 9,
|
|
462
|
+
placeholder: "71 234 5678",
|
|
463
|
+
format: /^7[0-8]\d{7}$/,
|
|
464
|
+
label: "+94",
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
_id: "np",
|
|
468
|
+
country: "Nepal",
|
|
469
|
+
dialCode: "+977",
|
|
470
|
+
minLength: 10,
|
|
471
|
+
maxLength: 10,
|
|
472
|
+
placeholder: "98 1234 5678",
|
|
473
|
+
format: /^9[78]\d{8}$/,
|
|
474
|
+
label: "+977",
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
_id: "mv",
|
|
478
|
+
country: "Maldives",
|
|
479
|
+
dialCode: "+960",
|
|
480
|
+
minLength: 7,
|
|
481
|
+
maxLength: 7,
|
|
482
|
+
placeholder: "791 2345",
|
|
483
|
+
format: /^[79]\d{6}$/,
|
|
484
|
+
label: "+960",
|
|
485
|
+
},
|
|
486
|
+
];
|
|
487
|
+
|
|
488
|
+
const getCountryByDialCode = (
|
|
489
|
+
dialCode: string
|
|
490
|
+
): TPhoneCountry | undefined => {
|
|
491
|
+
return countries.find((country) => country.dialCode === dialCode);
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
const getDialCodes = (): string[] => {
|
|
495
|
+
return countries.map((country) => country.dialCode);
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const formatPhoneNumber = (phoneNumber: string, dialCode: string): string => {
|
|
499
|
+
const country = getCountryByDialCode(dialCode);
|
|
500
|
+
if (!country) return phoneNumber;
|
|
501
|
+
|
|
502
|
+
let value = phoneNumber.replace(/\D/g, ""); // Remove non-digits
|
|
503
|
+
|
|
504
|
+
switch (dialCode) {
|
|
505
|
+
case "+65": // Singapore
|
|
506
|
+
if (value.length > 4) {
|
|
507
|
+
value = value.substring(0, 4) + " " + value.substring(4, 8);
|
|
508
|
+
}
|
|
509
|
+
break;
|
|
510
|
+
case "+60": // Malaysia
|
|
511
|
+
if (value.length > 2) {
|
|
512
|
+
value =
|
|
513
|
+
value.substring(0, 2) +
|
|
514
|
+
" " +
|
|
515
|
+
value.substring(2, 5) +
|
|
516
|
+
" " +
|
|
517
|
+
value.substring(5);
|
|
518
|
+
}
|
|
519
|
+
break;
|
|
520
|
+
case "+1": // US/Canada
|
|
521
|
+
if (value.length > 6) {
|
|
522
|
+
value =
|
|
523
|
+
"(" +
|
|
524
|
+
value.substring(0, 3) +
|
|
525
|
+
") " +
|
|
526
|
+
value.substring(3, 6) +
|
|
527
|
+
"-" +
|
|
528
|
+
value.substring(6, 10);
|
|
529
|
+
} else if (value.length > 3) {
|
|
530
|
+
value = "(" + value.substring(0, 3) + ") " + value.substring(3);
|
|
531
|
+
}
|
|
532
|
+
break;
|
|
533
|
+
case "+44": // UK
|
|
534
|
+
if (value.length > 4) {
|
|
535
|
+
value = value.substring(0, 4) + " " + value.substring(4);
|
|
536
|
+
}
|
|
537
|
+
break;
|
|
538
|
+
default:
|
|
539
|
+
// Generic formatting for other countries
|
|
540
|
+
if (value.length > 3 && value.length <= 6) {
|
|
541
|
+
value = value.substring(0, 3) + " " + value.substring(3);
|
|
542
|
+
} else if (value.length > 6) {
|
|
543
|
+
value =
|
|
544
|
+
value.substring(0, 3) +
|
|
545
|
+
" " +
|
|
546
|
+
value.substring(3, 6) +
|
|
547
|
+
" " +
|
|
548
|
+
value.substring(6);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return value;
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
return {
|
|
556
|
+
countries,
|
|
557
|
+
getCountryByDialCode,
|
|
558
|
+
getDialCodes,
|
|
559
|
+
formatPhoneNumber,
|
|
560
|
+
};
|
|
561
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default function usePrice() {
|
|
2
|
+
function getByNameType(name: string, type: string) {
|
|
3
|
+
return useNuxtApp().$api<Record<string, any>>("/api/prices/price", {
|
|
4
|
+
method: "GET",
|
|
5
|
+
params: {
|
|
6
|
+
name,
|
|
7
|
+
type,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
getByNameType,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export default function usePromoCode() {
|
|
2
|
+
function add(value: TPromoCode) {
|
|
3
|
+
return useNuxtApp().$api<Record<string, any>>("/api/promo-codes", {
|
|
4
|
+
method: "POST",
|
|
5
|
+
body: value,
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getPromoCodes({ search = "", page = 1, status = "active" } = {}) {
|
|
10
|
+
return useNuxtApp().$api<Record<string, any>>("/api/promo-codes", {
|
|
11
|
+
method: "GET",
|
|
12
|
+
query: {
|
|
13
|
+
search,
|
|
14
|
+
page,
|
|
15
|
+
status,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getByCode(code: string, type?: string, assigned?: boolean) {
|
|
21
|
+
return useNuxtApp().$api<Record<string, any>>("/api/promo-codes/code", {
|
|
22
|
+
method: "GET",
|
|
23
|
+
params: {
|
|
24
|
+
code,
|
|
25
|
+
type,
|
|
26
|
+
assigned,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
add,
|
|
33
|
+
getPromoCodes,
|
|
34
|
+
getByCode,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default function useRecapPermission() {
|
|
2
|
+
const permissions: TPermissions = {
|
|
3
|
+
request: {
|
|
4
|
+
"create-request": {
|
|
5
|
+
check: true,
|
|
6
|
+
description: "Create a new request.",
|
|
7
|
+
},
|
|
8
|
+
"review-request": {
|
|
9
|
+
check: true,
|
|
10
|
+
description: "Review a request.",
|
|
11
|
+
},
|
|
12
|
+
"approve-request": {
|
|
13
|
+
check: true,
|
|
14
|
+
description: "Approve a request.",
|
|
15
|
+
},
|
|
16
|
+
"delete-request": {
|
|
17
|
+
check: true,
|
|
18
|
+
description: "Delete authored request.",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
permissions,
|
|
25
|
+
};
|
|
26
|
+
}
|