Skip to content

Commit

Permalink
fix: gather writing error and refactor gather type (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungJL authored Apr 18, 2024
2 parents 72d4ab4 + 2a090eb commit c899839
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 120 deletions.
2 changes: 1 addition & 1 deletion components/atoms/TimeSelectorUnit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ function TimeSelectorUnit({ time, setTime, timeArr, disabled }: ITimeSelectorUni
const minutes = Number(value.slice(3));
setTime({ hours, minutes });
};


return (
<Layout>
<Select
name="hour"
value={`${hourStr}:${minuteStr}`}
// placeholder="시간"
onChange={onChangeTime}
disabled={disabled}
>
Expand Down
2 changes: 1 addition & 1 deletion components/organisms/location/LocationSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { KeyboardEvent, useState } from "react";
import styled from "styled-components";

import { DispatchType } from "../../../types/hooks/reactTypes";
import { IGatherLocation } from "../../../types/models/gatherTypes/gather";
import { IGatherLocation } from "../../../types/models/gatherTypes/gatherTypes";

interface ISearchLocation {
location?: string;
Expand Down
2 changes: 1 addition & 1 deletion constants/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GatherStatus } from "../types/models/gatherTypes/gather";
import { GatherStatus } from "../types/models/gatherTypes/gatherTypes";

export const TABLE_COLORS = [
"#FF8896",
Expand Down
2 changes: 1 addition & 1 deletion constants/util/convert.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GatherStatus } from "../../types/models/gatherTypes/gather";
import { GatherStatus } from "../../types/models/gatherTypes/gatherTypes";

export const STATUS_TO_TEXT: Record<GatherStatus, string> = {
open: "오픈",
Expand Down
2 changes: 1 addition & 1 deletion hooks/gather/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMutation } from "react-query";

import { requestServer } from "../../libs/methodHelpers";
import { MutationOptions } from "../../types/hooks/reactTypes";
import { IGather, IGatherWriting } from "../../types/models/gatherTypes/gather";
import { IGather, IGatherWriting } from "../../types/models/gatherTypes/gatherTypes";

type GatherWritingParam<T> = T extends "post"
? { gather: IGatherWriting }
Expand Down
2 changes: 1 addition & 1 deletion hooks/groupStudy/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GATHER_CONTENT, GROUP_STUDY, GROUP_STUDY_ALL } from "../../constants/ke
import { SERVER_URI } from "../../constants/system";
import { IGatherSummary } from "../../pages/review";
import { QueryOptions } from "../../types/hooks/reactTypes";
import { IGather } from "../../types/models/gatherTypes/gather";
import { IGather } from "../../types/models/gatherTypes/gatherTypes";
import { IGroup, IGroupAttendance } from "../../types/models/groupTypes/group";

export const useGroupQuery = (options?: QueryOptions<IGroup[]>) =>
Expand Down
2 changes: 1 addition & 1 deletion hooks/user/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const usePointSystemLogQuery = (
[USER_POINT_SYSTEM, category, isUserScope, "log"],
async () => {
const scopeQuery = isUserScope ? "" : "all";
console.log(5, category, scopeQuery);

const res = await axios.get<IPointLog[]>(`${SERVER_URI}/log/${category}/${scopeQuery}`);
return res.data;
},
Expand Down
8 changes: 6 additions & 2 deletions modals/gather/GatherKakaoShareModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import KakaoShareBtn from "../../components/atoms/Icons/KakaoShareBtn";
import { WEB_URL } from "../../constants/system";
import { ModalSubtitle } from "../../styles/layout/modal";
import { IModal } from "../../types/components/modalTypes";
import { IGatherHeader } from "../../types/models/gatherTypes/gather";

import { ModalLayout } from "../Modals";

interface IGatherKakaoShareModal extends IModal, IGatherHeader {}
interface IGatherKakaoShareModal extends IModal {
title: string;
date: string;
locationMain: string;
}

function GatherKakaoShareModal({ title, date, locationMain, setIsModal }: IGatherKakaoShareModal) {
const router = useRouter();
Expand Down
2 changes: 1 addition & 1 deletion modals/gather/GatherWritingConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { isGatherEditState } from "../../recoils/checkAtoms";
import { sharedGatherWritingState } from "../../recoils/sharedDataAtoms";
import { ModalSubtitle } from "../../styles/layout/modal";
import { IModal } from "../../types/components/modalTypes";
import { IGather, IGatherWriting } from "../../types/models/gatherTypes/gather";
import { IGather, IGatherWriting } from "../../types/models/gatherTypes/gatherTypes";
import { IFooterOptions, ModalLayout } from "../Modals";

interface IGatherWritingConfirmModal extends IModal {
Expand Down
2 changes: 1 addition & 1 deletion pageTemplates/gather/detail/GatherContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from "styled-components";

import { IGatherListItem } from "../../../types/models/gatherTypes/gather";
import { IGatherListItem } from "../../../types/models/gatherTypes/gatherTypes";

interface IGather {
content: string;
Expand Down
2 changes: 1 addition & 1 deletion pageTemplates/gather/detail/GatherTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled from "styled-components";

import { Badge } from "../../../components/atoms/badges/Badges";
import { STATUS_TO_TEXT } from "../../../constants/util/convert";
import { GatherStatus } from "../../../types/models/gatherTypes/gather";
import { GatherStatus } from "../../../types/models/gatherTypes/gatherTypes";

interface IGatherTitle {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion pageTemplates/gather/writing/GatherWritingDateDate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
PickerDateAndTimeHeader,
} from "../../../components/molecules/picker/DatePickerOptions";
import { DispatchType } from "../../../types/hooks/reactTypes";
import { IGatherWriting } from "../../../types/models/gatherTypes/gather";
import { IGatherWriting } from "../../../types/models/gatherTypes/gatherTypes";
import { dayjsToFormat } from "../../../utils/dateTimeUtils";

const TIME_RANGE_MIN = new Date();
Expand Down
25 changes: 20 additions & 5 deletions pageTemplates/gather/writing/GatherWritingDateSubject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Input from "../../../components/atoms/Input";
import TimeSelectorUnit from "../../../components/atoms/TimeSelectorUnit";
import { TIME_SELECTOR_UNIT } from "../../../constants/util/util";
import { DispatchType } from "../../../types/hooks/reactTypes";
import { IGatherListItem, IGatherWriting } from "../../../types/models/gatherTypes/gather";
import { IGatherListItem, IGatherWriting } from "../../../types/models/gatherTypes/gatherTypes";
import { ITime } from "../../../types/utils/timeAndDate";

interface IGatherWritingDateSubject {
Expand Down Expand Up @@ -35,14 +35,29 @@ function GatherWritingDateSubject({
});

useEffect(() => {
if (date)
const [{ time: firstTime }, { time: secondTime }] = gatherWriting?.gatherList || [
{ time: null },
{ time: null },
];

if (firstTime || date) {
setFirstGather((old) => ({
...old,
time: {
hours: dayjs(date).hour(),
minutes: dayjs(date).minute(),
hours: firstTime ? firstTime.hours : dayjs(date).hour(),
minutes: firstTime ? firstTime.minutes : dayjs(date).minute(),
},
}));
}
if (secondTime) {
setSecondGather((old) => ({
...old,
time: {
hours: secondTime.hours,
minutes: secondTime.minutes,
},
}));
}
}, [date]);

useEffect(() => {
Expand Down Expand Up @@ -73,7 +88,7 @@ function GatherWritingDateSubject({
</Box>
<Box h="40px" />
<TimeSelectorUnit
time={firstGather?.time}
time={firstGather.time}
setTime={(time) => setFirstGather((old) => ({ ...old, time }))}
timeArr={TIME_SELECTOR_UNIT}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from "styled-components";

import CountNum from "../../../../components/atoms/CountNum";
import { DispatchType } from "../../../../types/hooks/reactTypes";
import { IGatherMemberCnt } from "../../../../types/models/gatherTypes/gather";
import { IGatherMemberCnt } from "../../../../types/models/gatherTypes/gatherTypes";

interface IGatherWritingConditionCnt {
isMin: boolean;
Expand Down
2 changes: 1 addition & 1 deletion pageTemplates/group/detail/GroupComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useResetQueryData } from "../../../hooks/custom/CustomHooks";
import { useGroupCommentMutation } from "../../../hooks/groupStudy/mutations";
import { useUserInfoQuery } from "../../../hooks/user/queries";
import GatherCommentEditModal from "../../../modals/gather/GatherCommentEditModal";
import { IGatherComment } from "../../../types/models/gatherTypes/gather";
import { IGatherComment } from "../../../types/models/gatherTypes/gatherTypes";
import { getDateDiff } from "../../../utils/dateTimeUtils";
// import GroupCommentEditModal from "../../../modals/group/GroupCommentEditModal";

Expand Down
2 changes: 1 addition & 1 deletion pageTemplates/group/detail/GroupTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled from "styled-components";

import { Badge } from "../../../components/atoms/badges/Badges";
import { NewAlertIcon } from "../../../components/atoms/Icons/AlertIcon";
import { GatherStatus } from "../../../types/models/gatherTypes/gather";
import { GatherStatus } from "../../../types/models/gatherTypes/gatherTypes";

interface IGroupTitle {
title: string;
Expand Down
3 changes: 2 additions & 1 deletion pages/gather/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import GatherOrganizer from "../../../pageTemplates/gather/detail/GatherOrganize
import GatherParticipation from "../../../pageTemplates/gather/detail/GatherParticipation";
import GatherTitle from "../../../pageTemplates/gather/detail/GatherTitle";
import { IGather } from "../../../types/models/gatherTypes/gatherTypes";
import { IUserSummary } from "../../../types/models/userTypes/userInfoTypes";

function GatherDetail() {
const { data: session } = useSession();
Expand All @@ -42,7 +43,7 @@ function GatherDetail() {
<Layout>
<GatherOrganizer
createdAt={gatherData.createdAt}
organizer={gatherData.user}
organizer={gatherData.user as IUserSummary}
isAdminOpen={gatherData.isAdminOpen}
category={gatherData.type.title}
/>
Expand Down
4 changes: 2 additions & 2 deletions pages/gather/writing/category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import BottomNav from "../../../components/layouts/BottomNav";
import Header from "../../../components/layouts/Header";
import Slide from "../../../components/layouts/PageSlide";
import ProgressStatus from "../../../components/molecules/ProgressStatus";
import { GATHER_TYPES, GatherCategoryIcons } from "../../../constants/contentsText/GatherContents";
import { GATHER_TYPES,GatherCategoryIcons } from "../../../constants/contentsText/GatherContents";
import { useFailToast } from "../../../hooks/custom/CustomToast";
import RegisterLayout from "../../../pageTemplates/register/RegisterLayout";
import RegisterOverview from "../../../pageTemplates/register/RegisterOverview";
import { sharedGatherWritingState } from "../../../recoils/sharedDataAtoms";
import { IGatherType } from "../../../types/models/gatherTypes/gather";
import { IGatherType } from "../../../types/models/gatherTypes/gatherTypes";

function WritingGatherCategory() {
const router = useRouter();
Expand Down
33 changes: 18 additions & 15 deletions pages/gather/writing/condition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
faVenusMars,
} from "@fortawesome/pro-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useSession } from "next-auth/react";
import { ChangeEvent, useEffect, useState } from "react";
import { useRecoilState } from "recoil";
import styled from "styled-components";
Expand All @@ -17,7 +18,6 @@ import BottomNav from "../../../components/layouts/BottomNav";
import Header from "../../../components/layouts/Header";
import Slide from "../../../components/layouts/PageSlide";
import ProgressStatus from "../../../components/molecules/ProgressStatus";
import { useUserInfoQuery } from "../../../hooks/user/queries";
import GatherWritingConfirmModal from "../../../modals/gather/GatherWritingConfirmModal";
import GatherWritingConditionAgeRange from "../../../pageTemplates/gather/writing/condition/GatherWritingConditionAgeRange";
import GatherWritingConditionCnt from "../../../pageTemplates/gather/writing/condition/GatherWritingConditionCnt";
Expand All @@ -26,7 +26,7 @@ import GatherWritingConditionPre from "../../../pageTemplates/gather/writing/con
import RegisterLayout from "../../../pageTemplates/register/RegisterLayout";
import RegisterOverview from "../../../pageTemplates/register/RegisterOverview";
import { sharedGatherWritingState } from "../../../recoils/sharedDataAtoms";
import { IGatherMemberCnt, IGatherWriting } from "../../../types/models/gatherTypes/gather";
import { IGatherMemberCnt, IGatherWriting } from "../../../types/models/gatherTypes/gatherTypes";
import { Location } from "../../../types/services/locationTypes";
import { randomPassword } from "../../../utils/validationUtils";

Expand All @@ -36,28 +36,31 @@ export type CombinedLocation = "전체" | "수원/안양" | "양천/강남";

function WritingCondition() {
const [gatherContent, setGatherContent] = useRecoilState(sharedGatherWritingState);

const { data: userInfo } = useUserInfoQuery();
const { data: session } = useSession();

const [condition, setCondition] = useState({
gender: gatherContent?.genderCondition || false,
age: gatherContent?.age ? true : false,
pre: gatherContent?.preCnt ? true : false,
location: true,
location: gatherContent?.place ? gatherContent.place === session?.user.location : true,
manager: true,
});

const [memberCnt, setMemberCnt] = useState<IGatherMemberCnt>({
min: 4,
max: 0,
});
const [memberCnt, setMemberCnt] = useState<IGatherMemberCnt>(
gatherContent?.memberCnt || {
min: 4,
max: 0,
},
);
const [preCnt, setPreCnt] = useState(gatherContent?.preCnt || 1);
const [age, setAge] = useState(gatherContent?.age || [19, 28]);
const [password, setPassword] = useState(gatherContent?.password);
const [location, setLocation] = useState<Location | CombinedLocation>(userInfo?.location);
const [location, setLocation] = useState<Location | CombinedLocation>(
gatherContent?.place || session?.user.location,
);
const [isConfirmModal, setIsConfirmModal] = useState(false);

const isManager = ["manager", "previliged"].includes(userInfo?.role);
const isManager = ["manager", "previliged"].includes(session?.user.role);

const onClickNext = async () => {
const gatherData: IGatherWriting = {
Expand All @@ -67,8 +70,8 @@ function WritingCondition() {
memberCnt,
genderCondition: condition.gender,
password,
user: userInfo,
place: location || userInfo?.location,
user: session?.user.id,
place: location || session?.user.location,
isAdminOpen: !condition.manager,
};
setGatherContent(gatherData);
Expand All @@ -82,7 +85,7 @@ function WritingCondition() {
const toggleSwitch = (e: ChangeEvent<HTMLInputElement>, type: ButtonType) => {
const isChecked = e.target.checked;
if (type === "location" && isChecked) {
setLocation(userInfo.location);
setLocation(session?.user.location);
}
setCondition((old) => {
return { ...old, [type]: isChecked };
Expand Down Expand Up @@ -118,7 +121,7 @@ function WritingCondition() {
<span>최대 인원</span>
</Name>
<GatherWritingConditionCnt
isMin={false}
isMin={memberCnt.max !== 0}
value={memberCnt.max}
setMemberCnt={setMemberCnt}
/>
Expand Down
2 changes: 1 addition & 1 deletion pages/gather/writing/date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import GatherWritingDateSubject from "../../../pageTemplates/gather/writing/Gath
import RegisterLayout from "../../../pageTemplates/register/RegisterLayout";
import RegisterOverview from "../../../pageTemplates/register/RegisterOverview";
import { sharedGatherWritingState } from "../../../recoils/sharedDataAtoms";
import { IGatherListItem } from "../../../types/models/gatherTypes/gather";
import { IGatherListItem } from "../../../types/models/gatherTypes/gatherTypes";

function WritingDate() {
const failToast = useFailToast();
Expand Down
2 changes: 1 addition & 1 deletion pages/gather/writing/location.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useFailToast } from "../../../hooks/custom/CustomToast";
import RegisterLayout from "../../../pageTemplates/register/RegisterLayout";
import RegisterOverview from "../../../pageTemplates/register/RegisterOverview";
import { sharedGatherWritingState } from "../../../recoils/sharedDataAtoms";
import { IGatherLocation } from "../../../types/models/gatherTypes/gather";
import { IGatherLocation } from "../../../types/models/gatherTypes/gatherTypes";

function WritingGahterLocation() {
const router = useRouter();
Expand Down
2 changes: 1 addition & 1 deletion pages/group/writing/condition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import QuestionBottomDrawer from "../../../pageTemplates/group/writing/QuestionB
import RegisterLayout from "../../../pageTemplates/register/RegisterLayout";
import RegisterOverview from "../../../pageTemplates/register/RegisterOverview";
import { sharedGroupWritingState } from "../../../recoils/sharedDataAtoms";
import { IGatherMemberCnt } from "../../../types/models/gatherTypes/gather";
import { IGatherMemberCnt } from "../../../types/models/gatherTypes/gatherTypes";
import { IGroupWriting } from "../../../types/models/groupTypes/group";
import { Location, LocationFilterType } from "../../../types/services/locationTypes";

Expand Down
2 changes: 1 addition & 1 deletion pages/review/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ReviewGatherSummary from "../../pageTemplates/review/ReviewGatherSummary"
import ReviewItemHeader from "../../pageTemplates/review/ReviewItemHeader";
import ReviewStatus from "../../pageTemplates/review/ReviewStatus";
import { IReviewData, REVIEW_DATA } from "../../storage/Review";
import { IGatherLocation, IGatherType } from "../../types/models/gatherTypes/gather";
import { IGatherLocation, IGatherType } from "../../types/models/gatherTypes/gatherTypes";
import {
ActiveLocation,
ActiveLocationAll,
Expand Down
2 changes: 1 addition & 1 deletion recoils/sharedDataAtoms.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { atom } from "recoil";

import { IGatherWriting } from "../types/models/gatherTypes/gather";
import { IGatherWriting } from "../types/models/gatherTypes/gatherTypes";
import { IGroupWriting } from "../types/models/groupTypes/group";

export const sharedGatherWritingState = atom<IGatherWriting>({
Expand Down
Loading

0 comments on commit c899839

Please sign in to comment.