Skip to content

Commit

Permalink
Merge pull request #379 from TripInfoWeb/dev_gathering
Browse files Browse the repository at this point in the history
Dev gathering
  • Loading branch information
ssssksss authored Sep 23, 2024
2 parents 87e8815 + 8d28073 commit b25dd78
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "@/styles/reactDataRange.css";
import { add, addDays, format, isAfter } from "date-fns";
import { add, addDays, format, isAfter, isSameDay } from "date-fns";
import ko from "date-fns/locale/ko";
import { useEffect, useState } from "react";
import { DateRangePicker, RangeKeyDict } from "react-date-range";
Expand Down Expand Up @@ -80,14 +80,18 @@ const GatheringPeriodModal = (props: IGatheringPeriodModalProps) => {
<DateRangePicker
onChange={(rangesByKey: RangeKeyDict) => {
const selection = rangesByKey.selection;
if (
selection.startDate?.getFullYear() !=
selection.endDate?.getFullYear() ||
selection.startDate?.getMonth() != selection.endDate?.getMonth()
) {
setMonth(selection.startDate!.getMonth() + 1);
setYear(selection.startDate!.getFullYear());
if (selection.startDate && selection.endDate && isSameDay(selection.startDate, selection.endDate)) {
setMonth(selection.startDate.getMonth() + 1);
}
if (
selection.startDate?.getFullYear() !=
selection.endDate?.getFullYear() ||
selection.startDate?.getMonth() !=
selection.endDate?.getMonth()
) {
setMonth(selection.startDate!.getMonth() + 1);
setYear(selection.startDate!.getFullYear());
}
setCalendarDate([
{
startDate: selection.startDate as Date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const GatheringPlaceModal = (props: IGatheringPlaceModalProps) => {
formContext.setValue("xAxis", Number(element.x));
formContext.setValue("yAxis", Number(element.y));
formContext.setValue("searchId", element.id);
formContext.setValue("roadAddressName", element.road_address_name);
formContext.setValue("roadAddressName", element.address_name);
formContext.trigger([
"placeName",
"xAxis",
Expand All @@ -126,7 +126,7 @@ const GatheringPlaceModal = (props: IGatheringPlaceModalProps) => {
};

const pickAddress = (element: PlaceElement1) => {
setRoadAddress(element.road_address.address_name);
setRoadAddress(element.address_name);
setPlaceData(element);
};

Expand All @@ -136,7 +136,7 @@ const GatheringPlaceModal = (props: IGatheringPlaceModalProps) => {
formContext.setValue("yAxis", Number(placeData?.y));
formContext.setValue(
"roadAddressName",
placeData?.road_address.address_name,
placeData?.address_name,
);
formContext.setValue("searchId", "");
formContext.trigger([
Expand Down Expand Up @@ -250,7 +250,7 @@ const GatheringPlaceModal = (props: IGatheringPlaceModalProps) => {
<span> {result.place_name} </span>
</div>
<div className={"text-sm text-gray2"}>
{result.road_address_name}
{result.address_name}
</div>
</li>
))}
Expand Down

0 comments on commit b25dd78

Please sign in to comment.