Skip to content

Commit

Permalink
fix: some regression in partners management
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Dec 9, 2024
1 parent 2ab6748 commit 00b6366
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ui/src/components/add-partner-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
</v-btn>
<v-btn
color="primary"
variant="flat"
:disabled="$uiConfig.manageSites && !redirects"
@click="confirmCreate"
>
Expand Down Expand Up @@ -115,7 +116,7 @@ const confirmCreate = withUiNotif(async () => {
await createForm.value?.validate()
if (createForm.value?.isValid) {
menu.value = false
await $fetch(`organizations/${orga.id}/partners`, { method: 'POST', body: editPartner })
await $fetch(`organizations/${orga.id}/partners`, { method: 'POST', body: editPartner.value })
sendUiNotif({ type: 'success', msg: t('pages.organization.invitePartnerSuccess', { email: editPartner.value.contactEmail }) })
emit('change')
}
Expand Down
16 changes: 8 additions & 8 deletions ui/src/components/partner-invitation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</template>

<template v-if="!user">
<p>
<p class="my-4">
Vous avez déjà un compte ? Vous pouvez vous connecter et vous serez redirigé vers cette page par la suite.
</p>
<p>
Expand All @@ -45,7 +45,7 @@
:href="loginUrl(undefined, {email: invit.e})"
/>
</p>
<p>
<p class="my-4">
Vous n'avez pas encore de compte ? Vous pouvez en créer un et vous serez redirigé vers cette page par la suite.
</p>
<p>
Expand All @@ -59,7 +59,7 @@
</template>

<template v-if="user">
<p v-if="otherUserOrgs.length === 0">
<p v-if="otherUserOrgs?.length === 0">
Vous n'appartenez à aucune organisation. Vous pouvez créer une nouvelle organisation et accepter l'invitation en son nom.
</p>
<p v-else>
Expand Down Expand Up @@ -122,7 +122,7 @@ import { type Organization, type ShortenedPartnerInvitation } from '#api/types'
import { jwtDecode } from 'jwt-decode'
const reactiveSearchParams = useReactiveSearchParams()
const { user, loginUrl } = useSessionAuthenticated()
const { user, loginUrl } = useSession()
const { mainPublicUrl } = useStore()
const createOrganizationName = ref('')
Expand All @@ -133,18 +133,18 @@ const token = reactiveSearchParams.partner_invit_token
const invit = token ? jwtDecode(token) as ShortenedPartnerInvitation : undefined
const otherUserOrgs = computed(() => {
if (!invit) return []
return user.value.organizations.filter(o => invit.o !== o.id)
return user.value?.organizations.filter(o => invit.o !== o.id)
})
if (invit) {
createOrganizationName.value = invit.n
if (otherUserOrgs.value.length === 0) createNewOrg.value = true
if (otherUserOrgs.value?.length === 0) createNewOrg.value = true
}
const createOrga = withUiNotif(async () => {
if (!createOrganizationName.value) return
const orga = await $fetch<Organization>('api/organizations', { method: 'POST', body: { name: createOrganizationName.value } })
if (!user.value.organizations.length) {
await $fetch('users/' + user.value.id, { body: { defaultOrg: orga.id, ignorePersonalAccount: true } })
if (!user.value?.organizations.length) {
await $fetch('users/' + user.value?.id, { body: { defaultOrg: orga.id, ignorePersonalAccount: true } })
}
acceptPartnerInvitation(orga)
})
Expand Down
2 changes: 1 addition & 1 deletion ui/src/composables/use-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function createStore () {
const mainRedirect = computed(() => {
const mainRedirect = reactiveSearchParams.main_redirect || reactiveSearchParams.mainRedirect
if (!mainRedirect && redirect.value?.startsWith(mainPublicUrl.origin)) return redirect.value
return mainRedirect
return mainRedirect ?? mainPublicUrl.href
})

const redirects = computed(() => {
Expand Down

0 comments on commit 00b6366

Please sign in to comment.