Skip to content

Commit

Permalink
add horizon type to csv file name
Browse files Browse the repository at this point in the history
  • Loading branch information
braddf committed Jun 19, 2024
1 parent e776bae commit ef47ada
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/quartz-app/src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type HeaderProps = {};
const Header: React.FC<HeaderProps> = () => {
const { showUserMenu, setShowUserMenu } = useUserMenu();
const [combinedData] = useGlobalState("combinedData");
const [forecastHorizon] = useGlobalState("forecastHorizon");
const [forecastHorizonMinutes] = useGlobalState("forecastHorizonMinutes");
const { user } = useUser();
const downloadCsv = async () => {
console.log("Download CSV");
Expand Down Expand Up @@ -78,7 +80,14 @@ const Header: React.FC<HeaderProps> = () => {
const a = document.createElement("a");
a.href = URL.createObjectURL(new Blob([csv], { type: "text/csv" }));
const now = DateTime.now().setZone("ist");
a.download = `Quartz-Data_${now
const forecastHorizonString = forecastHorizon
.split("_")
.map((type) => type.charAt(0).toUpperCase() + type.slice(1))
.join("-");
const forecastHorizonTimeString = forecastHorizon.includes("horizon")
? `${String(forecastHorizonMinutes / 60).replace(".", "-")}h`
: "";
a.download = `Quartz-${forecastHorizonString}${forecastHorizonTimeString}_${now
.toString()
.slice(0, 16)
.replaceAll("T", "_")}.csv`;
Expand Down

0 comments on commit ef47ada

Please sign in to comment.