-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add callto link to user details (#269)
- Loading branch information
Showing
5 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { PhoneOutlined } from '@ant-design/icons'; | ||
import React from 'react'; | ||
|
||
import { Anchor } from '../Anchor'; | ||
|
||
import { RowWithLabel } from './RowWithLabel'; | ||
import { callToLink } from './phone'; | ||
|
||
type PhoneRowProps = { | ||
phone: string; | ||
}; | ||
|
||
export function PhoneRow({ phone }: PhoneRowProps) { | ||
return ( | ||
<RowWithLabel label={<PhoneOutlined />}> | ||
<Anchor href={callToLink(phone)}>{phone}</Anchor> | ||
</RowWithLabel> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ export default { | |
email: { control: { type: 'text' }, defaultValue: '[email protected]' }, | ||
firstname: { control: { type: 'text' }, defaultValue: 'John' }, | ||
lastname: { control: { type: 'text' }, defaultValue: 'Doe' }, | ||
phone: { control: { type: 'text' }, defaultValue: '123' }, | ||
username: { control: { type: 'text' }, defaultValue: 'jdoe' }, | ||
inactive: { | ||
control: { | ||
|
@@ -56,6 +57,7 @@ export const Default: Story = function Link(args) { | |
firstname: args.firstname, | ||
lastname: args.lastname, | ||
username: args.username, | ||
phone: args.phone, | ||
inactive: args.inactive, | ||
} | ||
} | ||
|
@@ -73,6 +75,7 @@ export const WithCustomChildren: Story = function Link(args) { | |
firstname: args.firstname, | ||
lastname: args.lastname, | ||
username: args.username, | ||
phone: args.phone, | ||
inactive: args.inactive, | ||
}), | ||
[args], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { callToLink } from './phone'; | ||
|
||
describe('callToLink', () => { | ||
it('throws error when phone is empty ', () => { | ||
expect(() => callToLink('')).toThrow(/empty/); | ||
}); | ||
|
||
it('renders callto link ', () => { | ||
const phone = '123'; | ||
expect(callToLink(phone)).toBe(`callto:${phone}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function callToLink(phone: string): string { | ||
if (!phone) { | ||
throw new Error('Could not create callto-Link because phone is empty'); | ||
} | ||
|
||
return `callto:${phone}`; | ||
} |