├── crypto-project
├── .firebaserc
├── public
│ ├── 1.PNG
│ ├── 2.PNG
│ ├── 3.PNG
│ ├── robots.txt
│ ├── favicon.ico
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ ├── index.html
│ └── 404.html
├── postcss.config.js
├── firebase.json
├── src
│ ├── routes
│ │ ├── Home.jsx
│ │ ├── Account.jsx
│ │ ├── Signin.jsx
│ │ ├── Signup.jsx
│ │ └── CoinPage.jsx
│ ├── index.js
│ ├── index.css
│ ├── components
│ │ ├── ThemeToggle.jsx
│ │ ├── Trending.jsx
│ │ ├── CoinSearch.jsx
│ │ ├── CoinItem.jsx
│ │ ├── SavedCoin.jsx
│ │ ├── Footer.jsx
│ │ └── Navbar.jsx
│ ├── firebase.js
│ ├── context
│ │ ├── ThemeContext.jsx
│ │ └── AuthContext.jsx
│ └── App.js
├── .env
├── .gitignore
├── .firebase
│ ├── hosting.YnVpbGQ.cache
│ └── hosting.cHVibGlj.cache
├── tailwind.config.js
├── package.json
└── README.md
├── README.md
└── .github
└── workflows
├── firebase-hosting-merge.yml
└── firebase-hosting-pull-request.yml
/crypto-project/.firebaserc:
--------------------------------------------------------------------------------
1 | {
2 | "projects": {
3 | "default": "cryptobase-bf85a"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/crypto-project/public/1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Linh777GKOG/crypto-app/HEAD/crypto-project/public/1.PNG
--------------------------------------------------------------------------------
/crypto-project/public/2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Linh777GKOG/crypto-app/HEAD/crypto-project/public/2.PNG
--------------------------------------------------------------------------------
/crypto-project/public/3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Linh777GKOG/crypto-app/HEAD/crypto-project/public/3.PNG
--------------------------------------------------------------------------------
/crypto-project/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/crypto-project/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Linh777GKOG/crypto-app/HEAD/crypto-project/public/favicon.ico
--------------------------------------------------------------------------------
/crypto-project/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Linh777GKOG/crypto-app/HEAD/crypto-project/public/logo192.png
--------------------------------------------------------------------------------
/crypto-project/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Linh777GKOG/crypto-app/HEAD/crypto-project/public/logo512.png
--------------------------------------------------------------------------------
/crypto-project/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/crypto-project/firebase.json:
--------------------------------------------------------------------------------
1 | {
2 | "hosting": {
3 | "public": "build",
4 | "ignore": [
5 | "firebase.json",
6 | "**/.*",
7 | "**/node_modules/**"
8 | ]
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | A multi-page reactjs application.
2 | 
3 |
4 | 
5 |
6 | 
7 |
--------------------------------------------------------------------------------
/crypto-project/src/routes/Home.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import CoinSearch from '../components/CoinSearch';
3 | import Trending from '../components/Trending';
4 |
5 | const Home = ({ coins }) => {
6 | return (
7 |
8 |
9 |
10 |
11 | );
12 | };
13 |
14 | export default Home;
15 |
--------------------------------------------------------------------------------
/crypto-project/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import App from './App';
5 | import { BrowserRouter } from 'react-router-dom';
6 |
7 | const root = ReactDOM.createRoot(document.getElementById('root'));
8 | root.render(
9 |
10 |
11 |
12 | );
13 |
--------------------------------------------------------------------------------
/crypto-project/.env:
--------------------------------------------------------------------------------
1 | REACT_APP_FIREBASE_API_KEY= AIzaSyAMdjD7pTkXBkGIAPB67zsPI5HU0B4A6V8
2 | REACT_APP_FIREBASE_AUTH_DOMAIN= cryptobase-bf85a.firebaseapp.com
3 | REACT_APP_FIREBASE_PROJECT_ID= cryptobase-bf85a
4 | REACT_APP_FIREBASE_STORAGE_BUCKET= cryptobase-bf85a.appspot.com
5 | REACT_APP_FIREBASE_MESSAGING_SENDER= 783998547168
6 | REACT_APP_FIREBASE_APP_ID= 1:783998547168:web:95247d78a5fc3f66a9cc85
--------------------------------------------------------------------------------
/crypto-project/.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 | .vercel
25 |
--------------------------------------------------------------------------------
/crypto-project/.firebase/hosting.YnVpbGQ.cache:
--------------------------------------------------------------------------------
1 | favicon.ico,1660296587293,eae62e993eb980ec8a25058c39d5a51feab118bd2100c4deebb2a9c158ec11f9
2 | logo192.png,1660296587293,3ee59515172ee198f3be375979df15ac5345183e656720a381b8872b2a39dc8b
3 | logo512.png,1660296587293,ee7e2f3fdb8209c4b6fd7bef6ba50d1b9dba30a25bb5c3126df057e1cb6f5331
4 | manifest.json,1660296587293,aff3449bdc238776f5d6d967f19ec491b36aed5fb7f23ccff6500736fd58494a
5 | robots.txt,1660296587293,bfe106a3fb878dc83461c86818bf74fc1bdc7f28538ba613cd3e775516ce8b49
6 |
--------------------------------------------------------------------------------
/crypto-project/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 |
--------------------------------------------------------------------------------
/.github/workflows/firebase-hosting-merge.yml:
--------------------------------------------------------------------------------
1 | # This file was auto-generated by the Firebase CLI
2 | # https://github.com/firebase/firebase-tools
3 |
4 | name: Deploy to Firebase Hosting on merge
5 | 'on':
6 | push:
7 | branches:
8 | - master
9 | jobs:
10 | build_and_deploy:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v2
14 | - uses: FirebaseExtended/action-hosting-deploy@v0
15 | with:
16 | repoToken: '${{ secrets.GITHUB_TOKEN }}'
17 | firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CRYPTOBASE_BF85A }}'
18 | channelId: live
19 | projectId: cryptobase-bf85a
20 |
--------------------------------------------------------------------------------
/crypto-project/.firebase/hosting.cHVibGlj.cache:
--------------------------------------------------------------------------------
1 | 404.html,1662471464494,daa499dd96d8229e73235345702ba32f0793f0c8e5c0d30e40e37a5872be57aa
2 | index.html,1660296587293,820c850791eeaef190f4564272c4cbe718a2f8ead4973eeacc12aa8473f3b4c5
3 | favicon.ico,1660296587293,eae62e993eb980ec8a25058c39d5a51feab118bd2100c4deebb2a9c158ec11f9
4 | logo192.png,1660296587293,3ee59515172ee198f3be375979df15ac5345183e656720a381b8872b2a39dc8b
5 | manifest.json,1660296587293,aff3449bdc238776f5d6d967f19ec491b36aed5fb7f23ccff6500736fd58494a
6 | robots.txt,1660296587293,bfe106a3fb878dc83461c86818bf74fc1bdc7f28538ba613cd3e775516ce8b49
7 | logo512.png,1660296587293,ee7e2f3fdb8209c4b6fd7bef6ba50d1b9dba30a25bb5c3126df057e1cb6f5331
8 |
--------------------------------------------------------------------------------
/.github/workflows/firebase-hosting-pull-request.yml:
--------------------------------------------------------------------------------
1 | # This file was auto-generated by the Firebase CLI
2 | # https://github.com/firebase/firebase-tools
3 |
4 | name: Deploy to Firebase Hosting on PR
5 | 'on': pull_request
6 | jobs:
7 | build_and_preview:
8 | if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - uses: FirebaseExtended/action-hosting-deploy@v0
13 | with:
14 | repoToken: '${{ secrets.GITHUB_TOKEN }}'
15 | firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CRYPTOBASE_BF85A }}'
16 | projectId: cryptobase-bf85a
17 |
--------------------------------------------------------------------------------
/crypto-project/tailwind.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | content: ['./src/**/*.{js,jsx,ts,tsx}'],
3 | darkMode: 'class',
4 | theme: {
5 | extend: {
6 | backgroundColor: {
7 | primary: 'var(--color-bg-primary)',
8 | secondary: 'var(--color-bg-secondary)',
9 | button: 'var(--color-bg-button)',
10 | },
11 | textColor: {
12 | accent: 'var(--color-text-accent)',
13 | primary: 'var(--color-text-primary)',
14 | secondary: 'var(--color-text-secondary)',
15 | btnText: 'var(--color-bg-secondary)',
16 | },
17 | borderColor: {
18 | primary: 'var(--color-bg-primary)',
19 | secondary: 'var(--color-bg-secondary)',
20 | input: 'var(--color-bg-input)',
21 | accent: 'var(--color-text-accent)',
22 | },
23 | },
24 | },
25 | plugins: [],
26 | };
27 |
--------------------------------------------------------------------------------
/crypto-project/src/index.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | :root {
6 | @apply bg-primary text-primary;
7 | }
8 |
9 | .rounded-div {
10 | @apply border border-secondary rounded-2xl shadow-xl bg-primary px-2 max-w-[1140px] w-full mx-auto;
11 | }
12 |
13 | .dark {
14 | --color-bg-primary: #2d3748;
15 | --color-bg-primary: #2d3748;
16 | --color-bg-secondary: #283141;
17 | --color-text-primary: #dbdbdb;
18 | --color-text-secondary: #e2e8f0;
19 | --color-text-accent: #81e6d9;
20 | --color-bg-input: #4a5361;
21 | --color-bg-button: #81e6d9;
22 | }
23 |
24 | .light {
25 | --color-bg-primary: #ffffff;
26 | --color-bg-secondary: #edf2f7;
27 | --color-text-primary: #2d3748;
28 | --color-text-secondary: #4a5568;
29 | --color-text-accent: #2b6cb0;
30 | --color-bg-input: #edf2f7;
31 | --color-bg-button: #2b6cb0;
32 | }
33 |
--------------------------------------------------------------------------------
/crypto-project/src/components/ThemeToggle.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 | import { HiSun, HiMoon } from 'react-icons/hi';
3 | import { ThemeContext } from '../context/ThemeContext';
4 |
5 | const ThemeToggle = () => {
6 | const { theme, setTheme } = useContext(ThemeContext);
7 |
8 | return (
9 |
10 | {theme === 'dark' ? (
11 |
setTheme(theme === 'dark' ? 'light' : 'dark')}
14 | >
15 | Light Mode
16 |
17 | ) : (
18 |
setTheme(theme === 'dark' ? 'light' : 'dark')}
21 | >
22 | Dark Mode
23 |
24 | )}
25 |
26 | );
27 | };
28 |
29 | export default ThemeToggle;
30 |
--------------------------------------------------------------------------------
/crypto-project/src/firebase.js:
--------------------------------------------------------------------------------
1 | // Import the functions you need from the SDKs you need
2 | import { initializeApp } from 'firebase/app';
3 | import { getAuth } from 'firebase/auth';
4 | import { getFirestore } from 'firebase/firestore';
5 | // TODO: Add SDKs for Firebase products that you want to use
6 | // https://firebase.google.com/docs/web/setup#available-libraries
7 |
8 | // Your web app's Firebase configuration
9 | const firebaseConfig = {
10 | apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
11 | authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
12 | projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
13 | storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
14 | messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER,
15 | appId: process.env.REACT_APP_FIREBASE_APP_ID,
16 | };
17 |
18 | // Initialize Firebase
19 | const app = initializeApp(firebaseConfig);
20 | export const auth = getAuth(app);
21 | export const db = getFirestore(app);
22 |
23 | export default app;
24 |
--------------------------------------------------------------------------------
/crypto-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "crypto-project",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.14.1",
7 | "@testing-library/react": "^13.0.0",
8 | "@testing-library/user-event": "^13.2.1",
9 | "axios": "^0.27.2",
10 | "dompurify": "^2.3.8",
11 | "firebase": "^9.8.2",
12 | "react": "^18.1.0",
13 | "react-dom": "^18.1.0",
14 | "react-icons": "^4.3.1",
15 | "react-router-dom": "^6.3.0",
16 | "react-scripts": "5.0.1",
17 | "react-sparklines": "^1.7.0",
18 | "web-vitals": "^2.1.0"
19 | },
20 | "scripts": {
21 | "start": "react-scripts start",
22 | "build": "react-scripts build",
23 | "test": "react-scripts test",
24 | "eject": "react-scripts eject"
25 | },
26 | "eslintConfig": {
27 | "extends": [
28 | "react-app",
29 | "react-app/jest"
30 | ]
31 | },
32 | "browserslist": {
33 | "production": [
34 | ">0.2%",
35 | "not dead",
36 | "not op_mini all"
37 | ],
38 | "development": [
39 | "last 1 chrome version",
40 | "last 1 firefox version",
41 | "last 1 safari version"
42 | ]
43 | },
44 | "devDependencies": {
45 | "autoprefixer": "^10.4.7",
46 | "postcss": "^8.4.14",
47 | "tailwindcss": "^3.0.24"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/crypto-project/src/context/ThemeContext.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect, createContext } from 'react';
2 |
3 | const getInitialTheme = () => {
4 | if (typeof window !== 'undefined' && window.localStorage) {
5 | const storedPrefs = window.localStorage.getItem('color-theme');
6 | if (typeof storedPrefs === 'string') {
7 | return storedPrefs;
8 | }
9 |
10 | const userMedia = window.matchMedia('(prefers-color-scheme: dark)');
11 | if (userMedia.matches) {
12 | return 'dark';
13 | }
14 | }
15 | return 'light';
16 | };
17 |
18 | export const ThemeContext = createContext();
19 |
20 | export const ThemeProvider = ({ initialTheme, children }) => {
21 | const [theme, setTheme] = useState(getInitialTheme);
22 |
23 | const rawSetTheme = (theme) => {
24 | const root = window.document.documentElement;
25 | const isDark = theme === 'dark';
26 |
27 | root.classList.remove(isDark ? 'light' : 'dark');
28 | root.classList.add(theme);
29 |
30 | localStorage.setItem('color-theme', theme);
31 | };
32 |
33 | if (initialTheme) {
34 | rawSetTheme(initialTheme);
35 | }
36 |
37 | useEffect(() => {
38 | rawSetTheme(theme);
39 | }, [theme]);
40 |
41 | return (
42 |
43 | {children}
44 |
45 | );
46 | };
47 |
--------------------------------------------------------------------------------
/crypto-project/src/context/AuthContext.jsx:
--------------------------------------------------------------------------------
1 | import { createContext, useContext, useState, useEffect } from 'react';
2 | import { auth, db } from '../firebase';
3 | import {
4 | createUserWithEmailAndPassword,
5 | signInWithEmailAndPassword,
6 | signOut,
7 | onAuthStateChanged,
8 | } from 'firebase/auth';
9 |
10 | import { doc, setDoc } from 'firebase/firestore';
11 |
12 | const UserContext = createContext();
13 |
14 | export const AuthContextProvider = ({ children }) => {
15 | const [user, setUser] = useState({});
16 |
17 | const signUp = (email, password) => {
18 | createUserWithEmailAndPassword(auth, email, password);
19 | return setDoc(doc(db, 'users', email), {
20 | watchList: [],
21 | });
22 | };
23 | const signIn = (email, password) => {
24 | return signInWithEmailAndPassword(auth, email, password);
25 | };
26 |
27 | const logout = () => {
28 | return signOut(auth);
29 | };
30 |
31 | useEffect(() => {
32 | const unsubscribe = onAuthStateChanged(auth, (currentUser) => {
33 | setUser(currentUser);
34 | });
35 | return () => {
36 | unsubscribe();
37 | };
38 | }, []);
39 |
40 | return (
41 |
42 | {children}
43 |
44 | );
45 | };
46 |
47 | export const UserAuth = () => {
48 | return useContext(UserContext);
49 | };
50 |
--------------------------------------------------------------------------------
/crypto-project/src/routes/Account.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import SavedCoin from '../components/SavedCoin';
3 | import { UserAuth } from '../context/AuthContext';
4 | import { Navigate, useNavigate } from 'react-router-dom';
5 |
6 | const Account = () => {
7 | const { user, logout } = UserAuth();
8 | const navigate = useNavigate();
9 |
10 | const handleSignOut = async () => {
11 | try {
12 | await logout();
13 | navigate('/');
14 | } catch (e) {
15 | console.log(e.message);
16 | }
17 | };
18 |
19 | if (user) {
20 | return (
21 |
22 |
23 |
24 |
Account
25 |
26 |
Welcome, {user?.email}
27 |
28 |
29 |
30 |
34 | Sign Out
35 |
36 |
37 |
38 |
39 |
40 |
Watch List
41 |
42 |
43 |
44 |
45 | );
46 | } else {
47 | return ;
48 | }
49 | };
50 |
51 | export default Account;
52 |
--------------------------------------------------------------------------------
/crypto-project/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from 'react';
2 | import { Route, Routes } from 'react-router-dom';
3 | import Navbar from './components/Navbar';
4 | import { ThemeProvider } from './context/ThemeContext';
5 | import Home from './routes/Home';
6 | import Signin from './routes/Signin';
7 | import Signup from './routes/Signup';
8 | import Account from './routes/Account';
9 | import axios from 'axios';
10 | import CoinPage from './routes/CoinPage';
11 | import Footer from './components/Footer';
12 | import { AuthContextProvider } from './context/AuthContext';
13 |
14 | function App() {
15 | const [coins, setCoins] = useState([]);
16 |
17 | const url =
18 | 'https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=10&page=1&sparkline=true';
19 |
20 | useEffect(() => {
21 | axios.get(url).then((response) => {
22 | setCoins(response.data);
23 | // console.log(response.data)
24 | });
25 | }, [url]);
26 |
27 | return (
28 |
29 |
30 |
31 |
32 | } />
33 | } />
34 | } />
35 | } />
36 | }>
37 |
38 |
39 |
40 |
41 |
42 |
43 | );
44 | }
45 |
46 | export default App;
47 |
--------------------------------------------------------------------------------
/crypto-project/src/components/Trending.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 | import axios from 'axios';
3 |
4 | const Trending = () => {
5 | const [trending, setTrending] = useState([]);
6 |
7 | const url = 'https://api.coingecko.com/api/v3/search/trending';
8 |
9 | useEffect(() => {
10 | axios.get(url).then((response) => {
11 | setTrending(response.data.coins);
12 | // console.log(response.data.coins)
13 | });
14 | }, []);
15 |
16 | return (
17 |
18 |
Trending Coins
19 |
20 | {trending.map((coin, idx) => (
21 |
25 |
26 |
27 |
32 |
33 |
{coin.item.name}
34 |
{coin.item.symbol}
35 |
36 |
37 |
38 |
43 |
{coin.item.price_btc.toFixed(7)}
44 |
45 |
46 |
47 | ))}
48 |
49 |
50 | );
51 | };
52 |
53 | export default Trending;
54 |
--------------------------------------------------------------------------------
/crypto-project/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 | You need to enable JavaScript to run this app.
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/crypto-project/src/components/CoinSearch.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import CoinItem from './CoinItem';
3 |
4 | const CoinSearch = ({ coins }) => {
5 | const [searchText, setSearchText] = useState('');
6 | console.log(coins);
7 | return (
8 |
9 |
10 |
Search Crypto
11 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | #
26 | Coin
27 |
28 | Price
29 | 24h
30 | 24h Volume
31 | Mkt
32 | Last 7 Days
33 |
34 |
35 |
36 | {coins
37 | .filter((value) => {
38 | if (searchText === '') {
39 | return value;
40 | } else if (
41 | value.name.toLowerCase().includes(searchText.toLowerCase())
42 | ) {
43 | return value;
44 | }
45 | })
46 | .map((coin) => (
47 |
48 | ))}
49 |
50 |
51 |
52 | );
53 | };
54 |
55 | export default CoinSearch;
56 |
--------------------------------------------------------------------------------
/crypto-project/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Page Not Found
7 |
8 |
23 |
24 |
25 |
26 |
404
27 |
Page Not Found
28 |
The specified file was not found on this website. Please check the URL for mistakes and try again.
29 |
Why am I seeing this?
30 |
This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html file in your project's configured public directory.
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/crypto-project/src/routes/Signin.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { AiFillLock, AiOutlineMail } from 'react-icons/ai';
3 | import { Link, useNavigate } from 'react-router-dom';
4 | import { signIn, UserAuth } from '../context/AuthContext';
5 |
6 | const Signin = () => {
7 | const [email, setEmail] = useState('');
8 | const [password, setPassword] = useState('');
9 | const [error, setError] = useState('');
10 | const navigate = useNavigate();
11 | const { signIn } = UserAuth();
12 |
13 | const handleSubmit = async (e) => {
14 | e.preventDefault();
15 | setError('');
16 | try {
17 | await signIn(email, password);
18 | navigate('/account');
19 | } catch (e) {
20 | setError(e.message);
21 | console.log(e.message);
22 | }
23 | };
24 |
25 | return (
26 |
27 |
28 |
Sign In
29 |
56 |
57 | Don't have an account?{' '}
58 |
59 | Sign up
60 |
61 |
62 |
63 |
64 | );
65 | };
66 |
67 | export default Signin;
68 |
--------------------------------------------------------------------------------
/crypto-project/src/routes/Signup.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { AiFillLock, AiOutlineMail } from 'react-icons/ai';
3 | import { Link, useNavigate } from 'react-router-dom';
4 | import { UserAuth } from '../context/AuthContext';
5 |
6 | const Signup = () => {
7 | const [email, setEmail] = useState('');
8 | const [password, setPassword] = useState('');
9 | const [error, setError] = useState('');
10 | const navigate = useNavigate();
11 | const { signUp } = UserAuth();
12 |
13 | const handleSubmit = async (e) => {
14 | e.preventDefault();
15 | setError('');
16 | try {
17 | await signUp(email, password);
18 | navigate('/account');
19 | } catch (e) {
20 | setError(e.message);
21 | console.log(e.message);
22 | }
23 | };
24 |
25 | return (
26 |
27 |
28 |
Sign Up
29 | {error ?
{error}
: null}
30 |
57 |
58 | Already have an account?{' '}
59 |
60 | Sign in
61 |
62 |
63 |
64 |
65 | );
66 | };
67 |
68 | export default Signup;
69 |
--------------------------------------------------------------------------------
/crypto-project/src/components/CoinItem.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { AiFillStar, AiOutlineStar } from 'react-icons/ai';
3 | import { Link } from 'react-router-dom';
4 | import { Sparklines, SparklinesLine } from 'react-sparklines';
5 | import { UserAuth } from '../context/AuthContext';
6 | import { db } from '../firebase';
7 | import { arrayUnion, doc, updateDoc } from 'firebase/firestore';
8 |
9 | const CoinItem = ({ coin }) => {
10 | const [savedCoin, setSavedCoin] = useState(false);
11 | const { user } = UserAuth();
12 |
13 | const coinPath = doc(db, 'users', `${user?.email}`);
14 | const saveCoin = async () => {
15 | if (user?.email) {
16 | setSavedCoin(true);
17 | await updateDoc(coinPath, {
18 | watchList: arrayUnion({
19 | id: coin.id,
20 | name: coin.name,
21 | image: coin.image,
22 | rank: coin.market_cap_rank,
23 | symbol: coin.symbol,
24 | }),
25 | });
26 | } else {
27 | alert('Please sign in to save a coin to your watch list');
28 | }
29 | };
30 |
31 | return (
32 |
33 |
34 | {savedCoin ? : }
35 |
36 | {coin.market_cap_rank}
37 |
38 |
39 |
40 |
45 |
{coin.name}
46 |
47 |
48 |
49 | {coin.symbol.toUpperCase()}
50 | ${coin.current_price.toLocaleString()}
51 |
52 | {coin.price_change_percentage_24h > 0 ? (
53 |
54 | {coin.price_change_percentage_24h.toFixed(2)}%
55 |
56 | ) : (
57 |
58 | {coin.price_change_percentage_24h.toFixed(2)}%
59 |
60 | )}
61 |
62 |
63 | ${coin.total_volume.toLocaleString()}
64 |
65 |
66 | ${coin.market_cap.toLocaleString()}
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | );
75 | };
76 |
77 | export default CoinItem;
78 |
--------------------------------------------------------------------------------
/crypto-project/src/components/SavedCoin.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from 'react';
2 | import { AiOutlineClose } from 'react-icons/ai';
3 | import { Link } from 'react-router-dom';
4 | import { doc, onSnapshot, updateDoc } from 'firebase/firestore';
5 | import { db } from '../firebase';
6 | import { UserAuth } from '../context/AuthContext';
7 |
8 | const SavedCoin = () => {
9 | const [coins, setCoins] = useState([]);
10 | const { user } = UserAuth();
11 |
12 | useEffect(() => {
13 | onSnapshot(doc(db, 'users', `${user?.email}`), (doc) => {
14 | setCoins(doc.data()?.watchList);
15 | });
16 | }, [user?.email]);
17 |
18 | const coinPath = doc(db, 'users', `${user?.email}`);
19 | const deleteCoin = async (passedid) => {
20 | try {
21 | const result = coins.filter((item) => item.id !== passedid);
22 | await updateDoc(coinPath, {
23 | watchList: result,
24 | });
25 | } catch (e) {
26 | console.log(e.message);
27 | }
28 | };
29 |
30 | return (
31 |
32 | {coins?.length === 0 ? (
33 |
34 | You don't have any coins saved. Please save a coin to add it to your
35 | watch list. Click here to search coins.
36 |
37 | ) : (
38 |
39 |
40 |
41 | Rank #
42 | Coin
43 | Remove
44 |
45 |
46 |
47 | {coins?.map((coin) => (
48 |
49 | {coin?.rank}
50 |
51 |
52 |
53 |
54 |
55 |
{coin?.name}
56 |
57 | {coin?.symbol.toUpperCase()}
58 |
59 |
60 |
61 |
62 |
63 |
64 | deleteCoin(coin.id)}
66 | className="cursor-pointer"
67 | />
68 |
69 |
70 | ))}
71 |
72 |
73 | )}
74 |
75 | );
76 | };
77 |
78 | export default SavedCoin;
79 |
--------------------------------------------------------------------------------
/crypto-project/src/components/Footer.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { AiOutlineInstagram } from 'react-icons/ai';
3 | import {
4 | FaFacebookF,
5 | FaGit,
6 | FaGithub,
7 | FaTiktok,
8 | FaTwitter,
9 | } from 'react-icons/fa';
10 | import ThemeToggle from './ThemeToggle';
11 |
12 | const Footer = () => {
13 | return (
14 |
15 |
16 |
17 |
18 |
Support
19 |
20 | Help Center
21 | Contact Us
22 | API Status
23 | Documentation
24 |
25 |
26 |
27 |
Info
28 |
29 | About Us
30 | Careers
31 | Invest
32 | Legal
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | Sign up for crypto news
44 |
45 |
46 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
Powered by Coin Gecko
69 |
70 | );
71 | };
72 |
73 | export default Footer;
74 |
--------------------------------------------------------------------------------
/crypto-project/src/components/Navbar.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { Link, useNavigate } from 'react-router-dom';
3 | import ThemeToggle from './ThemeToggle';
4 | import { AiOutlineClose, AiOutlineMenu } from 'react-icons/ai';
5 | import { UserAuth } from '../context/AuthContext';
6 |
7 | const Navbar = () => {
8 | const [nav, setNav] = useState(false);
9 | const { user, logout } = UserAuth();
10 | const navigate = useNavigate();
11 |
12 | const handleNav = () => {
13 | setNav(nav);
14 | };
15 |
16 | const handleSignOut = async () => {
17 | try {
18 | await logout();
19 | navigate('/');
20 | } catch (e) {
21 | console.log(e.message);
22 | }
23 | };
24 |
25 | return (
26 |
27 |
28 |
Cryptobase
29 |
30 |
31 |
32 |
33 |
34 | {user?.email ? (
35 |
36 |
37 | Account
38 |
39 | Sign out
40 |
41 | ) : (
42 |
43 |
44 | Sign In
45 |
46 |
50 | Sign Up
51 |
52 |
53 | )}
54 |
55 | {/* Menu Icon */}
56 |
59 |
60 | {/* Mobile Menu */}
61 |
68 |
69 |
70 | Home
71 |
72 |
73 | Account
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
85 | Sign In
86 |
87 |
88 |
89 |
90 | Sign Up
91 |
92 |
93 |
94 |
95 |
96 | );
97 | };
98 |
99 | export default Navbar;
100 |
--------------------------------------------------------------------------------
/crypto-project/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 your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may 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 |
--------------------------------------------------------------------------------
/crypto-project/src/routes/CoinPage.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 | import axios from 'axios';
3 | import { Sparklines, SparklinesLine } from 'react-sparklines';
4 | import { FaTwitter, FaFacebook, FaReddit, FaGithub } from 'react-icons/fa';
5 | import DOMPurify from 'dompurify';
6 | import { useParams } from 'react-router-dom';
7 |
8 | const CoinPage = () => {
9 | const [coin, setCoin] = useState({});
10 | const params = useParams();
11 |
12 | const url = `https://api.coingecko.com/api/v3/coins/${params.coinId}?localization=false&sparkline=true`;
13 |
14 | useEffect(() => {
15 | axios.get(url).then((response) => {
16 | setCoin(response.data);
17 | console.log(response.data);
18 | });
19 | }, [url]);
20 |
21 | return (
22 |
23 |
24 |
25 |
26 |
{coin?.name} price
27 |
({coin.symbol?.toUpperCase()} / USD)
28 |
29 |
30 |
31 |
32 |
33 |
34 | {coin.market_data?.current_price ? (
35 |
36 | ${coin.market_data.current_price.usd.toLocaleString()}
37 |
38 | ) : null}
39 |
7 Day
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
Market Cap
49 | {coin.market_data?.market_cap ? (
50 |
${coin.market_data.market_cap.usd.toLocaleString()}
51 | ) : null}
52 |
53 |
54 |
Volume (24h)
55 | {coin.market_data?.market_cap ? (
56 |
${coin.market_data.total_volume.usd.toLocaleString()}
57 | ) : null}
58 |
59 |
60 |
61 |
62 |
63 |
24h High
64 | {coin.market_data?.high_24h ? (
65 |
${coin.market_data.high_24h.usd.toLocaleString()}
66 | ) : null}
67 |
68 |
69 |
24h Low
70 | {coin.market_data?.low_24h ? (
71 |
${coin.market_data.low_24h.usd.toLocaleString()}
72 | ) : null}
73 |
74 |
75 |
76 |
77 |
78 |
Market Stats
79 |
80 |
81 |
Market Rank
82 | {coin.market_cap_rank}
83 |
84 |
85 |
Hashing Algorithm
86 | {coin.hashing_algorithm ?
{coin.hashing_algorithm}
: null}
87 |
88 |
89 |
Trust Score
90 | {coin.tickers ?
{coin.liquidity_score.toFixed(2)}
: null}
91 |
92 |
93 |
94 |
95 |
96 |
Price Change (24h)
97 | {coin.market_data ? (
98 |
99 | {coin.market_data.price_change_percentage_24h.toFixed(2)}%
100 |
101 | ) : null}
102 |
103 |
104 |
Price Change (7d)
105 | {coin.market_data ? (
106 |
{coin.market_data.price_change_percentage_7d.toFixed(2)}%
107 | ) : null}
108 |
109 |
110 |
Price Change (14d)
111 | {coin.market_data ? (
112 |
113 | {coin.market_data.price_change_percentage_14d.toFixed(2)}%
114 |
115 | ) : null}
116 |
117 |
118 |
119 |
120 |
Price Change (30d)
121 | {coin.market_data ? (
122 |
123 | {coin.market_data.price_change_percentage_30d.toFixed(2)}%
124 |
125 | ) : null}
126 |
127 |
128 |
Price Change (60d)
129 | {coin.market_data ? (
130 |
131 | {coin.market_data.price_change_percentage_60d.toFixed(2)}%
132 |
133 | ) : null}
134 |
135 |
136 |
Price Change (1y)
137 | {coin.market_data ? (
138 |
{coin.market_data.price_change_percentage_1y.toFixed(2)}%
139 | ) : null}
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 | {/* Description */}
152 |
153 |
About {coin.name}
154 |
161 |
162 |
163 | );
164 | };
165 |
166 | export default CoinPage;
167 |
--------------------------------------------------------------------------------