Skip to content

Commit c1c7cd6

Browse files
committed
wip: start implementing unit update
1 parent 3c2dfec commit c1c7cd6

File tree

6 files changed

+116
-17
lines changed

6 files changed

+116
-17
lines changed

frontend/app/api/generated.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export type LeaderboardEntry = {
387387
id: Scalars['ID']['output'];
388388
image?: Maybe<Scalars['String']['output']>;
389389
name: Scalars['String']['output'];
390-
rank: Scalars['Int']['output'];
390+
rank?: Maybe<Scalars['Int']['output']>;
391391
score: Scalars['Int']['output'];
392392
tags: Array<LeaderboardEntryTag>;
393393
};
@@ -1521,20 +1521,20 @@ export type StandingsGlobalPageQueryVariables = Exact<{
15211521
}>;
15221522

15231523

1524-
export type StandingsGlobalPageQuery = { __typename?: 'Query', myCurrentProject: { __typename?: 'Project', id: string, leaderboard: { __typename?: 'LeaderboardConnection', edges: Array<{ __typename?: 'LeaderboardEdge', node: { __typename?: 'LeaderboardEntry', id: string, name: string, description: string, score: number, image?: string | null, rank: number, tags: Array<LeaderboardEntryTag> } }>, me?: { __typename?: 'LeaderboardEntry', id: string, name: string, description: string, score: number, rank: number, tags: Array<LeaderboardEntryTag>, image?: string | null } | null } } };
1524+
export type StandingsGlobalPageQuery = { __typename?: 'Query', myCurrentProject: { __typename?: 'Project', id: string, leaderboard: { __typename?: 'LeaderboardConnection', edges: Array<{ __typename?: 'LeaderboardEdge', node: { __typename?: 'LeaderboardEntry', id: string, name: string, description: string, score: number, image?: string | null, rank?: number | null, tags: Array<LeaderboardEntryTag> } }>, me?: { __typename?: 'LeaderboardEntry', id: string, name: string, description: string, score: number, rank?: number | null, tags: Array<LeaderboardEntryTag>, image?: string | null } | null } } };
15251525

15261526
export type StandingsLocalPageQueryVariables = Exact<{
15271527
entityType: LeaderboardEntityType;
15281528
filter?: InputMaybe<LeaderboardFilter>;
15291529
}>;
15301530

15311531

1532-
export type StandingsLocalPageQuery = { __typename?: 'Query', me: { __typename?: 'User', church: { __typename?: 'Church', id: string, name: string } }, myCurrentProject: { __typename?: 'Project', id: string, leaderboard: { __typename?: 'LeaderboardConnection', edges: Array<{ __typename?: 'LeaderboardEdge', node: { __typename?: 'LeaderboardEntry', id: string, name: string, score: number, image?: string | null, rank: number, tags: Array<LeaderboardEntryTag> } }>, me?: { __typename?: 'LeaderboardEntry', id: string, name: string, score: number, rank: number, tags: Array<LeaderboardEntryTag>, image?: string | null } | null } } };
1532+
export type StandingsLocalPageQuery = { __typename?: 'Query', me: { __typename?: 'User', church: { __typename?: 'Church', id: string, name: string } }, myCurrentProject: { __typename?: 'Project', id: string, leaderboard: { __typename?: 'LeaderboardConnection', edges: Array<{ __typename?: 'LeaderboardEdge', node: { __typename?: 'LeaderboardEntry', id: string, name: string, score: number, image?: string | null, rank?: number | null, tags: Array<LeaderboardEntryTag> } }>, me?: { __typename?: 'LeaderboardEntry', id: string, name: string, score: number, rank?: number | null, tags: Array<LeaderboardEntryTag>, image?: string | null } | null } } };
15331533

15341534
export type StandingsUnitPageQueryVariables = Exact<{ [key: string]: never; }>;
15351535

15361536

1537-
export type StandingsUnitPageQuery = { __typename?: 'Query', myCurrentProject: { __typename?: 'Project', id: string, myTeam?: { __typename?: 'Team', id: string, name: string, memberLeaderboard: Array<{ __typename?: 'LeaderboardEntry', id: string, name: string, tags: Array<LeaderboardEntryTag>, rank: number, score: number }> } | null } };
1537+
export type StandingsUnitPageQuery = { __typename?: 'Query', myCurrentProject: { __typename?: 'Project', id: string, myTeam?: { __typename?: 'Team', id: string, name: string, memberLeaderboard: Array<{ __typename?: 'LeaderboardEntry', id: string, name: string, tags: Array<LeaderboardEntryTag>, rank?: number | null, score: number }> } | null } };
15381538

15391539
export type GetMeQueryVariables = Exact<{ [key: string]: never; }>;
15401540

@@ -1812,7 +1812,7 @@ export type ProfilePageQuery = { __typename?: 'Query', me: { __typename?: 'User'
18121812
| { __typename?: 'ReadingAchievement', id: string, name: string, description: string, image?: string | null, hidden: boolean, achievedAt?: any | null, points: number }
18131813
| { __typename?: 'SimpleAchievement', id: string, name: string, description: string, image?: string | null, hidden: boolean, achievedAt?: any | null, points: number }
18141814
| { __typename?: 'StreakAchievement', id: string, name: string, description: string, image?: string | null, hidden: boolean, achievedAt?: any | null, points: number }
1815-
>, leaderboard: { __typename?: 'LeaderboardConnection', me?: { __typename?: 'LeaderboardEntry', score: number, rank: number } | null } } };
1815+
>, leaderboard: { __typename?: 'LeaderboardConnection', me?: { __typename?: 'LeaderboardEntry', score: number, rank?: number | null } | null } } };
18161816

18171817

18181818
export const StandingsGlobalPageDocument = gql`

frontend/app/components/PageLayout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const hasScrolled = computed(() => y.value > 25)
4747
</header>
4848
</ProgressiveBlur>
4949
</div>
50-
<div class="p-list-outside grow pb-28">
50+
<div class="p-list-outside grow">
5151
<slot />
5252
</div>
5353
</div>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
label?: string
4+
}>()
5+
6+
const id = useId()
7+
8+
const modelValue = defineModel<string>()
9+
</script>
10+
11+
<template>
12+
<div class="flex flex-col">
13+
<label
14+
v-if="label"
15+
:for="id"
16+
class="text-caption text-text-muted px-4 py-2"
17+
>
18+
{{ label }}
19+
</label>
20+
<DesignPanel>
21+
<input
22+
:id="id"
23+
v-model="modelValue"
24+
class="text-label w-full px-3 py-4"
25+
/>
26+
</DesignPanel>
27+
</div>
28+
</template>

frontend/app/components/standings/StandingsUnit.vue

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,23 @@ const { data, error, fetching } = useStandingsUnitPageQuery({
2424
pause: computed(() => !isAuthReady.value),
2525
})
2626
27+
const teamLeader = computed(() => {
28+
return data.value?.myCurrentProject.myTeam?.memberLeaderboard.find((entry) =>
29+
entry.tags?.includes(LeaderboardEntryTag.TeamLead),
30+
)
31+
})
32+
2733
// Update team
28-
// const { executeMutation } = useUpdateTeamMutation()
34+
const { executeMutation } = useUpdateTeamMutation()
35+
function saveChanges() {
36+
const id = data.value?.myCurrentProject.myTeam?.id
37+
if (!id) return
38+
39+
// executeMutation({
40+
// id,
41+
// input: { name: data.value?.myCurrentProject.myTeam?.name },
42+
// })
43+
}
2944
</script>
3045

3146
<template>
@@ -40,17 +55,63 @@ const { data, error, fetching } = useStandingsUnitPageQuery({
4055
<h2 class="text-heading text-balance">
4156
{{ data.myCurrentProject.myTeam.name }}
4257
</h2>
43-
<DesignButton v-if="isTeamLead" variant="secondary" size="medium">
44-
{{ $t('standings.editUnit') }}
45-
</DesignButton>
58+
<UModal
59+
v-if="isTeamLead"
60+
:ui="{ content: 'bg-background-default' }"
61+
:transition="false"
62+
modal
63+
fullscreen
64+
>
65+
<DesignButton variant="secondary" size="medium">
66+
{{ $t('unit.editUnit') }}
67+
</DesignButton>
68+
<template #content="{ close }">
69+
<PageLayout :title="$t('unit.editUnit')">
70+
<template #action>
71+
<DesignIconButton icon="lucide:x" @click="close" />
72+
</template>
73+
<div class="gap-list-section-gap flex h-full flex-col">
74+
<DesignInput
75+
v-model="data.myCurrentProject.myTeam.name"
76+
:label="$t('unit.unitName')"
77+
/>
78+
<DesignPanel>
79+
<div class="flex items-center gap-2.5 px-3 py-2">
80+
<Icon name="lucide:badge-check" class="size-6" />
81+
<span class="text-label">{{ $t('unit.unitLeader') }}</span>
82+
<DesignButton
83+
variant="secondary"
84+
size="small"
85+
:class="[
86+
'ml-auto grow-0',
87+
{ 'text-text-hint': !teamLeader?.name },
88+
]"
89+
>
90+
{{ teamLeader?.name ?? $t('unit.noUnitLeader') }}
91+
</DesignButton>
92+
</div>
93+
</DesignPanel>
94+
<div class="p-default flex h-full flex-col justify-end">
95+
<DesignButton
96+
size="large"
97+
class="grow-0"
98+
@click="saveChanges"
99+
>
100+
{{ $t('unit.saveChanges') }}
101+
</DesignButton>
102+
</div>
103+
</div>
104+
</PageLayout>
105+
</template>
106+
</UModal>
46107
</div>
47108
<LeaderboardList
48109
v-if="data.myCurrentProject.myTeam?.memberLeaderboard?.length"
49110
:leaderboard="data.myCurrentProject.myTeam.memberLeaderboard"
50111
:badge="
51112
(entry) =>
52113
entry.tags?.includes(LeaderboardEntryTag.TeamLead)
53-
? $t('standings.unitLeader')
114+
? $t('unit.unitLeader')
54115
: undefined
55116
"
56117
hide-medals

frontend/i18n/locales/en.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@
2626
"global": "Top 20",
2727
"unit": "Your unit",
2828
"local": "Local",
29-
"editUnit": "Edit unit",
3029
"you": "You",
3130
"pointsHistoryButton": "Points history",
32-
"pointsExplainerButton": "Get points",
33-
"unitLeader": "Unit leader"
31+
"pointsExplainerButton": "Get points"
32+
},
33+
"unit": {
34+
"unitLeader": "Unit leader",
35+
"saveChanges": "Save changes",
36+
"unitName": "Unit name",
37+
"editUnit": "Edit unit",
38+
"noUnitLeader": "No unit leader"
3439
},
3540
"points": "points",
3641
"place": "place"

frontend/i18n/locales/nb.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@
2626
"global": "Topp 20",
2727
"unit": "Din unit",
2828
"local": "Lokalt",
29-
"editUnit": "Rediger unit",
3029
"you": "Deg",
3130
"pointsHistoryButton": "Poenghistorikk",
32-
"pointsExplainerButton": "Få poeng",
33-
"unitLeader": "Unitleder"
31+
"pointsExplainerButton": "Få poeng"
32+
},
33+
"unit": {
34+
"editUnit": "Rediger unit",
35+
"unitLeader": "Unitleder",
36+
"saveChanges": "Lagre endringer",
37+
"unitName": "Unitnavn",
38+
"noUnitLeader": "Ingen unitleder"
3439
},
3540
"place": "plass",
3641
"points": "poeng"

0 commit comments

Comments
 (0)