Skip to content

Instantly share code, notes, and snippets.

@dshook
Created December 22, 2021 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dshook/5268e8a9c6affa0416ba4c3c2a9c1740 to your computer and use it in GitHub Desktop.
Save dshook/5268e8a9c6affa0416ba4c3c2a9c1740 to your computer and use it in GitHub Desktop.
/** ...imports... */
export const AccountQuery = gql`
query exampleQuery($id: ID!) {
account(id: $id) {
id
name
addresses(type: [BUSINESS]) {
id
street
street2
city
state
type
}
parentAccount {
id
}
}
}
`;
const StyledWrapper = styled.div`
margin: 10px auto;
background-color: ${palettes.gray[700]};
`;
const AddressDisplay = styled.div`
text-align: left;
`;
export const GrowerTINEditContainer = () => {
const { accountId } = useParams<{ accountId: string }>();
const { data, error, loading } = useQuery<ExampleQueryData, ExampleQueryVariables>(AccountQuery, {
variables: { id: accountId },
});
if (loading) { return <Loader />; }
if (error || !data?.account) {
throw new Error('Could not retrieve account');
}
return (
<StyledWrapper>
<SubComponent account={data?.account} />
{data?.account.addresses.map(address =>
<AddressDisplay
key={address.id}
address={address}
>
{`${address.street} ${address.city}, ${address.state}`}
</AddressDisplay>
)}
</StyledWrapper>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment