joyent-portal/consoles/my-joy-navigation/src/containers/account.js

50 lines
901 B
JavaScript
Raw Normal View History

2018-03-28 16:26:25 +03:00
import React from 'react';
import get from 'lodash.get';
import emotion from 'preact-emotion';
import { graphql, compose } from 'react-apollo';
import gql from 'graphql-tag';
2018-03-28 16:26:25 +03:00
import { Anchor, Popover } from '../components';
const Ul = emotion('ul')`
list-style-type: none;
padding: 0;
margin: 0;
`;
const GetAccountServices = gql`
{
account {
services {
name
url
}
}
}
`;
const Account = ({ expanded, services = [] }) => {
2018-04-06 17:53:44 +03:00
return expanded ? (
2018-03-28 16:26:25 +03:00
<Popover>
<Ul>
{services.map(({ name, url }) => (
<li>
<Anchor href={url}>{name}</Anchor>
</li>
))}
</Ul>
2018-03-28 16:26:25 +03:00
</Popover>
2018-04-06 17:53:44 +03:00
) : null;
};
2018-03-28 16:26:25 +03:00
export default compose(
graphql(GetAccountServices, {
options: () => ({
ssr: false
}),
props: ({ data }) => ({
services: get(data, 'account.services', [])
})
})
)(Account);