Skip to content

Commit

Permalink
Merge branch 'main' into change-window-reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-zReeZ authored Jul 9, 2024
2 parents 8cb999a + d9a1758 commit c7789d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 7 additions & 11 deletions nextjs-interface/src/app/dashboard/esp/[espId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from "@/lib/data";

// import libraries
import { endOfMonth, format, startOfMonth } from "date-fns";
import { differenceInDays, endOfWeek, format, startOfWeek } from "date-fns";
import { DateRange } from "react-day-picker";
import React, { useState } from "react";

Expand All @@ -39,8 +39,8 @@ export default function Page({ params }: { params: any }) {
const [date, setDate] = React.useState<DateRange | undefined>(() => {
const now = new Date();
return {
from: startOfMonth(now),
to: endOfMonth(now),
from: startOfWeek(now),
to: endOfWeek(now),
};
});

Expand Down Expand Up @@ -69,8 +69,9 @@ export default function Page({ params }: { params: any }) {

const handleSelect = (value: any) => {
setPrecision(value);
console.log(value);
};
const dateRangeInDays =
date?.from && date?.to ? differenceInDays(date.to, date.from) : 0;

return (
<div className="flex h-full w-full min-w-[500px] flex-col gap-y-5 pt-2">
Expand Down Expand Up @@ -104,16 +105,11 @@ export default function Page({ params }: { params: any }) {
</SelectItem>
<SelectItem
value="Hour"
className="cursor-pointer rounded-none border-t-2 border-secondary dark:border-gray-700"
className={`cursor-pointer rounded-none border-t-2 border-secondary dark:border-gray-700 ${dateRangeInDays > 7 ? "cursor-not-allowed opacity-50" : ""}`}
disabled={dateRangeInDays > 7}
>
Hour
</SelectItem>
<SelectItem
value="Minute"
className="cursor-pointer rounded-none border-t-2 border-secondary dark:border-gray-700"
>
Minute
</SelectItem>
</SelectContent>
</Select>
</div>
Expand Down
1 change: 0 additions & 1 deletion nextjs-interface/src/app/ui/plan/espMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export function EspMap({
} catch (error) {
console.error("error :", error);
}
window.location.reload();
};

return (
Expand Down

0 comments on commit c7789d8

Please sign in to comment.