@icvdeveloper/common-module 0.0.46 → 0.0.48

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
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "v3plus-common-module",
3
3
  "configKey": "v3plusCommonModule",
4
- "version": "0.0.46"
4
+ "version": "0.0.48"
5
5
  }
@@ -98,3 +98,6 @@ export type presenterModalClassObj = {
98
98
  iconContainer?: string | null;
99
99
  components?: presenterModalCompObj;
100
100
  };
101
+ export type uccClassObj = {
102
+ container?: string | null;
103
+ };
@@ -0,0 +1,52 @@
1
+ <script lang="ts" setup>
2
+ import { toRefs, onMounted } from "vue";
3
+ import { useUcc } from "../../composables/useUcc";
4
+ import { useConferencesStore } from "../../store/conferences";
5
+ import { uccClassObj } from "../../@types/components";
6
+ import { useClassBinding } from "../../composables/useClassBinding";
7
+
8
+ const { loadUccScript } = useUcc();
9
+
10
+ interface Props {
11
+ eventId?: number | null;
12
+ classObject?: uccClassObj;
13
+ }
14
+
15
+ const props = withDefaults(defineProps<Props>(), {
16
+ eventId: () => useConferencesStore().currentConference.id,
17
+ classObject: () => {
18
+ return {
19
+ container: ""
20
+ };
21
+ },
22
+ });
23
+
24
+ const {
25
+ classObject,
26
+ } = toRefs(props);
27
+
28
+ const conferenceStore = useConferencesStore();
29
+ const { classBinding } = useClassBinding();
30
+
31
+ // reactive data
32
+ const { eventId } = toRefs(props);
33
+
34
+ // on mount
35
+ onMounted(() => {
36
+ loadUccScript(props.eventId);
37
+ });
38
+
39
+ </script>
40
+
41
+ <template>
42
+ <div
43
+ id="uccTarget"
44
+ :class="
45
+ classBinding(
46
+ classObject,
47
+ 'container',
48
+ 'p-0 m-0 w-full'
49
+ )
50
+ "
51
+ />
52
+ </template>
@@ -8,4 +8,5 @@ export * from "./useLogin";
8
8
  export * from "./usePresentation";
9
9
  export * from "./usePresenter";
10
10
  export * from "./usePresenters";
11
+ export * from "./useUcc";
11
12
  export * from "./useV3plusCommonModule";
@@ -8,4 +8,5 @@ export * from "./useLogin.mjs";
8
8
  export * from "./usePresentation.mjs";
9
9
  export * from "./usePresenter.mjs";
10
10
  export * from "./usePresenters.mjs";
11
+ export * from "./useUcc.mjs";
11
12
  export * from "./useV3plusCommonModule.mjs";
@@ -1,4 +1,4 @@
1
1
  export type UseClassBindingMethods = {
2
- classBinding(_classObject: {}, _element: string, _defaults: string): string;
2
+ classBinding(_classObject: {} | undefined, _element: string, _defaults: string): string;
3
3
  };
4
4
  export declare const useClassBinding: () => UseClassBindingMethods;
