Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion packages/app-elements/src/ui/composite/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type { Address as AddressType } from "@commercelayer/sdk"
import { NoteIcon, PencilSimpleIcon, PhoneIcon } from "@phosphor-icons/react"
import {
EnvelopeSimpleIcon,
NoteIcon,
PencilSimpleIcon,
PhoneIcon,
} from "@phosphor-icons/react"
import isEmpty from "lodash-es/isEmpty"
import { useMemo } from "react"
import { t } from "#providers/I18NProvider"
Expand All @@ -21,6 +26,7 @@ export interface AddressProps {
AddressType,
| "first_name"
| "last_name"
| "email"
| "company"
| "line_1"
| "line_2"
Expand Down Expand Up @@ -123,12 +129,24 @@ export const Address = withSkeletonTemplate<AddressProps>(
) : null}

{!isEmpty(address.phone) ||
!isEmpty(address.email) ||
(showNotes && !isEmpty(address.notes)) ? (
<>
<Spacer top="4" bottom="4">
<Hr variant="dashed" />
</Spacer>
<div className="grid gap-1">
{!isEmpty(address.email) && (
<div className="flex gap-2 ">
{/* mt-[2px] to keep icon aligned with text */}
<Text tag="div" variant="info" className="mt-[2px]">
<EnvelopeSimpleIcon weight="bold" />
</Text>
<Text tag="div" size="small" variant="info">
{address.email}
</Text>
</div>
)}
{!isEmpty(address.phone) && (
<div className="flex gap-2 ">
{/* mt-[2px] to keep icon aligned with text */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const presetAddresses = {
first_name: "Darth",
last_name: "Vader",
full_name: "Darth Vader",
email: "vader@galacticempire.com",
line_1: "Via Morte Nera, 13",
line_2: "Ragnatela, 99",
city: "Cogorno",
Expand Down Expand Up @@ -46,6 +47,7 @@ export const presetAddresses = {
first_name: "Luke",
last_name: "Skywalker",
full_name: "Luke Skywalker",
email: "luke@rebellion.com",
line_1: "Via Polis Massa, 42",
line_2: "Ragnatela, 99",
city: "Cogorno",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ describe("ResourceAddress", () => {
expect(getByText("+39 055 1234567890")).toBeVisible()
})

test("Should render email", async () => {
const { getByText } = setup()
expect(getByText("luke@rebellion.com")).toBeVisible()
})

test("Should render notes", async () => {
const { getByText } = setup()
expect(
Expand Down
Loading