Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

refactor: removes galoy-client dependency to fetch contacts #178

Open
wants to merge 2 commits into
base: julian-task
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export KRATOS_API_URL="http://localhost:4433"
export KRATOS_BROWSER_URL="http://localhost:4433"
export GALOY_AUTH_ENDPOINT="http://localhost:4002/auth"

export KRATOS_FEATURE_FLAG="false"
export KRATOS_FEATURE_FLAG="false"
28 changes: 24 additions & 4 deletions src/components/pages/contacts.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
import { truncatedDisplay, useQuery } from "@galoymoney/client"
import { gql } from "@apollo/client"
import { Spinner } from "@galoymoney/react"

import { truncatedDisplay } from "@galoymoney/client"
import { useContactsQuery } from "graphql/generated"
import { translate, history, useAuthContext, NoPropsFCT } from "store/index"

import ErrorMessage from "components/error-message"
import Header from "components/header"
import Icon from "components/icon"

gql`
query contacts {
me {
id
contacts {
username
alias
transactionsCount
__typename
}
__typename
}
}
`

const ContactsList: NoPropsFCT = () => {
const { loading, errorsMessage, data } = useQuery.contacts()
const { data, loading, error } = useContactsQuery({
context: {
credentials: "include",
},
})

const handleSendBitcoin = (contactUsername: string) => {
history.push(`/send?to=${contactUsername}`)
Expand All @@ -22,7 +42,7 @@ const ContactsList: NoPropsFCT = () => {
<div className="list">
{loading && <Spinner size="big" />}

{errorsMessage && <ErrorMessage message={errorsMessage} />}
{error && <ErrorMessage message={error.message} />}

{data?.me?.contacts.length === 0 && (
<div className="no-data">{translate("No Contacts")}</div>
Expand Down
Loading