@@ -1,7 +1,7 @@
1
1
  export const useClassBinding = () => {
2
2
  const classBinding = (_classObject, _element, _defaults) => {
3
3
  const key = _element;
4
- if (_classObject[`${key}`] === void 0 || !_classObject[`${key}`].length) {
4
+ if (_classObject === void 0 || _classObject[`${key}`] === void 0 || !_classObject[`${key}`].length) {
5
5
  return _defaults;
6
6
  }
7
7
  return _classObject[`${key}`];
@@ -3,10 +3,10 @@ export type DateFunctions = {
3
3
  * Takes a date string and converts it to a formatted date
4
4
  * e.g August 8, 2022
5
5
  */
6
- formatDate: (date: string) => string;
6
+ formatDate: (date: string, dateFormat?: string) => string;
7
7
  /**
8
8
  * Takes a date string with its timezone and converts it to the users local time.
9
9
  */
10
- formatTimezoneToLocal: (date: string | Date, format: string, timezone: string) => string;
10
+ formatTimezoneToLocal: (date: string | Date, dateFormat: string, timezone: string) => string;
11
11
  };
12
12
  export declare const useDateFormat: () => DateFunctions;
@@ -1,17 +1,17 @@
1
1
  import { format as formatTz } from "date-fns-tz";
2
2
  import { format, parseISO } from "date-fns";
3
3
  export const useDateFormat = () => {
4
- const formatDate = (date) => {
5
- return format(new Date(parseISO(date)), "MMMM do, Y");
4
+ const formatDate = (date, dateFormat = "MMMM do, Y") => {
5
+ return format(new Date(parseISO(date)), dateFormat);
6
6
  };
7
- const formatTimezoneToLocal = (date, format2, timezone) => {
7
+ const formatTimezoneToLocal = (date, dateFormat, timezone) => {
8
8
  return formatTz(
9
9
  new Date(
10
10
  formatTz(parseISO(date), "yyyy-MM-dd HH:mm z", {
11
11
  timeZone: timezone
12
12
  })
13
13
  ),
14
- format2
14
+ dateFormat
15
15
  );
16
16
  };
17
17
  return {
@@ -0,0 +1,11 @@
1
+ export type UccFunctions = {
2
+ /**
3
+ * load UCC script
4
+ */
5
+ loadUccScript: (eventId: number) => void;
6
+ /**
7
+ * show UCC Event Sign Up
8
+ */
9
+ uccShowEventSignUp: (eventId: number) => void;
10
+ };
11
+ export declare const useUcc: () => UccFunctions;
@@ -0,0 +1,66 @@
1
+ import { get } from "lodash-es";
2
+ export const useUcc = () => {
3
+ const loadUccScript = (eventId) => {
4
+ window.uccMixin = {};
5
+ window.uccMixin.eventId = eventId;
6
+ window.uccMixin.uccShowEventSignUp = uccShowEventSignUp;
7
+ let ucc = document.createElement("script");
8
+ ucc.setAttribute("src", "https://cssjs.nejm-qa.org/mmsWidgets.js");
9
+ ucc.onload = () => {
10
+ mmsWidgets.init({
11
+ clientId: "6gw22dzjxwmgj6kekxkgwdshvyrx2uuz",
12
+ // Akamai client id
13
+ origin: "NEJMGroupEvents",
14
+ debug: true,
15
+ // set this false for production
16
+ onReady: function() {
17
+ console.log("UCC ready");
18
+ },
19
+ onLoginSuccess: function(ssoEvent) {
20
+ console.log("UCC login success");
21
+ },
22
+ onAuthStateReady: function(ssoEvent) {
23
+ console.log("UCC auth state ready");
24
+ if (window.uccMixin.eventId) {
25
+ window.uccMixin.uccShowEventSignUp(window.uccMixin.eventId);
26
+ }
27
+ },
28
+ onRegistrationSuccess: function(ssoEvent) {
29
+ console.log("UCC reg success");
30
+ },
31
+ onLogoutSuccess: function(ssoEvent) {
32
+ console.log("UCC logout success");
33
+ }
34
+ });
35
+ };
36
+ document.head.appendChild(ucc);
37
+ };
38
+ const uccShowEventSignUp = (eventId) => {
39
+ return new Promise((resolve, reject) => {
40
+ const request = useApi();
41
+ request(
42
+ `conferences/${eventId}?with=custom1`
43
+ ).then((response) => {
44
+ let brandCode = get(response.data, "custom1[0].code");
45
+ if (brandCode) {
46
+ let mmsResponse = window.mmsWidgets.showEventsSignUp(
47
+ "#uccTarget",
48
+ `${eventId}`,
49
+ null,
50
+ { productCode: `${brandCode}` }
51
+ );
52
+ } else {
53
+ throw new Error("Missing required parameter");
54
+ }
55
+ resolve(brandCode);
56
+ }).catch((error) => {
57
+ document.getElementById("uccTarget").innerHTML = `<div class='border font-bold px-4 py-3 mb-4 rounded relative message-base bg-red-100 border-red-400 text-red-600'>${error}</div>`;
58
+ reject(error);
59
+ });
60
+ });
61
+ };
62
+ return {
63
+ loadUccScript,
64
+ uccShowEventSignUp
65
+ };
66
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icvdeveloper/common-module",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {