@@ -2,17 +2,11 @@ import React, { useState, useEffect } from 'react';
2
2
import { motion } from 'framer-motion' ;
3
3
import { AreaChart , Card , Title , Badge , TabGroup , TabList , Tab } from '@tremor/react' ;
4
4
import { HiTrendingUp , HiTrendingDown , HiCurrencyDollar , HiChartPie , HiClock } from 'react-icons/hi' ;
5
- import axios from 'axios' ;
6
5
import PortfolioAnalytics from '../components/dashboard/PortfolioAnalytics' ;
7
6
import StockDetail from '../components/dashboard/StockDetail' ;
7
+ import api from '../services/api' ;
8
8
9
- const API_BASE_URL = import . meta. env . VITE_API_BASE_URL || 'https://portfolio-tracker-backend-y7ne.onrender.com/api' ;
10
9
11
- // Create axios instance with base URL
12
- const api = axios . create ( {
13
- baseURL : API_BASE_URL ,
14
- timeout : 10000
15
- } ) ;
16
10
17
11
const containerVariants = {
18
12
hidden : { opacity : 0 } ,
@@ -128,7 +122,7 @@ export default function Dashboard({ theme: propTheme }) {
128
122
129
123
const fetchStocks = async ( ) => {
130
124
try {
131
- console . log ( 'Fetching stocks from:' , API_BASE_URL ) ;
125
+ console . log ( 'Fetching stocks from API' ) ;
132
126
const response = await api . get ( '/stocks' ) ;
133
127
console . log ( 'Stocks fetched successfully:' , response . data ) ;
134
128
setStocks ( response . data ) ;
@@ -481,19 +475,67 @@ export default function Dashboard({ theme: propTheme }) {
481
475
< div className = "flex justify-between items-center mb-4" >
482
476
< TabGroup
483
477
defaultIndex = { 1 }
484
- className = "mb-4"
478
+ className = "mb-4 [&>div]:border-none "
485
479
onIndexChange = { ( index ) => {
486
480
const periods = [ '1D' , '1W' , '1M' , '3M' , '1Y' , 'ALL' ] ;
487
481
setSelectedPeriod ( periods [ index ] ) ;
488
482
} }
489
483
>
490
484
< TabList className = { theme === 'dark' ? 'text-white' : '' } >
491
- < Tab className = { theme === 'dark' ? 'text-white hover:text-blue-400' : '' } > 1D</ Tab >
492
- < Tab className = { theme === 'dark' ? 'text-white hover:text-blue-400' : '' } > 1W</ Tab >
493
- < Tab className = { theme === 'dark' ? 'text-white hover:text-blue-400' : '' } > 1M</ Tab >
494
- < Tab className = { theme === 'dark' ? 'text-white hover:text-blue-400' : '' } > 3M</ Tab >
495
- < Tab className = { theme === 'dark' ? 'text-white hover:text-blue-400' : '' } > 1Y</ Tab >
496
- < Tab className = { theme === 'dark' ? 'text-white hover:text-blue-400' : '' } > ALL</ Tab >
485
+ < Tab className = { `px-3 py-1 text-sm font-medium transition-all ${
486
+ selectedPeriod === '1D'
487
+ ? theme === 'dark'
488
+ ? 'text-blue-400 font-semibold'
489
+ : 'text-blue-600 font-semibold'
490
+ : theme === 'dark'
491
+ ? 'text-gray-300 hover:text-white'
492
+ : 'text-gray-600 hover:text-gray-900'
493
+ } `} > 1D</ Tab >
494
+ < Tab className = { `px-3 py-1 text-sm font-medium transition-all ${
495
+ selectedPeriod === '1W'
496
+ ? theme === 'dark'
497
+ ? 'text-blue-400 font-semibold'
498
+ : 'text-blue-600 font-semibold'
499
+ : theme === 'dark'
500
+ ? 'text-gray-300 hover:text-white'
501
+ : 'text-gray-600 hover:text-gray-900'
502
+ } `} > 1W</ Tab >
503
+ < Tab className = { `px-3 py-1 text-sm font-medium transition-all ${
504
+ selectedPeriod === '1M'
505
+ ? theme === 'dark'
506
+ ? 'text-blue-400 font-semibold'
507
+ : 'text-blue-600 font-semibold'
508
+ : theme === 'dark'
509
+ ? 'text-gray-300 hover:text-white'
510
+ : 'text-gray-600 hover:text-gray-900'
511
+ } `} > 1M</ Tab >
512
+ < Tab className = { `px-3 py-1 text-sm font-medium transition-all ${
513
+ selectedPeriod === '3M'
514
+ ? theme === 'dark'
515
+ ? 'text-blue-400 font-semibold'
516
+ : 'text-blue-600 font-semibold'
517
+ : theme === 'dark'
518
+ ? 'text-gray-300 hover:text-white'
519
+ : 'text-gray-600 hover:text-gray-900'
520
+ } `} > 3M</ Tab >
521
+ < Tab className = { `px-3 py-1 text-sm font-medium transition-all ${
522
+ selectedPeriod === '1Y'
523
+ ? theme === 'dark'
524
+ ? 'text-blue-400 font-semibold'
525
+ : 'text-blue-600 font-semibold'
526
+ : theme === 'dark'
527
+ ? 'text-gray-300 hover:text-white'
528
+ : 'text-gray-600 hover:text-gray-900'
529
+ } `} > 1Y</ Tab >
530
+ < Tab className = { `px-3 py-1 text-sm font-medium transition-all ${
531
+ selectedPeriod === 'ALL'
532
+ ? theme === 'dark'
533
+ ? 'text-blue-400 font-semibold'
534
+ : 'text-blue-600 font-semibold'
535
+ : theme === 'dark'
536
+ ? 'text-gray-300 hover:text-white'
537
+ : 'text-gray-600 hover:text-gray-900'
538
+ } `} > ALL</ Tab >
497
539
</ TabList >
498
540
</ TabGroup >
499
541
< div className = { `flex flex-col items-end ${
0 commit comments