├── public ├── favicon.ico ├── logo192.png ├── logo512.png ├── robots.txt ├── index.html └── manifest.json ├── src ├── setupTests.js ├── App.test.js ├── index.css ├── reportWebVitals.js ├── Tiles.css ├── index.js ├── Tile.js ├── Tiles.js └── logo.svg ├── .gitignore ├── package.json ├── README.md └── .eslintcache /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkmru/stocks/master/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkmru/stocks/master/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkmru/stocks/master/public/logo512.png -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | stocks 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": "./", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /src/Tiles.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './index.css'; 3 | import ReactDOM from 'react-dom'; 4 | import {BrowserRouter, Route} from 'react-router-dom'; 5 | import Tiles from './Tiles'; 6 | import reportWebVitals from './reportWebVitals'; 7 | 8 | ReactDOM.render( 9 | 10 | 11 | 12 | 13 | , 14 | document.getElementById('root') 15 | ); 16 | 17 | // If you want to start measuring performance in your app, pass a function 18 | // to log results (for example: reportWebVitals(console.log)) 19 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 20 | reportWebVitals(); 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stocks-viewer", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.4", 7 | "@testing-library/react": "^11.1.0", 8 | "@testing-library/user-event": "^12.1.10", 9 | "jquery": "^3.5.1", 10 | "react": "^17.0.1", 11 | "react-dom": "^17.0.1", 12 | "react-router-dom": "^5.2.0", 13 | "react-scripts": "4.0.1", 14 | "web-vitals": "^0.2.4" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject", 21 | "predeploy": "react-scripts build", 22 | "deploy": "gh-pages -d build" 23 | }, 24 | "homepage": "https://tkmru.dev/stocks/", 25 | "eslintConfig": { 26 | "extends": [ 27 | "react-app", 28 | "react-app/jest" 29 | ] 30 | }, 31 | "browserslist": { 32 | "production": [ 33 | ">0.2%", 34 | "not dead", 35 | "not op_mini all" 36 | ], 37 | "development": [ 38 | "last 1 chrome version", 39 | "last 1 firefox version", 40 | "last 1 safari version" 41 | ] 42 | }, 43 | "devDependencies": { 44 | "gh-pages": "^3.1.0" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Tile.js: -------------------------------------------------------------------------------- 1 | //import logo from './logo.svg'; 2 | //import './App.css'; 3 | 4 | function Tile(props) { 5 | return ( 6 |
7 |
8 |

{props.result['longName']}

9 |

{props.result['symbol']}, {props.result['fullExchangeName']}({props.result['marketState']})

10 |

Price: 11 |

12 | {props.result['regularMarketPrice']}{props.result['currency']} 13 |
14 |

15 |

Target Price: 16 |

17 | High: {props.result['targetPriceHigh']}{props.result['currency']}
18 | Low: {props.result['targetPriceLow']}{props.result['currency']} 19 |
20 |

21 |

Trend: 22 |

23 | Mid Term: {props.result['pageViews']['midTermTrend']}
24 | Long Term: {props.result['pageViews']['longTermTrend']}
25 | Short Term: {props.result['pageViews']['shortTermTrend']}
26 |
27 |

28 |
29 |
); 30 | } 31 | 32 | export default Tile; 33 | -------------------------------------------------------------------------------- /src/Tiles.js: -------------------------------------------------------------------------------- 1 | //import logo from './logo.svg'; 2 | import './Tiles.css'; 3 | import Tile from './Tile.js'; 4 | import { withRouter } from 'react-router-dom'; 5 | import React, { useState, useEffect } from 'react'; 6 | 7 | var $ = require('jquery'); 8 | 9 | function Tiles(props) { 10 | const symbolArgs = new URLSearchParams(props.location.search).get('symbols'); 11 | const [error, setError] = useState(null); 12 | const [isLoaded, setIsLoaded] = useState(false); 13 | const [result, setResult] = useState([]); 14 | const settings = { 15 | "async": true, 16 | "crossDomain": true, 17 | "url": "https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/v2/get-quotes?symbols="+symbolArgs, 18 | "method": "GET", 19 | "headers": { 20 | "x-rapidapi-host": "apidojo-yahoo-finance-v1.p.rapidapi.com", 21 | "x-rapidapi-key": "de40c01ca1mshebfd6541116a023p185831jsn793176dff3dc" 22 | } 23 | } 24 | 25 | useEffect(() => { 26 | $.ajax(settings).done(function (response) { 27 | setIsLoaded(true); 28 | console.log(response); 29 | setResult(response['quoteResponse']['result']); 30 | }).fail(function (error) { 31 | setIsLoaded(true); 32 | setError(error); 33 | }); 34 | }, []); 35 | 36 | if (error) { 37 | return
Error: {error.message}
; 38 | } else if (!isLoaded) { 39 | return
Loading...
; 40 | } else { 41 | let resultRows = []; 42 | for (let i = 0; i < result.length; i=i+3) { 43 | let end = i + 3; 44 | if (end > result.length) { 45 | end = result.length 46 | } 47 | resultRows.push( 48 | result.slice(i, end) 49 | ) 50 | } 51 | console.log(result); 52 | return ( 53 |
54 | { 55 | resultRows.map((results) => { 56 | return ( 57 |
58 | { 59 | results.map((result) => { 60 | return () 61 | }) 62 | } 63 |
64 | )}) 65 | } 66 |
67 | ); 68 | } 69 | } 70 | 71 | export default withRouter(Tiles); 72 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `yarn start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `yarn test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `yarn build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `yarn eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `yarn build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /.eslintcache: -------------------------------------------------------------------------------- 1 | [{"/Users/tkmru/code/stocks-viewer/src/index.js":"1","/Users/tkmru/code/stocks-viewer/src/Tiles.js":"2","/Users/tkmru/code/stocks-viewer/src/reportWebVitals.js":"3","/Users/tkmru/code/stocks-viewer/src/Tile.js":"4"},{"size":670,"mtime":1606553513626,"results":"5","hashOfConfig":"6"},{"size":1865,"mtime":1606551580560,"results":"7","hashOfConfig":"6"},{"size":362,"mtime":1606197201751,"results":"8","hashOfConfig":"6"},{"size":1159,"mtime":1606561835317,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"12"},"10qv6lr",{"filePath":"13","messages":"14","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"15"},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/tkmru/code/stocks-viewer/src/index.js",[],["20","21"],"/Users/tkmru/code/stocks-viewer/src/Tiles.js",["22"],"//import logo from './logo.svg';\nimport './Tiles.css';\nimport Tile from './Tile.js';\nimport { withRouter } from 'react-router-dom';\nimport React, { useState, useEffect } from 'react';\n\nvar $ = require('jquery');\n\nfunction Tiles(props) {\n const symbolArgs = new URLSearchParams(props.location.search).get('symbols');\n const [error, setError] = useState(null);\n const [isLoaded, setIsLoaded] = useState(false);\n const [result, setResult] = useState([]);\n const settings = {\n \"async\": true,\n \"crossDomain\": true,\n \"url\": \"https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/v2/get-quotes?symbols=\"+symbolArgs,\n \"method\": \"GET\",\n \"headers\": {\n \"x-rapidapi-host\": \"apidojo-yahoo-finance-v1.p.rapidapi.com\",\n \"x-rapidapi-key\": \"de40c01ca1mshebfd6541116a023p185831jsn793176dff3dc\"\n }\n }\n \n useEffect(() => {\n $.ajax(settings).done(function (response) {\n setIsLoaded(true);\n console.log(response);\n setResult(response['quoteResponse']['result']);\n }).fail(function (error) {\n setIsLoaded(true);\n setError(error);\n });\n }, []);\n\n if (error) {\n return
Error: {error.message}
;\n } else if (!isLoaded) {\n return
Loading...
;\n } else {\n let resultRows = [];\n for (let i = 0; i < result.length; i=i+3) {\n let end = i + 3;\n if (end > result.length) {\n end = result.length\n }\n resultRows.push(\n result.slice(i, end)\n )\n }\n console.log(result);\n return (\n
\n {\n resultRows.map((results) => {\n return (\n
\n { \n results.map((result) => {\n return ()\n }) \n }\n
\n )})\n }\n
\n );\n }\n}\n\nexport default withRouter(Tiles);\n","/Users/tkmru/code/stocks-viewer/src/reportWebVitals.js",[],"/Users/tkmru/code/stocks-viewer/src/Tile.js",[],{"ruleId":"23","replacedBy":"24"},{"ruleId":"25","replacedBy":"26"},{"ruleId":"27","severity":1,"message":"28","line":34,"column":6,"nodeType":"29","endLine":34,"endColumn":8,"suggestions":"30"},"no-native-reassign",["31"],"no-negated-in-lhs",["32"],"react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'settings'. Either include it or remove the dependency array.","ArrayExpression",["33"],"no-global-assign","no-unsafe-negation",{"desc":"34","fix":"35"},"Update the dependencies array to be: [settings]",{"range":"36","text":"37"},[1088,1090],"[settings]"] --------------------------------------------------------------------------------