@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.
Files changed (198) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.editorconfig +12 -0
  4. package/.github/workflows/main.yml +17 -0
  5. package/.github/workflows/publish.yml +39 -0
  6. package/.nuxtrc +1 -0
  7. package/.playground/app.vue +41 -0
  8. package/.playground/eslint.config.mjs +6 -0
  9. package/.playground/nuxt.config.ts +22 -0
  10. package/.playground/pages/feedback.vue +30 -0
  11. package/CHANGELOG.md +263 -0
  12. package/README.md +73 -0
  13. package/app.vue +3 -0
  14. package/components/AccessCardAddForm.vue +363 -0
  15. package/components/AccessManagement.vue +420 -0
  16. package/components/Avatar/Main.vue +68 -0
  17. package/components/BillingMain.vue +66 -0
  18. package/components/BtnUploadFile.vue +139 -0
  19. package/components/BuildingForm.vue +303 -0
  20. package/components/BuildingManagement/buildings.vue +335 -0
  21. package/components/BuildingManagement/units.vue +350 -0
  22. package/components/BuildingUnitFormAdd.vue +441 -0
  23. package/components/BuildingUnitFormEdit.vue +429 -0
  24. package/components/CameraForm.vue +264 -0
  25. package/components/CameraMain.vue +352 -0
  26. package/components/Card/DeleteConfirmation.vue +51 -0
  27. package/components/Card/MemberInfoSummary.vue +44 -0
  28. package/components/Card/Toggle.vue +25 -0
  29. package/components/Chat/Bubbles.vue +53 -0
  30. package/components/Chat/Information.vue +416 -0
  31. package/components/Chat/ListCard.vue +62 -0
  32. package/components/Chat/Message.vue +158 -0
  33. package/components/Chat/Navigation.vue +150 -0
  34. package/components/ConfirmDialog.vue +66 -0
  35. package/components/Container/Standard.vue +33 -0
  36. package/components/DashboardPlaceholder.vue +1524 -0
  37. package/components/Dialog/DeleteConfirmation.vue +51 -0
  38. package/components/Dialog/ReplaceAutofillPrompt.vue +49 -0
  39. package/components/Dialog/UpdateMoreAction.vue +103 -0
  40. package/components/DocumentForm.vue +187 -0
  41. package/components/DocumentManagement.vue +376 -0
  42. package/components/Editor.vue +95 -0
  43. package/components/EntryPassMain.vue +518 -0
  44. package/components/Feedback/Form.vue +173 -0
  45. package/components/FeedbackDetail.vue +599 -0
  46. package/components/FeedbackMain.vue +588 -0
  47. package/components/FormDialog.vue +65 -0
  48. package/components/ImageCarousel.vue +138 -0
  49. package/components/Input/Date.vue +177 -0
  50. package/components/Input/DateTimePicker.vue +131 -0
  51. package/components/Input/File.vue +236 -0
  52. package/components/Input/FileV2.vue +234 -0
  53. package/components/Input/InputPhoneNumberV2.vue +164 -0
  54. package/components/Input/ListGroupSelection.vue +96 -0
  55. package/components/Input/NRICNumber.vue +53 -0
  56. package/components/Input/NewDate.vue +123 -0
  57. package/components/Input/Number.vue +124 -0
  58. package/components/Input/Password.vue +22 -0
  59. package/components/Input/PhoneNumber.vue +188 -0
  60. package/components/Input/VehicleNumber.vue +49 -0
  61. package/components/InputLabel.vue +22 -0
  62. package/components/InvitationForm.vue +359 -0
  63. package/components/InvitationMain.vue +310 -0
  64. package/components/Layout/Header.vue +129 -0
  65. package/components/Layout/NavigationDrawer.vue +44 -0
  66. package/components/ListItem.vue +35 -0
  67. package/components/ListView.vue +87 -0
  68. package/components/LocalPagination.vue +31 -0
  69. package/components/MemberMain.vue +459 -0
  70. package/components/NFC/NFCPatrolReportMain.vue +591 -0
  71. package/components/NFC/NFCPatrolRouteForm.vue +596 -0
  72. package/components/NFC/NFCPatrolRouteMain.vue +539 -0
  73. package/components/NFC/NFCTagForm.vue +236 -0
  74. package/components/NFC/NFCTagMain.vue +337 -0
  75. package/components/NFC/PatrolSettings.vue +130 -0
  76. package/components/NavigationItem.vue +83 -0
  77. package/components/NumberSettingField.vue +107 -0
  78. package/components/OnlineFormConfigurationForm.vue +290 -0
  79. package/components/OnlineFormsConfiguration.vue +429 -0
  80. package/components/PeopleForm.vue +452 -0
  81. package/components/PlaceholderComponent.vue +34 -0
  82. package/components/RolePermissionFormCreate.vue +161 -0
  83. package/components/RolePermissionFormPreviewUpdate.vue +183 -0
  84. package/components/RolePermissionMain.vue +361 -0
  85. package/components/SearchVehicleNumberUser.vue +91 -0
  86. package/components/ServiceProviderFormCreate.vue +154 -0
  87. package/components/ServiceProviderMain.vue +547 -0
  88. package/components/SignaturePad.vue +73 -0
  89. package/components/Snackbar.vue +23 -0
  90. package/components/SpecificAttr.vue +53 -0
  91. package/components/SupplyManagement.vue +292 -0
  92. package/components/SwitchContext.vue +108 -0
  93. package/components/TableList.vue +150 -0
  94. package/components/TableListSecondary.vue +164 -0
  95. package/components/TableMain.vue +142 -0
  96. package/components/TableWithButton.vue +94 -0
  97. package/components/VehicleUpdateMoreAction.vue +84 -0
  98. package/components/VideoPlayer.vue +125 -0
  99. package/components/VisitorForm.vue +659 -0
  100. package/components/VisitorFormSelection.vue +53 -0
  101. package/components/VisitorManagement.vue +490 -0
  102. package/components/WorkOrder/Create.vue +284 -0
  103. package/components/WorkOrder/Detail.vue +71 -0
  104. package/components/WorkOrder/ListView.vue +96 -0
  105. package/components/WorkOrder/Main.vue +489 -0
  106. package/components/Workorder.vue +1 -0
  107. package/composables/useAddress.ts +107 -0
  108. package/composables/useBuilding.ts +250 -0
  109. package/composables/useBuildingUnit.ts +116 -0
  110. package/composables/useCard.ts +46 -0
  111. package/composables/useCommonPermission.ts +207 -0
  112. package/composables/useCustomer.ts +113 -0
  113. package/composables/useCustomerSite.ts +56 -0
  114. package/composables/useDashboard.ts +31 -0
  115. package/composables/useDashboardData.ts +425 -0
  116. package/composables/useDocument.ts +57 -0
  117. package/composables/useFacility.ts +246 -0
  118. package/composables/useFeedback.ts +119 -0
  119. package/composables/useFile.ts +55 -0
  120. package/composables/useInvoice.ts +18 -0
  121. package/composables/useLocal.ts +131 -0
  122. package/composables/useLocalAuth.ts +137 -0
  123. package/composables/useLocalSetup.ts +13 -0
  124. package/composables/useMember.ts +111 -0
  125. package/composables/useNFCPatrolRoute.ts +77 -0
  126. package/composables/useNFCPatrolSettings.ts +19 -0
  127. package/composables/useNFCPatrolTag.ts +53 -0
  128. package/composables/useOnlineForm.ts +67 -0
  129. package/composables/useOrg.ts +129 -0
  130. package/composables/usePDFDownload.ts +25 -0
  131. package/composables/usePaymentMethod.ts +101 -0
  132. package/composables/usePeople.ts +81 -0
  133. package/composables/usePermission.ts +54 -0
  134. package/composables/usePhoneCountries.ts +561 -0
  135. package/composables/usePrice.ts +15 -0
  136. package/composables/usePromoCode.ts +36 -0
  137. package/composables/useRecapPermission.ts +26 -0
  138. package/composables/useRole.ts +104 -0
  139. package/composables/useSecurityUtils.ts +18 -0
  140. package/composables/useServiceProvider.ts +224 -0
  141. package/composables/useSite.ts +109 -0
  142. package/composables/useSiteEntryPassSettings.ts +46 -0
  143. package/composables/useSiteSettings.ts +123 -0
  144. package/composables/useSubscription.ts +150 -0
  145. package/composables/useUser.ts +132 -0
  146. package/composables/useUtils.ts +445 -0
  147. package/composables/useVerification.ts +34 -0
  148. package/composables/useVisitor.ts +120 -0
  149. package/composables/useWorkOrder.ts +85 -0
  150. package/error.vue +41 -0
  151. package/layouts/plain.vue +7 -0
  152. package/middleware/01.auth.ts +20 -0
  153. package/middleware/02.org.ts +21 -0
  154. package/middleware/03.customer.ts +13 -0
  155. package/middleware/member.ts +4 -0
  156. package/nuxt.config.ts +54 -0
  157. package/package.json +39 -0
  158. package/pages/index.vue +3 -0
  159. package/pages/payment-method-linked.vue +31 -0
  160. package/pages/require-customer.vue +56 -0
  161. package/pages/require-organization-membership.vue +47 -0
  162. package/pages/unauthorized.vue +29 -0
  163. package/plugins/API.ts +21 -0
  164. package/plugins/iconify.client.ts +5 -0
  165. package/plugins/secure-member.client.ts +86 -0
  166. package/plugins/vuetify.ts +62 -0
  167. package/public/bg-camera.jpg +0 -0
  168. package/public/bg-city.jpg +0 -0
  169. package/public/bg-condo.jpg +0 -0
  170. package/public/images/icons/delete-icon.png +0 -0
  171. package/public/sprite.svg +1 -0
  172. package/tsconfig.json +3 -0
  173. package/types/address.d.ts +13 -0
  174. package/types/building.d.ts +27 -0
  175. package/types/camera.d.ts +31 -0
  176. package/types/card.d.ts +22 -0
  177. package/types/customer.d.ts +27 -0
  178. package/types/document.d.ts +6 -0
  179. package/types/feedback.d.ts +68 -0
  180. package/types/local.d.ts +74 -0
  181. package/types/member.d.ts +21 -0
  182. package/types/online-form.d.ts +15 -0
  183. package/types/org.d.ts +13 -0
  184. package/types/people.d.ts +24 -0
  185. package/types/permission.d.ts +25 -0
  186. package/types/phone-number.d.ts +10 -0
  187. package/types/price.d.ts +17 -0
  188. package/types/promo-code.d.ts +19 -0
  189. package/types/role.d.ts +11 -0
  190. package/types/select.d.ts +4 -0
  191. package/types/service-provider.d.ts +15 -0
  192. package/types/site.d.ts +20 -0
  193. package/types/subscription.d.ts +23 -0
  194. package/types/user.d.ts +19 -0
  195. package/types/verification.d.ts +20 -0
  196. package/types/visitor.d.ts +42 -0
  197. package/types/work-order.d.ts +42 -0
  198. package/utils/phoneMasks.ts +1703 -0
