-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from snamiki1212/f/refactor
F/refactor
- Loading branch information
Showing
18 changed files
with
242 additions
and
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,36 @@ | ||
import React from "react"; | ||
import { useCommunityCollegeAfterwardsWorkingHolidayCalendar } from "../hooks/useCommunityCollegeAfterwardsWorkingHolidayCalendar"; | ||
import { useUser } from "../hooks/useUser"; | ||
import { DEPRECATED_useEventsHandler } from "../hooks/DEPRECATED_useEventsHandler"; | ||
import { BaseCalendarContainer } from "./BaseCalendarContainer"; | ||
import { useResourceGroupLabelContentInTemplateCalendar } from "../hooks/useResourceGroupLabelContentInTemplateCalendar"; | ||
|
||
const ableConfis = { | ||
selectable: false, | ||
editable: false, | ||
} as const; | ||
|
||
export function TemplateCalendarContainer() { | ||
const { birth } = useUser(); | ||
const { events, select, click, set: setEvents } = DEPRECATED_useEventsHandler(); | ||
const { stories, generate } = useCommunityCollegeAfterwardsWorkingHolidayCalendar(); | ||
const {resourceGroupLabelContent} = useResourceGroupLabelContentInTemplateCalendar() | ||
|
||
const storyResources = React.useMemo( | ||
() => | ||
stories.reduce( | ||
(prev, story) => [...prev, ...story.resources], | ||
[] as any[] | ||
), | ||
[stories] | ||
); | ||
const storyEvents = React.useMemo( | ||
() => | ||
stories.reduce((prev, story) => [...prev, ...story.events], [] as any[]), | ||
[stories] | ||
); | ||
const { | ||
resources, | ||
events, | ||
generate, | ||
} = useCommunityCollegeAfterwardsWorkingHolidayCalendar(); | ||
const { | ||
resourceGroupLabelContent, | ||
} = useResourceGroupLabelContentInTemplateCalendar(); | ||
|
||
React.useEffect(() => { | ||
generate(birth); | ||
}, [generate, birth]); | ||
|
||
React.useEffect(() => { | ||
setEvents(storyEvents); | ||
}, [storyEvents, setEvents]); | ||
|
||
return ( | ||
<BaseCalendarContainer | ||
events={events} | ||
resources={storyResources} | ||
select={select} | ||
eventClick={click} | ||
resources={resources} | ||
initialDate={"2020-06-01"} | ||
resourceGroupLabelContent={resourceGroupLabelContent} | ||
{...ableConfis} | ||
/> | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,43 +1,42 @@ | ||
import React from "react"; | ||
import { useUserCalendar } from "../hooks/useUserCalendar"; | ||
import { useUser } from "../hooks/useUser"; | ||
import { DEPRECATED_useEventsHandler } from "../hooks/DEPRECATED_useEventsHandler"; | ||
import { BaseCalendarContainer } from "./BaseCalendarContainer"; | ||
import { useResourceGroupLabelContentInUserCalendar } from "../hooks/useResourceGroupLabelContentInUserCalendar"; | ||
|
||
const ableConfis = { | ||
selectable: true, | ||
editable: true, | ||
} as const; | ||
|
||
export function UserCalendarContainer() { | ||
const { birth } = useUser(); | ||
|
||
const { | ||
resourceGroupLabelContent, | ||
} = useResourceGroupLabelContentInUserCalendar(); | ||
const { birth } = useUser(); | ||
|
||
const { | ||
events, | ||
select, | ||
click, | ||
set: setEvents, | ||
} = DEPRECATED_useEventsHandler(); | ||
const { | ||
events: _events, | ||
resources: _resources, | ||
resources, | ||
init: initUserCalendar, | ||
click, | ||
select, | ||
} = useUserCalendar(); | ||
|
||
React.useEffect(() => { | ||
initUserCalendar(birth); | ||
}, [birth, initUserCalendar]); | ||
|
||
React.useEffect(() => { | ||
setEvents(_events); | ||
}, [setEvents, _events]); | ||
|
||
return ( | ||
<BaseCalendarContainer | ||
events={events} | ||
resources={_resources} | ||
resources={resources} | ||
select={select} | ||
eventClick={click} | ||
initialDate={"2020-06-01"} | ||
resourceGroupLabelContent={resourceGroupLabelContent} | ||
{...ableConfis} | ||
/> | ||
); | ||
} |
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 |
---|---|---|
@@ -1 +1,12 @@ | ||
export type BaseEvent = any; | ||
import { EventInput } from "@fullcalendar/react"; | ||
|
||
type MyEvent = { | ||
id: string; | ||
resourceId: string; | ||
storyId: string; | ||
title?: string; | ||
start: Date | string; | ||
end: Date | string; | ||
}; | ||
|
||
export type BaseEvent = MyEvent | EventInput; |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.