Skip to content

feat(site): add support for weekly data on template insights #9997

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

Merged
merged 20 commits into from
Oct 3, 2023
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
If template is created less than 5 weeks, show daily
  • Loading branch information
BrunoQuaresma committed Oct 2, 2023
commit f1ea3613d9eef5a3452b5da366fc75e05ec6fe7a
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
endOfWeek,
isSunday,
endOfDay,
addWeeks,
} from "date-fns";
import "react-date-range/dist/styles.css";
import "react-date-range/dist/theme/default.css";
Expand All @@ -58,7 +59,11 @@ export default function TemplateInsightsPage() {
endDate: now,
};

const [interval, setInterval] = useState<InsightsInterval>("week");
const [interval, setInterval] = useState<InsightsInterval>(() => {
const templateCreateDate = new Date(template.created_at);
const hasFiveWeeksOrMore = addWeeks(templateCreateDate, 5) < now;
return hasFiveWeeksOrMore ? "week" : "day";
});
const [weeklyPreset, setWeeklyPreset] =
useState<WeeklyPreset>(defaultWeeklyPreset);
const [dateRangeValue, setDateRangeValue] = useState<DateRangeValue>(
Expand Down