-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70aa710
commit 5773998
Showing
6 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use client"; | ||
import { Filter } from "react-feather"; | ||
import { useFilteredConsultants } from "@/hooks/useFilteredConsultants"; | ||
import SecondaryButton from "@/components/SecondaryButton"; | ||
|
||
export default function WeekSelection() { | ||
const { setSelectedWeek, resetSelectedWeek, selectedWeek } = | ||
useFilteredConsultants(); | ||
|
||
function handlePreviousWeekClick() { | ||
if (selectedWeek) { | ||
setSelectedWeek({ year: 2023, weekNumber: selectedWeek.weekNumber - 1 }); | ||
} else { | ||
setSelectedWeek({ year: 2023, weekNumber: 43 }); | ||
} | ||
} | ||
|
||
function handleNextWeekClick() { | ||
if (selectedWeek) { | ||
setSelectedWeek({ year: 2023, weekNumber: selectedWeek.weekNumber + 1 }); | ||
} else { | ||
setSelectedWeek({ year: 2023, weekNumber: 45 }); | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<SecondaryButton label={"<"} onClick={handlePreviousWeekClick} /> | ||
<SecondaryButton label={"Denne uka"} onClick={resetSelectedWeek} /> | ||
<SecondaryButton label={">"} onClick={handleNextWeekClick} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Week } from "@/types"; | ||
|
||
export function stringToWeek(urlString?: string): Week | undefined { | ||
if (!urlString) return; | ||
try { | ||
const args = urlString.split("-"); | ||
const year = Number.parseInt(args[0]); | ||
const week = Number.parseInt(args[1]); | ||
if (year && week) { | ||
return { | ||
year: year, | ||
weekNumber: week, | ||
}; | ||
} | ||
} catch { | ||
return; | ||
} | ||
} | ||
|
||
export function weekToString(week: Week) { | ||
return `${week.year}-${week.weekNumber}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters