feat: share badge on linkedin
This commit is contained in:
@@ -61,7 +61,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import LMSLogo from '@/components/Icons/LMSLogo.vue'
|
import LMSLogo from '@/components/Icons/LMSLogo.vue'
|
||||||
import { sessionStore } from '@/stores/session'
|
import { sessionStore } from '@/stores/session'
|
||||||
import { Dropdown, createResource } from 'frappe-ui'
|
import { Dropdown } from 'frappe-ui'
|
||||||
import {
|
import {
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
LogIn,
|
LogIn,
|
||||||
@@ -71,11 +71,10 @@ import {
|
|||||||
} from 'lucide-vue-next'
|
} from 'lucide-vue-next'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { convertToTitleCase } from '../utils'
|
import { convertToTitleCase } from '../utils'
|
||||||
import { onMounted, inject } from 'vue'
|
|
||||||
import { usersStore } from '@/stores/user'
|
import { usersStore } from '@/stores/user'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { logout } = sessionStore()
|
const { logout, branding } = sessionStore()
|
||||||
let { userResource } = usersStore()
|
let { userResource } = usersStore()
|
||||||
let { isLoggedIn } = sessionStore()
|
let { isLoggedIn } = sessionStore()
|
||||||
|
|
||||||
@@ -86,15 +85,6 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const branding = createResource({
|
|
||||||
url: 'lms.lms.api.get_branding',
|
|
||||||
cache: true,
|
|
||||||
auto: true,
|
|
||||||
onSuccess(data) {
|
|
||||||
document.querySelector("link[rel='icon']").href = data.favicon
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const userDropdownOptions = [
|
const userDropdownOptions = [
|
||||||
{
|
{
|
||||||
icon: User,
|
icon: User,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</h2>
|
</h2>
|
||||||
<div class="grid grid-cols-5 gap-4">
|
<div class="grid grid-cols-5 gap-4">
|
||||||
<div v-if="badges.data" v-for="badge in badges.data">
|
<div v-if="badges.data" v-for="badge in badges.data">
|
||||||
<Popover trigger="hover">
|
<Popover trigger="hover" leaveDelay="0.01">
|
||||||
<template #target>
|
<template #target>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<img
|
<img
|
||||||
@@ -51,12 +51,26 @@
|
|||||||
<div class="leading-5 mb-4">
|
<div class="leading-5 mb-4">
|
||||||
{{ badge.badge_description }}
|
{{ badge.badge_description }}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col mb-4">
|
||||||
<span class="text-xs text-gray-700 font-medium mb-1">
|
<span class="text-xs text-gray-700 font-medium mb-1">
|
||||||
{{ __('Issued on') }}:
|
{{ __('Issued on') }}:
|
||||||
</span>
|
</span>
|
||||||
{{ dayjs(badge.issued_on).format('DD MMM YYYY') }}
|
{{ dayjs(badge.issued_on).format('DD MMM YYYY') }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<span class="text-xs text-gray-700 font-medium mb-1">
|
||||||
|
{{ __('Share on') }}:
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
@click="shareOnLinkedIn(badge)"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<LinkedinIcon class="h-3 w-3 stroke-1.5" />
|
||||||
|
</template>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -67,10 +81,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { inject } from 'vue'
|
import { inject } from 'vue'
|
||||||
import { createResource, Popover } from 'frappe-ui'
|
import { createResource, Popover, Button } from 'frappe-ui'
|
||||||
import { X } from 'lucide-vue-next'
|
import { X, LinkedinIcon } from 'lucide-vue-next'
|
||||||
|
import { sessionStore } from '@/stores/session'
|
||||||
|
|
||||||
const dayjs = inject('$dayjs')
|
const dayjs = inject('$dayjs')
|
||||||
|
const { branding } = sessionStore()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
profile: {
|
profile: {
|
||||||
@@ -100,4 +116,17 @@ const badges = createResource({
|
|||||||
return finalBadges
|
return finalBadges
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const shareOnLinkedIn = (badge) => {
|
||||||
|
const url = encodeURIComponent(window.location.href)
|
||||||
|
const image = url.split('/lms')[0] + badge.badge_image
|
||||||
|
console.log(image)
|
||||||
|
const summary = `I am happy to announce that I earned the ${
|
||||||
|
badge.badge
|
||||||
|
} badge on ${dayjs(badge.issued_on).format('DD MMM YYYY')} at ${
|
||||||
|
branding.data?.brand_name
|
||||||
|
}. Here's the badge I earned: ${image}`
|
||||||
|
const shareUrl = `https://www.linkedin.com/shareArticle/?url=${url}&text=${summary}&submitted-image-url=${badge.badge_image}`
|
||||||
|
window.open(shareUrl, '_blank')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -41,10 +41,20 @@ export const sessionStore = defineStore('lms-session', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const branding = createResource({
|
||||||
|
url: 'lms.lms.api.get_branding',
|
||||||
|
cache: 'brand',
|
||||||
|
auto: true,
|
||||||
|
onSuccess(data) {
|
||||||
|
document.querySelector("link[rel='icon']").href = data.favicon
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user,
|
user,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
login,
|
login,
|
||||||
logout,
|
logout,
|
||||||
|
branding,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user