-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add YTD and last year to Reports headers #4019
base: master
Are you sure you want to change the base?
Changes from 7 commits
97e5d90
08d75b9
3e1d7e7
26c2b37
585d042
290058a
121d09b
f4973c8
690627e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,6 +460,8 @@ function CalendarInner({ widget, parameters }: CalendarInnerProps) { | |
}, | ||
); | ||
|
||
const [earliestTransaction, _] = useState(''); | ||
|
||
Comment on lines
+463
to
+464
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Initialize earliestTransaction state with data from useEffect The - const [earliestTransaction, _] = useState('');
+ const [earliestTransaction, setEarliestTransaction] = useState('');
useEffect(() => {
async function run() {
try {
const trans = await send('get-earliest-transaction');
+ if (trans) {
+ setEarliestTransaction(trans.date);
+ }
// ... rest of the effect
} catch (error) {
console.error('Error fetching earliest transaction:', error);
}
}
run();
}, []);
|
||
return ( | ||
<Page | ||
header={ | ||
|
@@ -492,6 +494,8 @@ function CalendarInner({ widget, parameters }: CalendarInnerProps) { | |
allMonths={allMonths} | ||
start={start} | ||
end={end} | ||
earliestTransaction={earliestTransaction} | ||
firstDayOfWeekIdx={firstDayOfWeekIdx} | ||
mode={mode} | ||
onChangeDates={onChangeDates} | ||
filters={conditions} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import { | |
|
||
import { useFilters } from '../../../hooks/useFilters'; | ||
import { useNavigate } from '../../../hooks/useNavigate'; | ||
import { useSyncedPref } from '../../../hooks/useSyncedPref'; | ||
import { SvgEquals } from '../../../icons/v1'; | ||
import { SvgCloseParenthesis } from '../../../icons/v2/CloseParenthesis'; | ||
import { SvgOpenParenthesis } from '../../../icons/v2/OpenParenthesis'; | ||
|
@@ -147,6 +148,10 @@ function SummaryInner({ widget }: SummaryInnerProps) { | |
}> | ||
>([]); | ||
|
||
const [earliestTransaction, _] = useState(''); | ||
const [_firstDayOfWeekIdx] = useSyncedPref('firstDayOfWeekIdx'); | ||
const firstDayOfWeekIdx = _firstDayOfWeekIdx || '0'; | ||
Comment on lines
+151
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Initialize earliestTransaction state with data from useEffect The - const [earliestTransaction, _] = useState('');
+ const [earliestTransaction, setEarliestTransaction] = useState('');
useEffect(() => {
async function run() {
const trans = await send('get-earliest-transaction');
+ if (trans) {
+ setEarliestTransaction(trans.date);
+ }
// ... rest of the effect
}
run();
}, []);
|
||
|
||
useEffect(() => { | ||
async function run() { | ||
const trans = await send('get-earliest-transaction'); | ||
|
@@ -273,6 +278,8 @@ function SummaryInner({ widget }: SummaryInnerProps) { | |
allMonths={allMonths} | ||
start={start} | ||
end={end} | ||
earliestTransaction={earliestTransaction} | ||
firstDayOfWeekIdx={firstDayOfWeekIdx} | ||
mode={mode} | ||
onChangeDates={onChangeDates} | ||
onApply={dividendFilters.onApply} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Enhancements | ||
authors: [rodriguestiago0] | ||
--- | ||
|
||
Add "Year to date" and "Last year" to reports header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding input validation to
convertToMonth
.The function assumes valid date strings but doesn't handle invalid inputs.
Add input validation:
📝 Committable suggestion