Skip to content

Commit b324dc8

Browse files
committed
fix: hide unit page if not in a unit
1 parent 4dfa3df commit b324dc8

File tree

4 files changed

+62
-7
lines changed

4 files changed

+62
-7
lines changed

frontend/app/api/generated.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,9 +2542,9 @@ export type ChallengesPageQueryVariables = Exact<{ [key: string]: never; }>;
25422542

25432543

25442544
export type ChallengesPageQuery = { __typename?: 'Query', myCurrentProject: { __typename?: 'Project', challenges: Array<
2545-
| { __typename?: 'ExternalChallenge', id: string, name: string, description: any, image?: string | null, buttonText: string, publishedAt?: any | null, endTime?: any | null, visibleAt?: any | null }
2546-
| { __typename?: 'QuizChallenge', id: string, name: string, description: any, image?: string | null, buttonText: string, publishedAt?: any | null, endTime?: any | null, visibleAt?: any | null }
2547-
| { __typename?: 'SimpleChallenge', id: string, name: string, description: any, image?: string | null, buttonText: string, publishedAt?: any | null, endTime?: any | null, visibleAt?: any | null }
2545+
| { __typename: 'ExternalChallenge', url: string, id: string, name: string, description: any, image?: string | null, buttonText: string, publishedAt?: any | null, endTime?: any | null, visibleAt?: any | null, userCompletedAt?: any | null }
2546+
| { __typename: 'QuizChallenge', id: string, name: string, description: any, image?: string | null, buttonText: string, publishedAt?: any | null, endTime?: any | null, visibleAt?: any | null, userCompletedAt?: any | null }
2547+
| { __typename: 'SimpleChallenge', allowSelfCompletion: boolean, id: string, name: string, description: any, image?: string | null, buttonText: string, publishedAt?: any | null, endTime?: any | null, visibleAt?: any | null, userCompletedAt?: any | null }
25482548
> } };
25492549

25502550
export type ProfilePageQueryVariables = Exact<{ [key: string]: never; }>;
@@ -2714,6 +2714,11 @@ export type AdminUsersPageQueryVariables = Exact<{
27142714

27152715
export type AdminUsersPageQuery = { __typename?: 'Query', users: { __typename?: 'UserConnection', totalCount: number, pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | null, endCursor?: string | null }, edges: Array<{ __typename?: 'UserEdge', cursor: string, node: { __typename?: 'User', id: string, name: string, email: string, image?: string | null, church: { __typename?: 'Church', name: string }, roles: Array<{ __typename?: 'UserRole', id: string, role: RoleType }> } }> } };
27162716

2717+
export type StandingsPageQueryVariables = Exact<{ [key: string]: never; }>;
2718+
2719+
2720+
export type StandingsPageQuery = { __typename?: 'Query', myCurrentProject: { __typename?: 'Project', myTeam?: { __typename?: 'Team', id: string } | null } };
2721+
27172722

27182723
export const ProjectRulesDocument = gql`
27192724
query ProjectRules {
@@ -3273,6 +3278,7 @@ export const ChallengesPageDocument = gql`
32733278
query ChallengesPage {
32743279
myCurrentProject {
32753280
challenges {
3281+
__typename
32763282
id
32773283
name
32783284
description
@@ -3281,6 +3287,13 @@ export const ChallengesPageDocument = gql`
32813287
publishedAt
32823288
endTime
32833289
visibleAt
3290+
userCompletedAt
3291+
... on SimpleChallenge {
3292+
allowSelfCompletion
3293+
}
3294+
... on ExternalChallenge {
3295+
url
3296+
}
32843297
}
32853298
}
32863299
}
@@ -3997,4 +4010,17 @@ export const AdminUsersPageDocument = gql`
39974010

39984011
export function useAdminUsersPageQuery(options?: Omit<Urql.UseQueryArgs<never, AdminUsersPageQueryVariables | undefined>, 'query'>) {
39994012
return Urql.useQuery<AdminUsersPageQuery, AdminUsersPageQueryVariables | undefined>({ query: AdminUsersPageDocument, variables: undefined, ...options });
4013+
};
4014+
export const StandingsPageDocument = gql`
4015+
query StandingsPage {
4016+
myCurrentProject {
4017+
myTeam {
4018+
id
4019+
}
4020+
}
4021+
}
4022+
`;
4023+
4024+
export function useStandingsPageQuery(options?: Omit<Urql.UseQueryArgs<never, StandingsPageQueryVariables | undefined>, 'query'>) {
4025+
return Urql.useQuery<StandingsPageQuery, StandingsPageQueryVariables | undefined>({ query: StandingsPageDocument, variables: undefined, ...options });
40004026
};

frontend/app/components/design/DesignTabs.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
<script setup lang="ts" generic="Tab extends { label: string; value: string }">
1+
<script
2+
setup
3+
lang="ts"
4+
generic="Tab extends { label: string; value: string; enabled?: boolean }"
5+
>
26
import { cva } from 'cva'
37
4-
withDefaults(
8+
const props = withDefaults(
59
defineProps<{
610
tabs: Tab[]
711
variant?: 'primary' | 'secondary'
@@ -38,12 +42,16 @@ const buttonClasses = cva('text-accent-contrast relative grow', {
3842
},
3943
},
4044
})
45+
46+
const enabledTabs = computed(() =>
47+
props.tabs.filter((tab) => tab.enabled !== false),
48+
)
4149
</script>
4250

4351
<template>
4452
<div :class="containerClasses({ variant })">
4553
<button
46-
v-for="tab in tabs"
54+
v-for="tab in enabledTabs"
4755
:key="tab.value"
4856
:class="buttonClasses({ variant, active: tab.value == modelValue })"
4957
@click="modelValue = tab.value"

frontend/app/graphql/queries/pages/challenges.gql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
query ChallengesPage {
22
myCurrentProject {
33
challenges {
4+
__typename
45
id
56
name
67
description
@@ -9,6 +10,13 @@ query ChallengesPage {
910
publishedAt
1011
endTime
1112
visibleAt
13+
userCompletedAt
14+
... on SimpleChallenge {
15+
allowSelfCompletion
16+
}
17+
... on ExternalChallenge {
18+
url
19+
}
1220
}
1321
}
1422
}

frontend/app/pages/standings.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ const tab = computed({
1313
params.tab = newTab
1414
},
1515
})
16+
17+
gql(`
18+
query StandingsPage {
19+
myCurrentProject {
20+
myTeam {
21+
id
22+
}
23+
}
24+
}
25+
`)
26+
27+
const { data } = await useStandingsPageQuery()
28+
const hasUnit = computed(() => Boolean(data.value?.myCurrentProject.myTeam?.id))
1629
</script>
1730

1831
<template>
@@ -23,7 +36,7 @@ const tab = computed({
2336
:tabs="[
2437
{ label: $t('standings.global'), value: 'global' },
2538
{ label: $t('standings.local'), value: 'local' },
26-
{ label: $t('standings.unit'), value: 'unit' },
39+
{ label: $t('standings.unit'), value: 'unit', enabled: hasUnit },
2740
]"
2841
class="mb-default -mt-list-outside"
2942
/>

0 commit comments

Comments
 (0)