Skip to content

Commit

Permalink
🔨 Type external connections store
Browse files Browse the repository at this point in the history
  • Loading branch information
devmount committed Jun 21, 2024
1 parent 9a220e5 commit f00cc62
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend/src/appointment/routes/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_external_connections(subscriber: Subscriber = Depends(get_subscriber)):
external_connections = defaultdict(list)

if os.getenv('ZOOM_API_ENABLED'):
external_connections['Zoom'] = []
external_connections['zoom'] = []

for ec in subscriber.external_connections:
external_connections[ec.type.name].append(
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,16 @@ export type Calendar = {
title: string;
color: string;
};

export type ExternalConnection = {
owner_id: number;
name: string;
type: string;
type_id: string;
};

export type ExternalConnectionCollection = {
fxa?: ExternalConnection[];
google?: ExternalConnection[];
zoom?: ExternalConnection[];
};
2 changes: 1 addition & 1 deletion frontend/src/stores/calendar-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useCalendarStore = defineStore('calendars', () => {

/**
* Get all calendars for current user
* @param {function} call preconfigured API fetch function
* @param call preconfigured API fetch function
*/
const fetch = async (call: (url: string) => UseFetchReturn<Calendar[]> & PromiseLike<UseFetchReturn<Calendar[]>>) => {
if (isLoaded.value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ExternalConnection, ExternalConnectionCollection } from '@/models';
import { UseFetchReturn } from '@vueuse/core';
import { defineStore } from 'pinia';
import { ref, computed } from 'vue';

Expand All @@ -7,10 +9,10 @@ export const useExternalConnectionsStore = defineStore('externalConnections', ()
const isLoaded = ref(false);

// Data
const zoom = ref([]);
const fxa = ref([]);
const google = ref([]);
const connections = computed(() => ({
const zoom = ref<ExternalConnection[]>([]);
const fxa = ref<ExternalConnection[]>([]);
const google = ref<ExternalConnection[]>([]);
const connections = computed((): ExternalConnectionCollection => ({
// FXA should be at the top since it represents the Appointment subscriber.
fxa: fxa.value,
google: google.value,
Expand All @@ -19,9 +21,9 @@ export const useExternalConnectionsStore = defineStore('externalConnections', ()

/**
* Get all external connections for current user
* @param {function} call preconfigured API fetch function
* @param call preconfigured API fetch function
*/
const fetch = async (call) => {
const fetch = async (call: (url: string) => UseFetchReturn<ExternalConnectionCollection[]> & PromiseLike<UseFetchReturn<ExternalConnectionCollection[]>>) => {
if (isLoaded.value) {
return;
}
Expand Down

0 comments on commit f00cc62

Please sign in to comment.