Skip to content

Commit

Permalink
rebase and correct files according to new linter rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Sojabio committed Oct 10, 2024
1 parent 7c34ce9 commit e8e3ae4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
28 changes: 14 additions & 14 deletions frontend/src/components/RangePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { DatePicker } from "antd"
import dayjs, { Dayjs } from 'dayjs'
import { useState, useEffect } from 'react'
import dayjs, { Dayjs } from "dayjs"
import { useState, useEffect } from "react"

export default function RangePicker() {
const { RangePicker } = DatePicker;

const [selectedDates, setSelectedDates] = useState<[Dayjs | null, Dayjs | null]>([
localStorage.getItem('startDate') ? dayjs(localStorage.getItem('startDate')) : null,
localStorage.getItem('endDate') ? dayjs(localStorage.getItem('endDate')) : null
localStorage.getItem("startDate") ? dayjs(localStorage.getItem("startDate")) : null,
localStorage.getItem("endDate") ? dayjs(localStorage.getItem("endDate")) : null
])

const handleChange = (value: [Dayjs | null, Dayjs | null] | null) => {
if (value) {
const formattedStartDate = value[0] ? dayjs(value[0]).format('YYYY-MM-DD') : null
const formattedEndDate = value[1] ? dayjs(value[1]).format('YYYY-MM-DD') : null
const formattedStartDate = value[0] ? dayjs(value[0]).format("YYYY-MM-DD") : null
const formattedEndDate = value[1] ? dayjs(value[1]).format("YYYY-MM-DD") : null

if (formattedStartDate) localStorage.setItem('startDate', formattedStartDate)
else localStorage.removeItem('startDate')
if (formattedStartDate) localStorage.setItem("startDate", formattedStartDate)
else localStorage.removeItem("startDate")

if (formattedEndDate) localStorage.setItem('endDate', formattedEndDate)
else localStorage.removeItem('endDate')
if (formattedEndDate) localStorage.setItem("endDate", formattedEndDate)
else localStorage.removeItem("endDate")

setSelectedDates(value)
} else {
localStorage.removeItem('startDate')
localStorage.removeItem('endDate')
localStorage.removeItem("startDate")
localStorage.removeItem("endDate")
setSelectedDates([null, null])
}
};

useEffect(() => {
const startDate = localStorage.getItem('startDate') ? dayjs(localStorage.getItem('startDate')) : null
const endDate = localStorage.getItem('endDate') ? dayjs(localStorage.getItem('endDate')) : null
const startDate = localStorage.getItem("startDate") ? dayjs(localStorage.getItem("startDate")) : null
const endDate = localStorage.getItem("endDate") ? dayjs(localStorage.getItem("endDate")) : null
setSelectedDates([startDate, endDate])
}, []);

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/ReservationButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, message } from 'antd';
import { Article } from '../interface/types';
import { useHandleReservationMutation } from '../generated/graphql-types'
import { Button, message } from "antd";
import { Article } from "../interface/types";
import { useHandleReservationMutation } from "../generated/graphql-types"

export default function ReservationButton( {articles} : {articles : Article[]}) {
const [handleReservation] = useHandleReservationMutation({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/generated/graphql-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,4 +980,4 @@ export function useGetCurrentReservationByUserIdSuspenseQuery(baseOptions?: Apol
export type GetCurrentReservationByUserIdQueryHookResult = ReturnType<typeof useGetCurrentReservationByUserIdQuery>;
export type GetCurrentReservationByUserIdLazyQueryHookResult = ReturnType<typeof useGetCurrentReservationByUserIdLazyQuery>;
export type GetCurrentReservationByUserIdSuspenseQueryHookResult = ReturnType<typeof useGetCurrentReservationByUserIdSuspenseQuery>;
export type GetCurrentReservationByUserIdQueryResult = Apollo.QueryResult<GetCurrentReservationByUserIdQuery, GetCurrentReservationByUserIdQueryVariables>;
export type GetCurrentReservationByUserIdQueryResult = Apollo.QueryResult<GetCurrentReservationByUserIdQuery, GetCurrentReservationByUserIdQueryVariables>;
11 changes: 0 additions & 11 deletions frontend/src/graphql/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ mutation HandleReservation($data: NewReservationInput!) {
handleReservation(data: $data) {
id
}
<<<<<<< HEAD
}
`;

export const ADD_ARTICLE_TO_RESERVATION = gql`
mutation AddArticleToReservation($articleId: String!, $reservation: String!) {
addArticleToReservation(articleId: $articleId, reservation: $reservation) {
id
}
}
`;
=======
}`
>>>>>>> 8604264 (refactor createNewReservation and addArticleToReservation into one method handleReservation)

0 comments on commit e8e3ae4

Please sign in to comment.