Skip to content

Commit

Permalink
fix(various): Email AddressURN and Team Email (#2470)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmin-Parvulescu authored Jul 11, 2023
1 parent 8165f54 commit d2c97bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
29 changes: 20 additions & 9 deletions apps/console/app/routes/apps/$clientId/team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ import {
getEmailDropdownItems,
} from '@proofzero/utils/getNormalisedConnectedAccounts'


import type { AddressURN } from '@proofzero/urns/address'
import type { AccountURN } from '@proofzero/urns/account'
import type { ActionFunction, LoaderFunction } from '@remix-run/cloudflare'
import type { errorsTeamProps, notificationHandlerType } from '~/types'
import { BadRequestError } from '@proofzero/errors'
import { getRollupReqFunctionErrorWrapper } from '@proofzero/utils/errors'
import { Dropdown, DropdownSelectListItem } from '@proofzero/design-system/src/atoms/dropdown/DropdownSelectList'
import {
Dropdown,
DropdownSelectListItem,
} from '@proofzero/design-system/src/atoms/dropdown/DropdownSelectList'

export const loader: LoaderFunction = getRollupReqFunctionErrorWrapper(
async ({ request, context, params }) => {
Expand Down Expand Up @@ -132,8 +134,9 @@ export default () => {

const submit = useSubmit()

let { connectedEmails } = useLoaderData() as { connectedEmails: Array<DropdownSelectListItem> }

let { connectedEmails } = useLoaderData() as {
connectedEmails: Array<DropdownSelectListItem>
}

const { PASSPORT_URL, notificationHandler, appContactAddress } =
useOutletContext<{
Expand Down Expand Up @@ -209,12 +212,12 @@ export default () => {
<Dropdown
items={connectedEmails.map((email: DropdownSelectListItem) => {
email.value === appContactAddress
? email.selected = true
: email.selected = false;
? (email.selected = true)
: (email.selected = false)
// Substituting subtitle with icon
// on the client side
email.subtitle && !email.icon
? email.icon = getEmailIcon(email.subtitle)
? (email.icon = getEmailIcon(email.subtitle))
: null
return {
value: email.value,
Expand All @@ -223,7 +226,7 @@ export default () => {
title: email.title,
}
})}
placeholder='Select an Email Address'
placeholder="Select an Email Address"
onSelect={(selected) => {
// type casting to DropdownSelectListItem instead of array
if (!Array.isArray(selected)) {
Expand All @@ -245,7 +248,15 @@ export default () => {
}
}}
ConnectButtonCallback={redirectToPassport}
ConnectButtonPhrase='Connect New Email Address'
ConnectButtonPhrase="Connect New Email Address"
defaultItems={connectedEmails
.filter((el) => el.value === appContactAddress)
.map((email: DropdownSelectListItem) => ({
value: email.value,
selected: email.selected,
icon: email.icon,
title: email.title,
}))}
/>
</>
)}
Expand Down
4 changes: 2 additions & 2 deletions apps/passport/app/routes/connect/email/otp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const loader: LoaderFunction = getRollupReqFunctionErrorWrapper(
throw new BadRequestError({ message: 'No address included in request' })

const addressURN = AddressURNSpace.componentizedUrn(
generateHashedIDRef(EmailAddressType.Email, email),
generateHashedIDRef(EmailAddressType.Email, email.toLowerCase()),
{ node_type: NodeType.Email, addr_type: EmailAddressType.Email },
{ alias: email, hidden: 'true' }
)
Expand Down Expand Up @@ -100,7 +100,7 @@ export const action: ActionFunction = getRollupReqFunctionErrorWrapper(
})

const addressURN = AddressURNSpace.componentizedUrn(
generateHashedIDRef(EmailAddressType.Email, email),
generateHashedIDRef(EmailAddressType.Email, email.toLowerCase()),
{ node_type: NodeType.Email, addr_type: EmailAddressType.Email },
{ alias: email, hidden: 'true' }
)
Expand Down

0 comments on commit d2c97bb

Please sign in to comment.