This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement nav menu and contacts screens (#52)
* fix: fix initial display of recent transactions * feat: add contacts placeholder components and refactor routes * feat: implement nav menu and contacts screens * chore: upgrade dependencies Co-authored-by: Samer Buna <[email protected]>
- Loading branch information
Showing
20 changed files
with
907 additions
and
483 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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { translate, useQuery } from "@galoymoney/client" | ||
import { Spinner } from "@galoymoney/react" | ||
import { history } from "../../store" | ||
import ErrorMessage from "../error-message" | ||
import Header from "../header" | ||
|
||
const nameDisplay = (name: string): string => { | ||
if (name.length > 15) { | ||
return name.substring(0, 15) + "..." | ||
} | ||
|
||
return name | ||
} | ||
|
||
const Contacts = () => { | ||
const { loading, errorsMessage, data } = useQuery.contacts() | ||
|
||
const handleSendBitcoin = (contactUsername: string) => { | ||
history.push(`/send?to=${contactUsername}`) | ||
} | ||
|
||
const showContactDetails = (contactUsername: string) => { | ||
history.push(`/transactions?username=${contactUsername}`) | ||
} | ||
|
||
return ( | ||
<div className="contacts"> | ||
<Header page="contacts" /> | ||
|
||
<div className="page-title">{translate("Contacts")}</div> | ||
<div className="list"> | ||
{loading && <Spinner size="big" />} | ||
|
||
{errorsMessage && <ErrorMessage message={errorsMessage} />} | ||
|
||
{data?.me?.contacts.map((contact) => { | ||
return ( | ||
<div key={contact.username} className="contact"> | ||
<i aria-hidden className="fas fa-user-alt" /> | ||
<div className="name">{nameDisplay(contact.alias ?? contact.username)}</div> | ||
<div className="actions"> | ||
<div | ||
title={translate("Transaction List")} | ||
onClick={() => showContactDetails(contact.username)} | ||
> | ||
<i aria-hidden className="fas fa-list" /> | ||
</div> | ||
<div | ||
title={translate("Send Bitcoin")} | ||
onClick={() => handleSendBitcoin(contact.username)} | ||
> | ||
<i aria-hidden className="fas fa-paper-plane" /> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Contacts |
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,11 @@ | ||
import { translate } from "@galoymoney/client" | ||
|
||
const ErrorMessage = ({ message = "Not able to generate invoice." }) => ( | ||
<div className="error"> | ||
{translate(message as never)} | ||
<br /> | ||
{translate("Please try again later.")} | ||
</div> | ||
) | ||
|
||
export default ErrorMessage |
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
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
Oops, something went wrong.