@@ -0,0 +1,104 @@
1
+ export default function useRole() {
2
+ function createRole(
3
+ { name, permissions, type, org } = {} as {
4
+ name: string;
5
+ permissions: Array<string>;
6
+ type: string;
7
+ org?: string;
8
+ }
9
+ ) {
10
+ return useNuxtApp().$api("/api/roles", {
11
+ method: "POST",
12
+ body: { name, permissions, type, org },
13
+ });
14
+ }
15
+
16
+ function getRoles({
17
+ search = "",
18
+ page = 1,
19
+ limit = 20,
20
+ type = "",
21
+ org = "",
22
+ } = {}) {
23
+ return useNuxtApp().$api<Record<string, any>>("/api/roles", {
24
+ method: "GET",
25
+ query: { search, page, limit, type, org },
26
+ });
27
+ }
28
+
29
+ function getRoleById(id: string) {
30
+ return useNuxtApp().$api<TRole>(`/api/roles/id/${id}`, {
31
+ method: "GET",
32
+ });
33
+ }
34
+
35
+ function updateRoleById(
36
+ _id: string,
37
+ name?: string,
38
+ permissions?: Array<string>
39
+ ) {
40
+ return useNuxtApp().$api(`/api/roles/id/${_id}`, {
41
+ method: "PATCH",
42
+ body: { name, permissions },
43
+ });
44
+ }
45
+
46
+ function updatePermissionById(_id: string, permissions?: Array<string>) {
47
+ return useNuxtApp().$api(`/api/roles/permissions/id/${_id}`, {
48
+ method: "PATCH",
49
+ body: { permissions },
50
+ });
51
+ }
52
+
53
+ function updateRoleFieldById(_id: string, field: string, value: string) {
54
+ return useNuxtApp().$api(`/api/roles/${_id}`, {
55
+ method: "PATCH",
56
+ body: { field, value },
57
+ });
58
+ }
59
+
60
+ function deleteRole(_id: string) {
61
+ return useNuxtApp().$api<Record<string, any>>(`/api/roles/${_id}`, {
62
+ method: "DELETE",
63
+ });
64
+ }
65
+
66
+ const role = useState<TRole>("userRole", () => {
67
+ return {
68
+ _id: "",
69
+ name: "",
70
+ permissions: [],
71
+ description: "",
72
+ createdAt: "",
73
+ updatedAt: "",
74
+ deletedAt: "",
75
+ };
76
+ });
77
+
78
+ const { getByUserId } = useMember();
79
+
80
+ async function getRoleByUserId(user: string) {
81
+ const member = ref<TMember | null>(null);
82
+
83
+ try {
84
+ const res = await getByUserId(user);
85
+ member.value = res;
86
+ const _role = await getRoleById(res.role);
87
+ Object.assign(role.value, _role);
88
+ } catch (error) {
89
+ console.log(error);
90
+ }
91
+ }
92
+
93
+ return {
94
+ role,
95
+ createRole,
96
+ getRoles,
97
+ getRoleById,
98
+ updateRoleById,
99
+ updateRoleFieldById,
100
+ deleteRole,
101
+ updatePermissionById,
102
+ getRoleByUserId,
103
+ };
104
+ }
@@ -0,0 +1,18 @@
1
+ export default function(){
2
+
3
+ const formatLocation = ({block, level, unit}: {block: number, level: string, unit: string | TBuildingUnit}) => {
4
+ const parts = [];
5
+
6
+ if (block) parts.push(`Block ${block}`);
7
+ if (level) parts.push(level);
8
+ if (unit) parts.push(unit);
9
+
10
+ return parts.join(" / ");
11
+ };
12
+
13
+
14
+ return {
15
+ formatLocation
16
+
17
+ }
18
+ }
@@ -0,0 +1,224 @@
1
+ export default function useServiceProvider() {
2
+ const serviceProviders = useState<Array<TServiceProvider>>(
3
+ "serviceProviders",
4
+ () => []
5
+ );
6
+ const serviceProviderCategories = useState<string[]>(
7
+ "serviceProviderCategories",
8
+ () => []
9
+ );
10
+
11
+ const page = useState("page", () => 1);
12
+ const pages = useState("pages", () => 0);
13
+ const pageRange = useState("pageRange", () => "-- - -- of --");
14
+
15
+ const serviceProvider = useState(
16
+ "serviceProvider",
17
+ (): TServiceProvider => ({
18
+ _id: "",
19
+ name: "",
20
+ orgId: "",
21
+ customerOrgId: "",
22
+ siteId: "",
23
+ serviceProviderOrgId: "",
24
+ type: "",
25
+ nature: "",
26
+ })
27
+ );
28
+
29
+ async function getServiceProviders({
30
+ page = 1,
31
+ search = "",
32
+ limit = 10,
33
+ serviceProviderId = "",
34
+ orgId = "",
35
+ siteId = "",
36
+ } = {}) {
37
+ try {
38
+ const response = await useNuxtApp().$api<Record<string, any>>(
39
+ "/api/service-providers",
40
+ {
41
+ method: "GET",
42
+ query: { page, search, limit, serviceProviderId, orgId, siteId },
43
+ }
44
+ );
45
+ serviceProviders.value = response.items;
46
+ pages.value = response.pages;
47
+ pageRange.value = response.pageRange;
48
+ } catch (err) {
49
+ console.error(err);
50
+ }
51
+ }
52
+
53
+ async function getAll({
54
+ page = 1,
55
+ search = "",
56
+ limit = 10,
57
+ serviceProviderOrgId = "",
58
+ orgId = "",
59
+ siteId = "",
60
+ } = {}) {
61
+ return useNuxtApp().$api<Record<string, any>>("/api/service-providers", {
62
+ method: "GET",
63
+ query: { page, search, limit, serviceProviderOrgId, orgId, siteId },
64
+ });
65
+ }
66
+
67
+ async function getByProviderOrg({
68
+ page = 1,
69
+ search = "",
70
+ limit = 10,
71
+ provider = "",
72
+ org = "",
73
+ } = {}) {
74
+ return useNuxtApp().$api<Record<string, any>>(
75
+ `/api/service-providers/provider/${provider}/org/${org}`,
76
+ {
77
+ method: "GET",
78
+ query: { page, search, limit },
79
+ }
80
+ );
81
+ }
82
+
83
+ async function getByServiceProviderOrgIdType({ id = "", type = "" } = {}) {
84
+ return useNuxtApp().$api<Record<string, any>>(
85
+ `/api/service-providers/org/${id}/type/${type}`,
86
+ {
87
+ method: "GET",
88
+ }
89
+ );
90
+ }
91
+
92
+ async function getServiceProviderNames({
93
+ page = 1,
94
+ search = "",
95
+ limit = 10,
96
+ } = {}): Promise<TServiceProviderPaginatedResponse | undefined> {
97
+ try {
98
+ const response =
99
+ await useNuxtApp().$api<TServiceProviderPaginatedResponse>(
100
+ "/api/service-providers/name",
101
+ {
102
+ method: "GET",
103
+ query: { page, search, limit },
104
+ }
105
+ );
106
+ return response;
107
+ } catch (err) {
108
+ console.error(err);
109
+ }
110
+ }
111
+
112
+ async function getServiceProviderCategories() {
113
+ try {
114
+ const response = await useNuxtApp().$api<{
115
+ items: string[];
116
+ page: number;
117
+ pages: number;
118
+ pageRange: string;
119
+ limit: number;
120
+ }>("/api/service-providers/category?page=1&limit=100", {
121
+ method: "GET",
122
+ });
123
+ serviceProviderCategories.value = response.items;
124
+ } catch (err) {
125
+ console.error("Error fetching service provider categories:", err);
126
+ }
127
+ }
128
+
129
+ async function createServiceProviderInvite({
130
+ email,
131
+ siteId,
132
+ serviceProviderOrgId,
133
+ }: {
134
+ email: string;
135
+ siteId: string;
136
+ serviceProviderOrgId: string;
137
+ }) {
138
+ try {
139
+ await useNuxtApp().$api<Record<string, any>>(
140
+ "/api/auth/invite/service-provider",
141
+ {
142
+ method: "POST",
143
+ body: { email, siteId, serviceProviderOrgId },
144
+ }
145
+ );
146
+ } catch (err) {
147
+ console.error("Error creating service provider invite:", err);
148
+ }
149
+ }
150
+
151
+ async function invite({
152
+ email = "",
153
+ orgId = "",
154
+ siteId = "",
155
+ siteName = "",
156
+ } = {}) {
157
+ return useNuxtApp().$api<Record<string, any>>(
158
+ "/api/service-providers/invite",
159
+ {
160
+ method: "POST",
161
+ body: { email, orgId, siteId, siteName },
162
+ }
163
+ );
164
+ }
165
+
166
+ async function add({
167
+ name = "",
168
+ type = "",
169
+ description = "",
170
+ email = "",
171
+ orgId = "",
172
+ siteId = "",
173
+ siteName = "",
174
+ // serviceProviderOrgId = "",
175
+ // org = "",
176
+ orgName = "",
177
+ category = "",
178
+ } = {}) {
179
+ return useNuxtApp().$api<Record<string, any>>("/api/service-providers", {
180
+ method: "POST",
181
+ body: {
182
+ name,
183
+ type,
184
+ description,
185
+ email,
186
+ orgId,
187
+ siteId,
188
+ siteName,
189
+ // serviceProviderOrgId,
190
+ // org,
191
+ orgName,
192
+ category,
193
+ },
194
+ });
195
+ }
196
+
197
+ async function addViaInvite(id = "") {
198
+ return useNuxtApp().$api<Record<string, any>>(
199
+ `/api/service-providers/id/${id}`,
200
+ {
201
+ method: "POST",
202
+ }
203
+ );
204
+ }
205
+
206
+ return {
207
+ serviceProviders,
208
+ serviceProvider,
209
+ serviceProviderCategories,
210
+ page,
211
+ pages,
212
+ pageRange,
213
+ getByProviderOrg,
214
+ getServiceProviders,
215
+ getServiceProviderNames,
216
+ getServiceProviderCategories,
217
+ getAll,
218
+ createServiceProviderInvite,
219
+ getByServiceProviderOrgIdType,
220
+ invite,
221
+ add,
222
+ addViaInvite,
223
+ };
224
+ }
@@ -0,0 +1,109 @@
1
+ export default function useSite() {
2
+ const sites = ref<Array<TSite>>([]);
3
+ const page = ref(1);
4
+ const pages = ref(0);
5
+ const pageRange = ref("-- - -- of --");
6
+ const search = ref("");
7
+
8
+ const site = useState(
9
+ "site",
10
+ (): TSite => ({
11
+ _id: "",
12
+ name: "",
13
+ description: "",
14
+ orgId: "",
15
+ blocks: 0,
16
+ customerOrgId: "",
17
+ customerSiteId: "",
18
+ createdAt: "",
19
+ updatedAt: "",
20
+ deletedAt: "",
21
+ })
22
+ );
23
+
24
+ const { currentUser } = useLocalAuth();
25
+
26
+ async function getSites({
27
+ orgId,
28
+ page: requestPage = 1,
29
+ search: searchQuery = "",
30
+ limit = 10,
31
+ sort = "createdAt",
32
+ order = "asc",
33
+ }: {
34
+ orgId?: string;
35
+ page?: number;
36
+ search?: string;
37
+ limit?: number;
38
+ sort?: string;
39
+ order?: string;
40
+ } = {}) {
41
+ try {
42
+ const organizationId = orgId || currentUser.value?.defaultOrg;
43
+
44
+ const response = await useNuxtApp().$api<Record<string, any>>(
45
+ `/api/sites/organization/${organizationId}`,
46
+ {
47
+ method: "GET",
48
+ query: { page: requestPage, search: searchQuery, limit, sort, order },
49
+ }
50
+ );
51
+
52
+ sites.value = response.items;
53
+ page.value = requestPage;
54
+ pages.value = response.pages;
55
+ pageRange.value = response.pageRange;
56
+
57
+ return response;
58
+ } catch (err) {
59
+ console.error(err);
60
+ }
61
+ }
62
+
63
+ function createSite(payload: TSiteCreate) {
64
+ return useNuxtApp().$api<Record<string, any>>(`/api/sites`, {
65
+ method: "POST",
66
+ body: payload,
67
+ });
68
+ }
69
+
70
+ function deleteSite(id: string) {
71
+ return useNuxtApp().$api<Record<string, any>>(`/api/sites/${id}`, {
72
+ method: "DELETE",
73
+ });
74
+ }
75
+
76
+ async function getSiteById(id: string) {
77
+ return useNuxtApp().$api<TSite>(`/api/sites/${id}`, {
78
+ method: "GET",
79
+ });
80
+ }
81
+
82
+ function getAll({
83
+ org = "",
84
+ page = 1,
85
+ search = "",
86
+ limit = 10,
87
+ sort = "createdAt",
88
+ order = "asc",
89
+ } = {}) {
90
+ return useNuxtApp().$api<Record<string, any>>("/api/sites", {
91
+ method: "GET",
92
+ query: { page, search, limit, sort, order, org },
93
+ });
94
+ }
95
+
96
+ return {
97
+ sites,
98
+ site,
99
+ page,
100
+ pages,
101
+ pageRange,
102
+ search,
103
+ getSites,
104
+ createSite,
105
+ deleteSite,
106
+ getSiteById,
107
+ getAll,
108
+ };
109
+ }
@@ -0,0 +1,46 @@
1
+ export default function useSiteEntryPassSettings() {
2
+ function getBySiteId(siteId: string) {
3
+ return useNuxtApp().$api<Record<string, any>>(
4
+ `/api/site-entrypass-settings/site/${siteId}`,
5
+ {
6
+ method: "GET",
7
+ }
8
+ );
9
+ }
10
+
11
+ function getById(id: string) {
12
+ return useNuxtApp().$api<Record<string, any>>(
13
+ `/api/site-entrypass-settings/${id}`,
14
+ {
15
+ method: "GET",
16
+ }
17
+ );
18
+ }
19
+
20
+ function add(value: any) {
21
+ return useNuxtApp().$api<Record<string, any>>(
22
+ "/api/site-entrypass-settings",
23
+ {
24
+ method: "POST",
25
+ body: value,
26
+ }
27
+ );
28
+ }
29
+
30
+ function updateBySiteId(value: any, siteId: string) {
31
+ return useNuxtApp().$api<Record<string, any>>(
32
+ "/api/site-entrypass-settings/site/" + siteId,
33
+ {
34
+ method: "PUT",
35
+ body: value,
36
+ }
37
+ );
38
+ }
39
+
40
+ return {
41
+ getBySiteId,
42
+ getById,
43
+ add,
44
+ updateBySiteId,
45
+ };
46
+ }
@@ -0,0 +1,123 @@
1
+ export default function () {
2
+ async function getSiteById(siteId: string) {
3
+ return await useNuxtApp().$api<Record<string, any>>(
4
+ `/api/sites/${siteId}`,
5
+ {
6
+ method: "GET",
7
+ }
8
+ );
9
+ }
10
+
11
+ async function getSiteLevels(siteId: string, query: { block: number }) {
12
+ return await useNuxtApp().$api<Record<string, any>>(
13
+ `/api/buildings/site/${siteId}`,
14
+ {
15
+ method: "GET",
16
+ query: query,
17
+ }
18
+ );
19
+ }
20
+
21
+ async function getSiteUnits(siteId: string, block: number, level: string) {
22
+ return await useNuxtApp().$api<Record<string, any>>(
23
+ `/api/building-units/site/${siteId}/block/${block}/level/${level}`,
24
+ {
25
+ method: "GET",
26
+ }
27
+ );
28
+ }
29
+
30
+ async function updateSite(siteId: string, payload: { block: number }) {
31
+ return await useNuxtApp().$api<Record<string, any>>(
32
+ `/api/sites/${siteId}/block`,
33
+ {
34
+ method: "PUT",
35
+ body: payload,
36
+ }
37
+ );
38
+ }
39
+ async function updateSitebyId(
40
+ siteId: string,
41
+ payload: { field: string; value: number }
42
+ ) {
43
+ return await useNuxtApp().$api<Record<string, any>>(
44
+ `/api/sites/id/${siteId}`,
45
+ {
46
+ method: "PATCH",
47
+ body: payload,
48
+ }
49
+ );
50
+ }
51
+ async function addCamera(camera: TSiteCamera) {
52
+ return await useNuxtApp().$api<Record<string, any>>(`/api/site-cameras`, {
53
+ method: "POST",
54
+ body: camera,
55
+ });
56
+ }
57
+
58
+ async function updateSiteCamera(
59
+ id: string,
60
+ value: Partial<
61
+ Pick<
62
+ TSiteCamera,
63
+ | "host"
64
+ | "category"
65
+ | "guardPost"
66
+ | "password"
67
+ | "username"
68
+ | "direction"
69
+ >
70
+ >
71
+ ) {
72
+ return await useNuxtApp().$api<Record<string, any>>(
73
+ `/api/site-cameras/id/${id}`,
74
+ {
75
+ method: "PATCH",
76
+ body: value,
77
+ }
78
+ );
79
+ }
80
+
81
+ async function deleteSiteCameraById(id: string) {
82
+ return await useNuxtApp().$api<Record<string, any>>(
83
+ `/api/site-cameras/id/${id}`,
84
+ {
85
+ method: "DELETE",
86
+ }
87
+ );
88
+ }
89
+
90
+ async function getAllSiteCameras(payload: {
91
+ site: string;
92
+ type?: string;
93
+ page?: number;
94
+ }) {
95
+ return await useNuxtApp().$api<Record<string, any>>(`/api/site-cameras`, {
96
+ method: "GET",
97
+ query: payload,
98
+ });
99
+ }
100
+
101
+ async function setSiteGuardPosts(siteId: string, value: number) {
102
+ return await useNuxtApp().$api<Record<string, any>>(
103
+ `/api/sites/guard-post/id/${siteId}`,
104
+ {
105
+ method: "PATCH",
106
+ body: { guardPost: value },
107
+ }
108
+ );
109
+ }
110
+
111
+ return {
112
+ getSiteById,
113
+ getSiteLevels,
114
+ getSiteUnits,
115
+ updateSite,
116
+ addCamera,
117
+ getAllSiteCameras,
118
+ setSiteGuardPosts,
119
+ updateSiteCamera,
120
+ deleteSiteCameraById,
121
+ updateSitebyId,
122
+ };
123
+ }