Skip to content

Commit 12530c3

Browse files
Merge pull request #164 from dev-protocol/feat/calendar
Feat/calendar
2 parents af3d49a + db83f07 commit 12530c3

4 files changed

Lines changed: 67 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devprotocol/huddle01-clubs-plugin",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"type": "module",
55
"description": "Repository for using Clubs-Huddle01 Plugin",
66
"main": "dist/index.js",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<script setup lang="ts">
2+
import { computed } from 'vue'
3+
import { toCompactISOTimeFromISO } from '../../fixtures'
4+
5+
const props = defineProps<{
6+
redirectToUrl: (calendarLink: string | undefined) => void
7+
meetingLink: string | undefined
8+
roomType: string
9+
startTime: string | undefined
10+
expiryTime: string | undefined
11+
description: string | undefined
12+
}>()
13+
14+
const compactStartTime = computed(() => {
15+
return toCompactISOTimeFromISO(props.startTime as string)
16+
})
17+
const compactExpiryTime = computed(() => {
18+
return toCompactISOTimeFromISO(props.expiryTime as string)
19+
})
20+
21+
const timeZone = new Intl.DateTimeFormat('en-US', {
22+
timeZoneName: 'short',
23+
}).resolvedOptions().timeZone
24+
25+
console.log('starttime', props.startTime)
26+
const calendarLink = computed(() => {
27+
return `https://calendar.google.com/calendar/r/eventedit?action=TEMPLATE&dates=${compactStartTime.value}%2F${compactExpiryTime.value}&text=${encodeURIComponent(props.description ? props.description : '')}&details=${encodeURIComponent(props.description ? props.description : '')}&location=${encodeURIComponent(props.meetingLink ? props.meetingLink : '')}&stz=${timeZone}&etz=${timeZone}`
28+
})
29+
</script>
30+
<template>
31+
<button
32+
class="is-fullwidth w-full gap-4 font-bold border border-black rounded-full text-black hover:bg-[#D9D9D9]"
33+
@click="
34+
() => {
35+
redirectToUrl(calendarLink)
36+
}
37+
"
38+
>
39+
Add to Calendar 🗓️
40+
</button>
41+
</template>

src/components/feed-after-post-content.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { ref, onMounted, computed } from 'vue'
33
import { currentPost } from '@devprotocol/clubs-plugin-posts/plugin-helper'
44
import Join from './Meeting/Join.vue'
5+
import AddToCal from './Meeting/AddToCal.vue'
56
import type { Posts } from '@devprotocol/clubs-plugin-posts'
67
import type { Meet } from '../types.ts'
78
import { connection } from '@devprotocol/clubs-core/connection'
@@ -51,6 +52,15 @@ const redirectToUrl = (url: string | undefined) => {
5152
:roomType="currentMeet.roomType"
5253
:startTime="currentMeet.startTime"
5354
:expiryTime="currentMeet.expiryTime"
55+
class="mb-4"
56+
/>
57+
<AddToCal
58+
:redirectToUrl="redirectToUrl"
59+
:meetingLink="currentMeet.meetingLink"
60+
:roomType="currentMeet.roomType"
61+
:startTime="currentMeet.startTime"
62+
:expiryTime="currentMeet.expiryTime"
63+
:description="currentMeet.description"
5464
/>
5565
</section>
5666
</div>

src/fixtures/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ export const formatISOTimestamp = (isoTimestamp: string) => {
2929
return `${hours}:${minutes} ${amPm} (${day}:${month}:${year}) ${timeZone}`
3030
}
3131

32+
export const toCompactISOTimeFromISO = (isoTimestamp: string) => {
33+
const date = new Date(isoTimestamp)
34+
const pad = (number: number) => number.toString().padStart(2, '0')
35+
36+
// Extract components
37+
const year = date.getUTCFullYear()
38+
const month = pad(date.getUTCMonth() + 1) // Months are zero-indexed
39+
const day = pad(date.getUTCDate())
40+
const hours = pad(date.getUTCHours())
41+
const minutes = pad(date.getUTCMinutes())
42+
const seconds = pad(date.getUTCSeconds())
43+
44+
return `${year}${month}${day}T${hours}${minutes}${seconds}Z`
45+
}
46+
3247
export const isFutureTimestamp = (isoTimestamp: string) => {
3348
if (isoTimestamp === undefined) {
3449
return true

0 commit comments

Comments
 (0)