Skip to content

Instantly share code, notes, and snippets.

@vsavkin
Created August 8, 2019 17:32
Show Gist options
  • Save vsavkin/0dc44af8f4092f750cb6e0c8de704451 to your computer and use it in GitHub Desktop.
Save vsavkin/0dc44af8f4092f750cb6e0c8de704451 to your computer and use it in GitHub Desktop.
export const App = () => {
const [tickets, setTickets] = useState<Ticket[]>([]);
const [agentName, setAgentName] = useState<{ name: string }>({ name: '' });
useEffect(() => {
fetch('/api/tickets')
.then(t => t.json())
.then(setTickets);
}, []);
useEffect(() => {
fetch('/agent')
.then(t => t.json())
.then(setAgentName);
}, []);
return (
<StyledApp>
<header className="flex">
<h1>Welcome to agent!</h1>
</header>
<main>
<TicketList tickets={tickets} />
<section>
<p>Agent {agentName.name}</p>
<button>Agent Action</button>
</section>
</main>
</StyledApp>
);
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment