-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
246 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<script setup lang="ts"> | ||
import { f7Card, f7CardContent, f7CardFooter, f7CardHeader, f7SkeletonBlock } from 'framework7-vue' | ||
import type { User } from '~/shared/types' | ||
const { data: user, isLoading: userIsLoading } = useUser() | ||
const membershipGradient: Record<Exclude<User['memberType'], null>, string> = { | ||
associate: 'bg-gradient-to-br from-blue-500 to-blue-600', | ||
affiliate: 'bg-gradient-to-br from-purple-500 to-purple-600', | ||
exco: 'bg-gradient-to-br from-red-500 to-red-600', | ||
ordinary: 'bg-gradient-to-br from-yellow-500 to-yellow-600', | ||
revoked: 'bg-gradient-to-br from-gray-500 to-gray-600', | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div v-if="userIsLoading" class="h-55"> | ||
<f7SkeletonBlock class="rounded-md" effect="fade" height="100%" /> | ||
</div> | ||
|
||
<f7Card v-else-if="user" class="m-0!"> | ||
<f7CardHeader class="h-45 rounded-[16px]!" valign="top" :class="membershipGradient[user.memberType!]"> | ||
<div class="flex flex-col w-full h-full"> | ||
<div class="flex flex-col flex-1"> | ||
<span class="font-bold text-3xl"> | ||
{{ user.name }} | ||
</span> | ||
<span class="font-mono text-base"> | ||
{{ user.memberId }} | ||
</span> | ||
</div> | ||
<div class="flex flex-col text-base"> | ||
<span class="font-semibold"> | ||
Class of {{ user.graduationYear }} | ||
</span> | ||
<span class="text-sm"> | ||
{{ user.memberType?.[0].toLocaleUpperCase() }}{{ user.memberType?.slice(1, user.memberType?.length) }} | ||
member | ||
</span> | ||
</div> | ||
</div> | ||
</f7CardHeader> | ||
<f7CardFooter> | ||
<span> | ||
<strong>Coming back?</strong> | ||
<br> | ||
<span>Tap on this card and present it to the security at the front gate.</span> | ||
</span> | ||
</f7CardFooter> | ||
</f7Card> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
import { useQuery } from '@tanstack/vue-query' | ||
import type { User } from '~/shared/types' | ||
|
||
const queryKeyFactory = { | ||
user: ['user'], | ||
} | ||
|
||
export function useUser() { | ||
const auth = useCurrentUser() | ||
return useApiFetch<User>(() => `/api/user/${auth.value?.uid}`, { immediate: false, watch: [() => auth.value?.uid] }) | ||
const firebaseCurrentUser = useCurrentUser() | ||
return useQuery({ | ||
queryKey: queryKeyFactory.user, | ||
queryFn: () => $api<User>(`/api/user/${firebaseCurrentUser.value?.uid}`), | ||
enabled: computed(() => !!firebaseCurrentUser.value), // Only run when user exists | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { VueQueryPlugin, type VueQueryPluginOptions } from '@tanstack/vue-query' | ||
import { persistQueryClient } from '@tanstack/query-persist-client-core' | ||
import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister' | ||
|
||
export default defineNuxtPlugin((nuxtApp) => { | ||
const vueQueryOptions: VueQueryPluginOptions = { | ||
queryClientConfig: { | ||
defaultOptions: { | ||
queries: { | ||
cacheTime: 1000 * 60 * 60 * 24, | ||
staleTime: 1000 * 60 * 60 * 24, | ||
}, | ||
}, | ||
}, | ||
clientPersister: (queryClient) => { | ||
return persistQueryClient({ | ||
queryClient, | ||
persister: createSyncStoragePersister({ storage: localStorage }), | ||
}) | ||
}, | ||
} | ||
|
||
nuxtApp.vueApp.use(VueQueryPlugin, vueQueryOptions) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.