@icvdeveloper/common-module 0.0.45 → 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 +1 -1
- package/dist/runtime/@types/components.d.ts +3 -0
- package/dist/runtime/components/auth/Ucc.vue +52 -0
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.mjs +1 -0
- package/dist/runtime/composables/useClassBinding.d.ts +1 -1
- package/dist/runtime/composables/useClassBinding.mjs +1 -1
- package/dist/runtime/composables/useDateFormat.d.ts +2 -2
- package/dist/runtime/composables/useDateFormat.mjs +4 -4
- package/dist/runtime/composables/useUcc.d.ts +11 -0
- package/dist/runtime/composables/useUcc.mjs +66 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -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>
|
|
@@ -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,
|
|
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)),
|
|
4
|
+
const formatDate = (date, dateFormat = "MMMM do, Y") => {
|
|
5
|
+
return format(new Date(parseISO(date)), dateFormat);
|
|
6
6
|
};
|
|
7
|
-
const formatTimezoneToLocal = (date,
|
|
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
|
-
|
|
14
|
+
dateFormat
|
|
15
15
|
);
|
|
16
16
|
};
|
|
17
17
|
return {
|
|
@@ -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
|
+
};
|