This file contains hidden or 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
| import React, { useState } from 'react' | |
| import { Image, Table } from 'semantic-ui-react' | |
| import { formatCurrency } from '../../utils/filters' | |
| import CoinDetailsModal from './CoinDetailsModal' | |
| const CoinsTable = ({ coins }) => { | |
| const [isModalOpen, setIsModalOpen] = useState(false) | |
| const [selectedCoin, setSelectedCoin] = useState(null) | |
| const handleModal = e => { |
This file contains hidden or 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
| import React, { useState } from 'react' | |
| import { useQuery } from '@apollo/react-hooks' | |
| import { Image, Modal, Menu, Grid } from 'semantic-ui-react' | |
| import CoinDetailsModalTable from './CoinDetailsModalTable' | |
| import { GET_COIN_DETAILS } from '../../utils/queries' | |
| const CoinDetailModals = ({ isModalOpen, onClose, coinDetails }) => { | |
| const [interval, setInterval] = useState('1d') | |
| const { data, loading, error, refetch } = useQuery(GET_COIN_DETAILS, { |
This file contains hidden or 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
| export const formatCurrency = value => { | |
| const formatter = new Intl.NumberFormat('en-US', { | |
| style: 'currency', | |
| currency: 'USD' | |
| }) | |
| return formatter.format(value) | |
| } | |
| export const convertToPercentage = value => { | |
| return (value * 100).toFixed(2) + '%' |
This file contains hidden or 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
| import gql from 'graphql-tag' | |
| export const GET_COINS_QUERY = gql` | |
| { | |
| getCoins { | |
| id | |
| currency | |
| name | |
| logo_url | |
| rank |
This file contains hidden or 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
| import { Table } from 'semantic-ui-react' | |
| import { formatCurrency, convertToPercentage } from '../../utils/filters' | |
| const CoinDetailsModalTable = ({ coinDetails, data }) => ( | |
| <Table basic="very"> | |
| <Table.Body> | |
| <Table.Row> | |
| <Table.Cell>Symbol</Table.Cell> | |
| <Table.Cell>{coinDetails.currency}</Table.Cell> | |
| </Table.Row> |
This file contains hidden or 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
| import { Table } from 'semantic-ui-react' | |
| import { formatCurrency, convertToPercentage } from '../../utils/filters' | |
| const CoinDetailsModalTable = ({ coinDetails, data }) => ( | |
| <Table basic="very"> | |
| <Table.Body> | |
| <Table.Row> | |
| <Table.Cell>Symbol</Table.Cell> | |
| <Table.Cell>{coinDetails.currency}</Table.Cell> | |
| </Table.Row> |
This file contains hidden or 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
| ... | |
| "scripts": { | |
| "dev": "nodemon --exec \"sls offline start\" -e \"extensions,to,watch,for,example,js,elm,hs,py,yml\"", | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| ... |
This file contains hidden or 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
| const { gql } = require('apollo-server-lambda'); | |
| module.exports.typeDefs = gql` | |
| type Orders { | |
| id: String! | |
| amount: Float! | |
| tax: Float! | |
| total: Float! | |
| } |
This file contains hidden or 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
| module.exports.resolvers = { | |
| Query: { | |
| getOrders: (_, args) => { | |
| const orders = [ | |
| { | |
| id: '1977', | |
| amount: 10.0, | |
| tax: 0.5, | |
| total: 10.5, | |
| }, |
This file contains hidden or 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
| const { ApolloServer } = require('apollo-server-lambda'); | |
| const { resolvers } = require('./graphql/resolvers'); | |
| const { typeDefs } = require('./graphql/schema'); | |
| const server = new ApolloServer({ | |
| typeDefs, | |
| resolvers, | |
| }); | |
| module.exports.graphqlHandler = server.createHandler({ |