intranets-phonebook
v0.0.8
Published
Internal API
Downloads
12
Readme
Intranets Phonebook
Internal API
Install
NPM
npm install intranets-phonebook --save
Yarn
yarn add intranets-phonebook
Sample React
import * as React from "react";
import { search } from "intranets-phonebook";
import { jsxIdentifier } from "@babel/types";
export interface Props {
children?: React.ReactNode;
}
const APISECRET = "**********" // replace with the Shared Secret you have received
export interface State {
searchResult: any;
}
export default class PhoneBook extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
searchResult: null
};
}
render() {
return (
<div>
<input
type="text"
style={{
fontSize: "48px",
width: "100%",
margin: "40px",
padding: "10px"
}}
placeholder="Enter a part of the name, email or phonenumber"
onInput={(e: any) => {
var searchFor: any = e.currentTarget.value;
search( APISECRET, searchFor, (result: any) => {
this.setState({ searchResult: result });
});
}}
></input>
<div>
{this.state.searchResult && (
<div>
{this.state.searchResult.results.map((address: any) => {
return (
<div
key={address.mail}
style={{
textAlign: "left",
fontSize: "48px",
width: "100%",
margin: "40px",
padding: "10px"
}}
>
<div>{address.name}</div>
<div>
E-mail:{" "}
<a href={"mailto:" + address.mail}>{address.mail}</a>
</div>
<div>Mobile: {address.mobile}</div>
<div>Phone: {address.phone}</div>
{JSON.stringify(address)}
</div>
);
})}
</div>
)}
</div>
</div>
);
}
}