This file contains hidden or 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
| import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; | |
| import { getSession, signOut } from 'next-auth/react'; | |
| import { Session } from '../api/auth/auth.types'; | |
| import { routes } from '../routes'; | |
| class AxiosProvider { | |
| private axiosInstance: AxiosInstance; | |
| constructor() { | |
| this.axiosInstance = axios.create({ |
This file contains hidden or 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
| import { useRouter, useSearchParams } from 'next/navigation'; | |
| export function useRouterWithQuery() { | |
| const router = useRouter(); | |
| const searchParams = useSearchParams(); | |
| const query = searchParams?.size ? `?${searchParams}` : ''; | |
| const replaceWithQuery = (url: string) => router.replace(`${url}${query}`); | |
| const pushWithQuery = (url: string) => router.push(`${url}${query}`); | |
| return { router, replaceWithQuery, pushWithQuery }; |
This file contains hidden or 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
| import React, { useEffect, useState } from 'react'; | |
| import './Calendar.scss'; | |
| import { CalendarMolecule } from 'molecules/Calendar'; | |
| import { WeekBarMolecule } from 'molecules/WeekBar'; | |
| import { VirtualScroller } from 'elements/VirtualScroller'; | |
| import { instanceOf, func, bool } from 'prop-types'; | |
| import classNames from 'classnames'; | |
| const TOTAL_MONTHS = 200 * 12; // 100 years ahead + 100 years behind | |
| const FRAME_HEIGHT = 270; // next month should be visible to make user aware of scrolling possibility |
This file contains hidden or 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
| import { | |
| addMonths, | |
| addYears, | |
| eachDayOfInterval, | |
| eachMonthOfInterval, | |
| eachWeekOfInterval, | |
| endOfMonth, | |
| endOfWeek, | |
| isAfter, | |
| isBefore, |
This file contains hidden or 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
| /* eslint-disable react/prop-types */ | |
| // inspired from this great article https://blog.logrocket.com/virtual-scrolling-core-principles-and-basic-implementation-in-react/ | |
| import React, { useRef, useEffect, useState } from 'react'; | |
| import { shape, func, string, number } from 'prop-types'; | |
| import './VirtualScroller.scss'; | |
| export function VirtualScroller(props) { | |
| const { settings, row, generateItems } = props; | |
| const viewportElement = useRef(); | |
| const [state, setState] = useState({ data: [] }); |
This file contains hidden or 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
| import { useEffect, useState } from 'react'; | |
| export const useViewportEdgeActions = ({ element, parent, reCalculate }) => { | |
| const [edgeState, setEdgeState] = useState({ | |
| isCloseToRightEdge: false, | |
| isCloseToLeft: false, | |
| isCloseToTop: false, | |
| isCloseToBottom: false, | |
| }); |