diff --git a/src/components/DashboardComponent/DashboadComponent.jsx b/src/components/DashboardComponent/DashboadComponent.jsx index 1332363..6e58a12 100644 --- a/src/components/DashboardComponent/DashboadComponent.jsx +++ b/src/components/DashboardComponent/DashboadComponent.jsx @@ -1,71 +1,69 @@ -import React, { useEffect, useState } from 'react'; -import Select from 'react-select'; -import styles from './DashboardComponent.module.css'; -import { useDispatch } from 'react-redux'; -import { fetchTransactionsSummary } from '../../redux/transactions/operations'; +// import React, { useEffect, useState } from 'react'; +// import Select from 'react-select'; +// import styles from './DashboardComponent.module.css'; +// import { useDispatch } from 'react-redux'; +// import { fetchTransactionsSummary } from '../../redux/transactions/operations'; -const StatisticsDashboard = () => { - const dispatch = useDispatch(); - const [selectedMonth, setSelectedMonth] = useState({ - value: 3, - label: 'March', - }); - const [selectedYear, setSelectedYear] = useState({ - value: 2024, - label: '2024', - }); +// const StatisticsDashboard = () => { +// const dispatch = useDispatch(); +// const [selectedMonth, setSelectedMonth] = useState({ +// value: 3, +// label: 'March', +// }); +// const [selectedYear, setSelectedYear] = useState({ +// value: 2024, +// label: '2024', +// }); - const onMonthChange = month => setSelectedMonth(month); - const onYearClick = year => setSelectedYear(year); +// const onMonthChange = month => setSelectedMonth(month); +// const onYearClick = year => setSelectedYear(year); - const optionsYears = [ - { value: 2024, label: '2024' }, - { value: 2023, label: '2023' }, - { value: 2022, label: '2022' }, - { value: 2021, label: '2021' }, - { value: 2019, label: '2019' }, - { value: 2018, label: '2018' }, - { value: 2017, label: '2017' }, - ]; +// const optionsYears = [ +// { value: 2024, label: '2024' }, +// { value: 2023, label: '2023' }, +// { value: 2022, label: '2022' }, +// { value: 2021, label: '2021' }, +// { value: 2019, label: '2019' }, +// { value: 2018, label: '2018' }, +// { value: 2017, label: '2017' }, +// ]; - const optionsMonth = [ - { value: 1, label: 'January' }, - { value: 2, label: 'February' }, - { value: 3, label: 'March' }, - { value: 4, label: 'April' }, - { value: 5, label: 'May' }, - { value: 6, label: 'June' }, - { value: 7, label: 'July' }, - { value: 8, label: 'August' }, - { value: 9, label: 'September' }, - { value: 10, label: 'October' }, - { value: 11, label: 'November' }, - { value: 12, label: 'December' }, - ]; +// const optionsMonth = [ +// { value: 1, label: 'January' }, +// { value: 2, label: 'February' }, +// { value: 3, label: 'March' }, +// { value: 4, label: 'April' }, +// { value: 5, label: 'May' }, +// { value: 6, label: 'June' }, +// { value: 7, label: 'July' }, +// { value: 8, label: 'August' }, +// { value: 9, label: 'September' }, +// { value: 10, label: 'October' }, +// { value: 11, label: 'November' }, +// { value: 12, label: 'December' }, +// ]; - useEffect(() => { - const data = { month: selectedMonth.value, year: selectedYear.value }; - dispatch(fetchTransactionsSummary(data)); - }, [dispatch, selectedMonth, selectedYear]); +// useEffect(() => { +// const data = { month: selectedMonth.value, year: selectedYear.value }; +// dispatch(fetchTransactionsSummary(data)); +// }, [dispatch, selectedMonth, selectedYear]); - return ( -
- -
- ); -}; +// return ( +//
+// +//
+// ); +// }; -export default StatisticsDashboard; +// export default StatisticsDashboard; diff --git a/src/components/StatisticsDashboard/StatisticsDashboard.jsx b/src/components/StatisticsDashboard/StatisticsDashboard.jsx index d5d0a1f..0f9fd97 100644 --- a/src/components/StatisticsDashboard/StatisticsDashboard.jsx +++ b/src/components/StatisticsDashboard/StatisticsDashboard.jsx @@ -52,7 +52,6 @@ const StatisticsDashboard = () => { selectedValue={selectedYear} onSelect={setSelectedYear} /> - {/* Poți folosi transactionsSummary aici sau în StatisticsTable */} ); }; diff --git a/src/components/StatisticsTable/StatisticsTable.module.css b/src/components/StatisticsTable/StatisticsTable.module.css index 2f4cb41..1fe6606 100644 --- a/src/components/StatisticsTable/StatisticsTable.module.css +++ b/src/components/StatisticsTable/StatisticsTable.module.css @@ -1,5 +1,6 @@ .statisticsTable { width: 100%; + margin-top: 20px; border-collapse: collapse; color: #ffffff; font-family: Arial, sans-serif; @@ -7,12 +8,32 @@ .tableHead { color: #fbfbfb; - background: #523b7e99; box-shadow: 0px 4px 60px 0px #00000040; backdrop-filter: blur(50px); + border-top-left-radius: 8px; + border-top-right-radius: 8px; + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + overflow: hidden; + position: relative; } -tr { +.tableHead:before { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: #523b7e99; + border-top-left-radius: 8px; + border-top-right-radius: 8px; + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + z-index: -1; +} + +.tableRow { border-bottom: 1px solid rgba(255, 255, 255, 0.1); } @@ -38,6 +59,7 @@ tr { font-weight: bold; color: #ffffff; opacity: 0.7; + padding: 17px; } .statisticsTable tbody tr td:first-child { @@ -55,7 +77,6 @@ tr { .totalRow, .incomeRow { font-weight: bold; - border-top: 1px solid #ffffff33; } .totalRow td, diff --git a/src/redux/Statistics/operations.js b/src/redux/Statistics/operations.js index 166adc6..7615af5 100644 --- a/src/redux/Statistics/operations.js +++ b/src/redux/Statistics/operations.js @@ -6,20 +6,20 @@ import { } from '../../config/userTransactionsApi'; export const getTransactionsSummaryByPeriod = createAsyncThunk( - 'transactions/summary', + 'statistics/getTransactionsSummaryByPeriod', async ({ month, year }, thunkApi) => { const savedToken = thunkApi.getState().auth.token; if (savedToken) { setToken(savedToken); - } else { - return thunkApi.rejectWithValue('Unable to fetch'); } try { const { data } = await userTransactionsApi.get( `/api/transactions-summary?month=${month}&year=${year}` ); + console.log('Răspuns de la API pentru period summary:', data); return data; } catch (error) { + console.error('Eroare la obținerea datelor:', error); return thunkApi.rejectWithValue(error.message); } } diff --git a/src/redux/Statistics/slice.js b/src/redux/Statistics/slice.js index cde5d16..f883c18 100644 --- a/src/redux/Statistics/slice.js +++ b/src/redux/Statistics/slice.js @@ -1,4 +1,3 @@ -/*Temporar*/ import { createSlice, isAnyOf } from '@reduxjs/toolkit'; import { getTransactionsCategories, @@ -6,8 +5,10 @@ import { } from './operations'; const initialState = { - summary: [], + summaryByPeriod: {}, categories: [], + selectedMonth: new Date().getMonth() + 1, + selectedYear: new Date().getFullYear(), isStatisticsLoading: false, isStatisticsError: null, }; @@ -15,19 +16,25 @@ const initialState = { const slice = createSlice({ name: 'statistics', initialState, + reducers: { + setSelectedMonth: (state, action) => { + state.selectedMonth = action.payload; + }, + setSelectedYear: (state, action) => { + state.selectedYear = action.payload; + }, + }, extraReducers: builder => { builder - .addCase(getTransactionsCategories.fulfilled, (state, action) => { state.isStatisticsLoading = false; - console.log(action.payload); state.categories = action.payload; }) .addCase( getTransactionsSummaryByPeriod.fulfilled, (state, { payload }) => { state.isStatisticsLoading = false; - state.summary = payload; + state.summaryByPeriod = payload; } ) .addMatcher( @@ -53,4 +60,5 @@ const slice = createSlice({ }, }); +export const { setSelectedMonth, setSelectedYear } = slice.actions; export const statisticsReducer = slice.reducer;