@icvdeveloper/common-module 0.0.21 → 0.0.23

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/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.0.21"
7
+ "version": "0.0.23"
8
8
  }
package/dist/module.mjs CHANGED
@@ -162,7 +162,6 @@ const module = defineNuxtModule({
162
162
  if (piniaRuntime) {
163
163
  nuxt2.plugins.splice(index, 1);
164
164
  nuxt2.plugins.unshift(piniaRuntime);
165
- console.log(nuxt2.plugins);
166
165
  } else {
167
166
  console.warn("[V3plus Common Module]: Could not find Pinia");
168
167
  }
@@ -0,0 +1,13 @@
1
+ import { NavigationConfig } from "../models/navigationConfig";
2
+ interface UseNavigationMethods {
3
+ /**
4
+ * Checks if a given nav item is external.
5
+ */
6
+ isExternalLink: (navItem: NavigationConfig) => boolean;
7
+ /**
8
+ * generates a href link.
9
+ */
10
+ formatLink: (navItem: NavigationConfig) => string;
11
+ }
12
+ export declare const useNavigation: () => UseNavigationMethods;
13
+ export {};
@@ -0,0 +1,31 @@
1
+ import { storeToRefs } from "pinia";
2
+ import { useConferencesStore } from "../store/index.mjs";
3
+ import { useConferenceHelpers } from "./useConferenceHelpers.mjs";
4
+ export const useNavigation = () => {
5
+ const { currentConference } = storeToRefs(useConferencesStore());
6
+ const { getConferenceWebcastUrl } = useConferenceHelpers(currentConference);
7
+ const isExternalLink = (navItem) => {
8
+ const url = formatLink(navItem);
9
+ return url.startsWith("http") === true;
10
+ };
11
+ const formatLink = (navItem) => {
12
+ let link = "/" + navItem.name;
13
+ if (navItem.name === "home") {
14
+ link = "/";
15
+ }
16
+ if (navItem.type === "custom-page") {
17
+ link = "/page/" + navItem.slug;
18
+ }
19
+ if (navItem.type === "link") {
20
+ link = navItem.url;
21
+ }
22
+ if (navItem.name === "webcast") {
23
+ link = getConferenceWebcastUrl();
24
+ }
25
+ return link;
26
+ };
27
+ return {
28
+ isExternalLink,
29
+ formatLink
30
+ };
31
+ };
@@ -0,0 +1,5 @@
1
+ interface UseRouteHelpersMethods {
2
+ isResetPasswordPage: () => boolean;
3
+ }
4
+ export declare const useRouteHelpers: () => UseRouteHelpersMethods;
5
+ export {};
@@ -0,0 +1,10 @@
1
+ import { useRoute } from "vue-router";
2
+ export const useRouteHelpers = () => {
3
+ const route = useRoute();
4
+ const isResetPasswordPage = () => {
5
+ return route.name === "login-reset-token";
6
+ };
7
+ return {
8
+ isResetPasswordPage
9
+ };
10
+ };
@@ -5,4 +5,5 @@ export declare type NavigationConfig = {
5
5
  order?: number;
6
6
  slug?: string;
7
7
  type?: string;
8
+ url?: string;
8
9
  };
@@ -1,7 +1,9 @@
1
1
  import { NavigationConfig } from "../models/navigationConfig";
2
2
  export interface NavigationConfigState {
3
- data: null | NavigationConfig;
3
+ data: NavigationConfig[];
4
4
  }
5
- export declare const useNavigationConfigStore: import("pinia").StoreDefinition<"navigationConfig", NavigationConfigState, {}, {
5
+ export declare const useNavigationConfigStore: import("pinia").StoreDefinition<"navigationConfig", NavigationConfigState, {
6
+ getEnabled: (state: NavigationConfigState) => (sorted?: boolean) => any;
7
+ }, {
6
8
  setNavigationConfig(payload: any): Promise<NavigationConfigState>;
7
9
  }>;
@@ -1,8 +1,20 @@
1
1
  import { defineStore } from "pinia";
2
+ import { filter, sortBy } from "lodash-es";
2
3
  export const useNavigationConfigStore = defineStore("navigationConfig", {
3
4
  state: () => ({
4
- data: null
5
+ data: []
5
6
  }),
7
+ getters: {
8
+ getEnabled: (state) => {
9
+ return (sorted = true) => {
10
+ const filtered = filter(state.data, { enabled: true });
11
+ if (sorted) {
12
+ return sortBy(filtered, ["order"]);
13
+ }
14
+ return filtered;
15
+ };
16
+ }
17
+ },
6
18
  actions: {
7
19
  setNavigationConfig(payload) {
8
20
  return new Promise((resolve) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icvdeveloper/common-module",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {