@@ -30,30 +30,58 @@ const teamLeader = computed(() => {
3030 )
3131})
3232
33+ const teamMembers = computed (() => {
34+ return data .value ?.myCurrentProject .myTeam ?.memberLeaderboard ?? []
35+ })
36+
3337// Update team
3438const form = reactive ({
3539 name: ' ' ,
40+ teamLeadId: null as string | null ,
3641})
3742watch (
3843 () => data .value ,
3944 (d ) => {
4045 if (d ) {
4146 form .name = d .myCurrentProject .myTeam ?.name ?? ' '
47+ form .teamLeadId = teamLeader .value ?.id ?? null
4248 }
4349 },
4450 { once: true },
4551)
52+
53+ const selectedTeamLeader = computed (() => {
54+ if (! form .teamLeadId ) return null
55+ return teamMembers .value .find ((m ) => m .id === form .teamLeadId )
56+ })
57+
4658const { executeMutation } = useUpdateTeamMutation ()
47- function saveChanges() {
59+ const { executeMutation : assignTeamLead } = useAssignTeamLeadMutation ()
60+
61+ async function saveChanges() {
4862 const id = data .value ?.myCurrentProject .myTeam ?.id
4963 if (! id ) return
5064
51- executeMutation ({
65+ // Update team name
66+ await executeMutation ({
5267 id ,
5368 input: { name: form .name },
54- }).then (() => {
55- reloadNuxtApp ()
5669 })
70+
71+ // Assign team lead if changed
72+ if (form .teamLeadId && form .teamLeadId !== teamLeader .value ?.id ) {
73+ await assignTeamLead ({ teamId: id , userId: form .teamLeadId })
74+ }
75+
76+ reloadNuxtApp ()
77+ }
78+
79+ // Team lead selector
80+ const showLeadSelector = ref (false )
81+
82+ function selectTeamLead(userId : string ) {
83+ form .teamLeadId = userId
84+ showLeadSelector .value = false
5785}
5886 </script >
5987
@@ -95,13 +123,54 @@ function saveChanges() {
95123 size =" small"
96124 :class =" [
97125 'ml-auto grow-0',
98- { 'text-text-hint': !teamLeader ?.name },
126+ { 'text-text-hint': !selectedTeamLeader ?.name },
99127 ]"
128+ @click =" showLeadSelector = true"
100129 >
101- {{ teamLeader ?.name ?? $t('unit.noUnitLeader') }}
130+ {{ selectedTeamLeader ?.name ?? $t('unit.noUnitLeader') }}
102131 </DesignButton >
103132 </div >
104133 </DesignPanel >
134+
135+ <UModal
136+ v-model:open =" showLeadSelector"
137+ :ui =" { content: 'bg-background-default' }"
138+ :transition =" false"
139+ fullscreen
140+ >
141+ <template #content =" { close: closeLeadSelector } " >
142+ <PageLayout
143+ :title =" $t('unit.selectUnitLeader')"
144+ :bottom-padding =" false"
145+ >
146+ <template #action >
147+ <DesignIconButton
148+ icon =" lucide:x"
149+ @click =" closeLeadSelector"
150+ />
151+ </template >
152+ <div class =" gap-list-section-gap flex flex-col" >
153+ <DesignPanel
154+ v-for =" member in teamMembers"
155+ :key =" member.id"
156+ class =" cursor-pointer"
157+ @click =" selectTeamLead(member.id)"
158+ >
159+ <div class =" flex items-center gap-2.5 px-3 py-2" >
160+ <span class =" text-label flex-1" >
161+ {{ member.name }}
162+ </span >
163+ <Icon
164+ v-if =" member.id === form.teamLeadId"
165+ name =" lucide:check"
166+ class =" text-accent size-5"
167+ />
168+ </div >
169+ </DesignPanel >
170+ </div >
171+ </PageLayout >
172+ </template >
173+ </UModal >
105174 <div class =" p-default flex h-full flex-col justify-end" >
106175 <DesignButton
107176 size =" large"
0 commit comments