@iservice365/layer-common 0.2.1 → 1.0.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/CHANGELOG.md +12 -0
- package/components/FeedbackMain.vue +6 -0
- package/components/InputLabel.vue +5 -1
- package/components/Layout/NavigationDrawer.vue +3 -4
- package/composables/useLocalAuth.ts +0 -8
- package/composables/useLocalSetup.ts +1 -4
- package/composables/useOrg.ts +8 -1
- package/composables/useSite.ts +2 -1
- package/composables/useSubscription.ts +1 -0
- package/composables/useUtils.ts +7 -0
- package/middleware/01.auth.ts +2 -2
- package/package.json +1 -4
- package/types/feedback.d.ts +2 -0
- package/types/site.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -173,6 +173,8 @@ const message = ref("");
|
|
|
173
173
|
const messageColor = ref("");
|
|
174
174
|
const messageSnackbar = ref(false);
|
|
175
175
|
|
|
176
|
+
const { getUserFromCookie } = useLocal();
|
|
177
|
+
|
|
176
178
|
const serviceProviders = ref<
|
|
177
179
|
Array<{ title: string; value: string; subtitle: string }>
|
|
178
180
|
>([]);
|
|
@@ -345,6 +347,9 @@ function handleCloseDialog() {
|
|
|
345
347
|
const _feedbackId = ref<string | null>(null);
|
|
346
348
|
|
|
347
349
|
async function _createFeedback(organization: string, site: string) {
|
|
350
|
+
|
|
351
|
+
const userId = getUserFromCookie();
|
|
352
|
+
|
|
348
353
|
const createPayload: TFeedbackCreate = {
|
|
349
354
|
subject: _feedback.value.subject,
|
|
350
355
|
category: _feedback.value.category,
|
|
@@ -356,6 +361,7 @@ async function _createFeedback(organization: string, site: string) {
|
|
|
356
361
|
assignee: _feedback.value.assignee || "",
|
|
357
362
|
organization,
|
|
358
363
|
site,
|
|
364
|
+
...(userId !== null ? {createdBy: userId } : {}),
|
|
359
365
|
};
|
|
360
366
|
|
|
361
367
|
const response = await createFeedback(createPayload);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<span class="text-subtitle-2 font-weight-medium">
|
|
2
|
+
<span :class="`text-subtitle-2 font-weight-medium ${props.class}`">
|
|
3
3
|
{{ title }} <span v-if="props.required" class="text-error">*</span>
|
|
4
4
|
</span>
|
|
5
5
|
</template>
|
|
@@ -14,5 +14,9 @@ const props = defineProps({
|
|
|
14
14
|
type: Boolean,
|
|
15
15
|
default: false,
|
|
16
16
|
},
|
|
17
|
+
class: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "",
|
|
20
|
+
},
|
|
17
21
|
});
|
|
18
22
|
</script>
|
|
@@ -12,19 +12,18 @@
|
|
|
12
12
|
:key="`${navigationItem.title}-${navigationIndex}`"
|
|
13
13
|
>
|
|
14
14
|
<NavigationItem
|
|
15
|
-
v-if="navigationItem.
|
|
15
|
+
v-if="navigationItem.children?.length"
|
|
16
16
|
:title="navigationItem.title"
|
|
17
17
|
:icon="navigationItem.icon"
|
|
18
|
-
:route="navigationItem.route"
|
|
19
18
|
:children="navigationItem.children"
|
|
20
19
|
/>
|
|
21
20
|
|
|
22
21
|
<NavigationItem
|
|
23
|
-
v-else-if="navigationItem.
|
|
22
|
+
v-else-if="navigationItem.route"
|
|
24
23
|
:title="navigationItem.title"
|
|
25
24
|
:icon="navigationItem.icon"
|
|
26
25
|
:link="navigationItem.link"
|
|
27
|
-
:
|
|
26
|
+
:route="navigationItem.route"
|
|
28
27
|
/>
|
|
29
28
|
</template>
|
|
30
29
|
|
|
@@ -4,14 +4,6 @@ export default function useLocalAuth() {
|
|
|
4
4
|
const currentUser = useState<TUser | null>("currentUser", () => null);
|
|
5
5
|
|
|
6
6
|
function authenticate() {
|
|
7
|
-
// Get access token from cookies
|
|
8
|
-
const accessToken = useCookie("accessToken", cookieConfig).value;
|
|
9
|
-
|
|
10
|
-
if (!accessToken) {
|
|
11
|
-
// Redirect to login page if no access token
|
|
12
|
-
navigateTo({ name: "index" });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
7
|
const user = useCookie("user", cookieConfig).value;
|
|
16
8
|
|
|
17
9
|
const { data: getCurrentUserReq, error: getCurrentUserErr } =
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export function useLocalSetup() {
|
|
2
|
-
const userAppRole = useState<
|
|
3
|
-
"userAppRole",
|
|
4
|
-
() => null
|
|
5
|
-
);
|
|
2
|
+
const userAppRole = useState<TRole | null>("userAppRole", () => null);
|
|
6
3
|
|
|
7
4
|
const id = useState<string | null>("memberShipOrgId", () => null);
|
|
8
5
|
|
package/composables/useOrg.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export default function useOrg() {
|
|
2
|
-
function getOrgs({
|
|
2
|
+
function getOrgs({
|
|
3
|
+
page = 1,
|
|
4
|
+
search = "",
|
|
5
|
+
user = "",
|
|
6
|
+
limit = 20,
|
|
7
|
+
type = "organization",
|
|
8
|
+
} = {}) {
|
|
3
9
|
return useNuxtApp().$api<Record<string, any>>(
|
|
4
10
|
`/api/organizations/user/${user}`,
|
|
5
11
|
{
|
|
@@ -8,6 +14,7 @@ export default function useOrg() {
|
|
|
8
14
|
page,
|
|
9
15
|
search,
|
|
10
16
|
limit,
|
|
17
|
+
type,
|
|
11
18
|
},
|
|
12
19
|
}
|
|
13
20
|
);
|
package/composables/useSite.ts
CHANGED
|
@@ -12,6 +12,7 @@ export default function useSite() {
|
|
|
12
12
|
name: "",
|
|
13
13
|
description: "",
|
|
14
14
|
orgId: "",
|
|
15
|
+
blocks: 0,
|
|
15
16
|
customerOrgId: "",
|
|
16
17
|
customerSiteId: "",
|
|
17
18
|
createdAt: "",
|
|
@@ -73,7 +74,7 @@ export default function useSite() {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
async function getSiteById(id: string) {
|
|
76
|
-
return useNuxtApp().$api<
|
|
77
|
+
return useNuxtApp().$api<TSite>(`/api/sites/${id}`, {
|
|
77
78
|
method: "GET",
|
|
78
79
|
});
|
|
79
80
|
}
|
package/composables/useUtils.ts
CHANGED
|
@@ -295,6 +295,12 @@ export default function useUtils() {
|
|
|
295
295
|
return params;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
+
function toOrdinal(n: number): string {
|
|
299
|
+
const s = ["th", "st", "nd", "rd"];
|
|
300
|
+
const v = n % 100;
|
|
301
|
+
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
|
302
|
+
}
|
|
303
|
+
|
|
298
304
|
return {
|
|
299
305
|
requiredRule,
|
|
300
306
|
emailRule,
|
|
@@ -324,5 +330,6 @@ export default function useUtils() {
|
|
|
324
330
|
formatNature,
|
|
325
331
|
replaceMatch,
|
|
326
332
|
setRouteParams,
|
|
333
|
+
toOrdinal,
|
|
327
334
|
};
|
|
328
335
|
}
|
package/middleware/01.auth.ts
CHANGED
|
@@ -2,9 +2,9 @@ export default defineNuxtRouteMiddleware(async () => {
|
|
|
2
2
|
const { cookieConfig } = useRuntimeConfig().public;
|
|
3
3
|
|
|
4
4
|
// Get access token from cookies
|
|
5
|
-
const
|
|
5
|
+
const sid = useCookie("sid", cookieConfig).value;
|
|
6
6
|
|
|
7
|
-
if (!
|
|
7
|
+
if (!sid) {
|
|
8
8
|
// Redirect to login page if no access token
|
|
9
9
|
return navigateTo({ name: "index" });
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
"name": "@iservice365/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "1.0.0",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
7
|
"scripts": {
|
|
11
8
|
"dev": "nuxi dev .playground",
|
|
12
9
|
"dev:prepare": "nuxt prepare .playground",
|
package/types/feedback.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare type TFeedback = {
|
|
|
18
18
|
highPriority?: boolean;
|
|
19
19
|
serviceProvider?: string;
|
|
20
20
|
assignee?: string;
|
|
21
|
+
createdBy?: string;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
declare type TFeedbackMetadata = {
|
|
@@ -43,6 +44,7 @@ declare type TFeedbackCreate = Pick<
|
|
|
43
44
|
| "assignee"
|
|
44
45
|
| "organization"
|
|
45
46
|
| "site"
|
|
47
|
+
| "createdBy"
|
|
46
48
|
>;
|
|
47
49
|
|
|
48
50
|
declare type TFeedbackUpdate = Pick<
|