Skip to content

Commit

Permalink
[Hotfix] Réinitialise le state local de l'orga à chaque essai de conn…
Browse files Browse the repository at this point in the history
…exion [NGC-901] (#571)
  • Loading branch information
bjlaa authored May 30, 2024
2 parents 849116f + 68e7787 commit 6ce5fbf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export default function HeroSection() {
<Trans>Nos Gestes Climat pour les organisations</Trans>
</h1>

<p className="mb-12 text-sm md:text-lg">
<div className="mb-12 text-sm md:text-lg">
<Baseline />
</p>
</div>

<div className="flex flex-col flex-wrap items-center gap-4 sm:flex-row sm:justify-start md:items-baseline md:gap-8 lg:justify-start">
<ButtonLink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ export default function EmailForm() {
email,
})

// Reset the organisation local state
updateUserOrganisation({
administratorEmail: email,
slug: '',
name: '',
})

// We update the expiration date of the code
updateLoginExpirationDate(expirationDate)
} catch (error: any) {
Expand All @@ -64,6 +71,13 @@ export default function EmailForm() {
userId: user.userId,
})

// Always reset the organisation local state
updateUserOrganisation({
administratorEmail: email,
slug: '',
name: '',
})

updateLoginExpirationDate(expirationDate)
} catch (error: any) {
setInputError(error.response.data.message)
Expand Down
6 changes: 3 additions & 3 deletions src/publicodes-state/hooks/useUser/useUserDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ export default function useUserDetails({ setUser }: Props) {
(organisation: UserOrganisationInfo) => {
const organisationModifications: UserOrganisationInfo = {}

if (organisation.administratorEmail) {
if (organisation.administratorEmail !== undefined) {
organisationModifications.administratorEmail =
organisation.administratorEmail
}

if (organisation.slug) {
if (organisation.slug !== undefined) {
organisationModifications.slug = organisation.slug
}

if (organisation.name) {
if (organisation.name !== undefined) {
organisationModifications.name = organisation.name
}

Expand Down

0 comments on commit 6ce5fbf

Please sign in to comment.