Skip to content

Commit

Permalink
chore: 브랜치 머지
Browse files Browse the repository at this point in the history
  • Loading branch information
corinthionia committed Aug 5, 2023
2 parents b793dcb + 173bec7 commit 0f1555a
Show file tree
Hide file tree
Showing 20 changed files with 261 additions and 84 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"react-router-dom": "^6.8.1",
"react-scripts": "5.0.1",
"react-scrollable-picker": "^1.0.2",
"react-selecto": "^1.22.2",
"react-selecto": "^1.26.0",
"react-slick": "^0.29.0",
"react-spring-bottom-sheet": "^3.4.1",
"recoil": "^0.7.6",
Expand Down
3 changes: 3 additions & 0 deletions src/assets/icons/reset.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions src/components/addButton/AddButton.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import styled from '@emotion/styled';
import theme from '../../styles/theme';

export const Wrapper = styled.div`
width: 100%;
max-width: 412px;
height: 90px;
position: fixed;
z-index: 3;
bottom: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
`;

export const BottomWrapper = styled.div`
width: 100%;
border-top: 1px solid ${theme.colors.gray02};
background: ${theme.colors.gray01};
display: flex;
justify-content: space-between;
padding: 10px 20px 28px 20px;
`;

export const ResetButtonWrapper = styled.div`
width: 52px;
height: 52px;
border-radius: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: ${theme.colors.gray01};
filter: drop-shadow(0px 0px 7px rgba(0, 0, 0, 0.1));
cursor: pointer;
`;

export const ResetButton = styled.img`
width: 20px;
height: 20px;
`;

export const ResetText = styled.span`
color: ${theme.colors.gray05};
${theme.typography.medium06};
`;

export const BottomButton = styled.button`
width: 273px;
height: 52px;
border-radius: 6px;
${theme.typography.semibold03};
color: ${theme.colors.gray01};
background: ${theme.colors.purple06};
display: flex;
align-items: center;
justify-content: center;
`;
52 changes: 52 additions & 0 deletions src/components/addButton/AddButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import reset from '../../assets/icons/reset.svg';

import {
BottomButton,
BottomWrapper,
ResetButton,
ResetButtonWrapper,
ResetText,
Wrapper,
} from './AddButton.styles';

interface TableSelectedTypes {
[key: number]: string[];
}

interface AddButtonTypes {
handleApplyClick: () => void;
setTableSelected: React.Dispatch<React.SetStateAction<TableSelectedTypes>>;
setIsResetButtonClick: React.Dispatch<React.SetStateAction<boolean>>;
}

const AddButton = ({
setTableSelected,
handleApplyClick,
setIsResetButtonClick,
}: AddButtonTypes) => {
const handleResetClick = () => {
setTableSelected({});

const selected = document.querySelectorAll('.selected');

selected.forEach((element) => {
element.classList.remove('selected');
});

setIsResetButtonClick(true);
};

return (
<Wrapper>
<BottomWrapper>
<ResetButtonWrapper onClick={handleResetClick}>
<ResetButton src={reset} alt="reset" />
<ResetText>초기화</ResetText>
</ResetButtonWrapper>
<BottomButton onClick={handleApplyClick}>등록하기</BottomButton>
</BottomWrapper>
</Wrapper>
);
};

export default AddButton;
27 changes: 18 additions & 9 deletions src/components/addTimeTable/AddTimeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
TableWrapper,
} from './AddTimeTable.styles';
import Table from './Table';
import BottomButton from '../bottomButton/BottomButton';

import addPrevDisable from '../../assets/icons/addPrevDisable.png';
import addNextDisable from '../../assets/icons/addNextDisable.png';
Expand All @@ -25,6 +24,8 @@ import { getAllTimeRange } from '../../utils/getAllTimeRange';
import { getTimeRange } from '../../utils/getTimeRange';
import { useGetAvailableTimesByOne } from '../../queries/availableTimes/useGetAvailableTimesByOne';
import { usePutAvailableTimes } from '../../queries/availableTimes/usePutAvailableTimes';
import AddButton from '../addButton/AddButton';
import { ROUTES } from '../../constants/ROUTES';

const AddTimeTable = ({
wrapperRef,
Expand All @@ -34,6 +35,9 @@ const AddTimeTable = ({
setSelected,
selectedMethod,
dates,
setTableSelected,
isResetButtonClick,
setIsResetButtonClick,
}: AddTimeTableTypes) => {
const navigate = useNavigate();
const { roomUUID } = useParams() as { roomUUID: string };
Expand Down Expand Up @@ -61,7 +65,7 @@ const AddTimeTable = ({
} = useScroll();

const { data } = useGetAvailableTimesByOne(roomUUID, userName);
const { mutate, isSuccess } = usePutAvailableTimes();
const { mutate, isSuccess, isError } = usePutAvailableTimes();

useEffect(() => {
if (data) {
Expand Down Expand Up @@ -112,7 +116,7 @@ const AddTimeTable = ({
document.body.style.overflow = '';
(wrapperRef.current as HTMLDivElement).style.overflow = 'auto';

navigate(`/current/${roomUUID}`);
navigate(`/${ROUTES.CURRENT}/${roomUUID}`);
};

const allTimeRange = getAllTimeRange(dates, timeRange);
Expand Down Expand Up @@ -148,7 +152,11 @@ const AddTimeTable = ({
if (isSuccess) {
goToCurrent();
}
}, [isSuccess]);

if (isError) {
alert('처리 중 오류가 발생했습니다. 다시 시도해 주세요!');
}
}, [isSuccess, isError]);

return (
<>
Expand Down Expand Up @@ -177,6 +185,8 @@ const AddTimeTable = ({
tablePage={tablePage}
selectedMethod={selectedMethod}
validDateChunks={validDateChunks}
isResetButtonClick={isResetButtonClick}
setIsResetButtonClick={setIsResetButtonClick}
/>
</TableWrapper>
<ScrollbarTrack ref={trackRef}>
Expand All @@ -189,11 +199,10 @@ const AddTimeTable = ({
/>
</ScrollbarTrack>

<BottomButton
onClick={handleApplyClick}
navigate={goToCurrent}
text="등록하기"
isActivated={true}
<AddButton
setTableSelected={setTableSelected}
handleApplyClick={handleApplyClick}
setIsResetButtonClick={setIsResetButtonClick}
/>
</>
);
Expand Down
5 changes: 5 additions & 0 deletions src/components/addTimeTable/AddTimeTable.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export interface AddTimeTableTypes {
dates: string[];
selected: TableSelectedTypes;
setSelected: React.Dispatch<React.SetStateAction<TableSelectedTypes>>;
setTableSelected: React.Dispatch<React.SetStateAction<TableSelectedTypes>>;
isResetButtonClick: boolean;
setIsResetButtonClick: React.Dispatch<React.SetStateAction<boolean>>;
}

export interface TableType {
Expand All @@ -36,4 +39,6 @@ export interface TableType {
tablePage: number;
validDateChunks: Array<ChunkType[]>;
times: number[];
isResetButtonClick: boolean;
setIsResetButtonClick: React.Dispatch<React.SetStateAction<boolean>>;
}
25 changes: 19 additions & 6 deletions src/components/addTimeTable/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const Table = ({
tablePage,
validDateChunks,
times,
isResetButtonClick,
setIsResetButtonClick,
}: TableType) => {
const timeDetail = getTimeArray(times);

Expand All @@ -44,7 +46,8 @@ const Table = ({

useEffect(() => {
selectoRef.current.setSelectedTargets([]);
}, [selectedMethod]);
setIsResetButtonClick(false);
}, [selectedMethod, isResetButtonClick]);

const handleCellSelect = (e: any) => {
e.added.forEach((el: any) => {
Expand All @@ -67,6 +70,19 @@ const Table = ({
setSelected(newObj);
};

const handleClickOneElement = (e: React.MouseEvent<HTMLDivElement>) => {
const target = e.target as HTMLDivElement;

if (target.classList.contains('valid')) {
if (target.classList.contains('selected')) {
target.classList.remove('selected');
} else {
target.classList.add('selected');
addSelectedToObject();
}
}
};

return (
<Wrapper ref={contentRef}>
<Top>
Expand Down Expand Up @@ -103,17 +119,14 @@ const Table = ({
onSelect={handleCellSelect}
onDragEnd={addSelectedToObject}
hitRate={0}
selectByClick={true}
selectFromInside={true}
continueSelect={true}
continueSelectWithoutDeselect={false}
toggleContinueSelect={'shift'}
toggleContinueSelectWithoutDeselect={[['ctrl'], ['meta']]}
ratio={0}
></Selecto>

/>
{timeDetail.map((time) => (
<Select
onMouseUp={handleClickOneElement}
className={isValidDate ? 'valid' : 'invalid'}
key={`${date} ${time}:00`}
id={`${date} ${time}`}
Expand Down
10 changes: 0 additions & 10 deletions src/components/resultButton/ResultButton.stories.tsx

This file was deleted.

21 changes: 21 additions & 0 deletions src/hooks/useInputScroll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { useEffect } from 'react';

const useInputScroll = (ref: React.RefObject<HTMLInputElement>) => {
useEffect(() => {
window.addEventListener('touchmove', handleScroll);
return () => {
window.removeEventListener('touchmove', handleScroll);
};
}, []);

const handleScroll = (e: TouchEvent) => {
if (
document.activeElement == ref.current ||
ref.current?.contains(e.target as Node)
) {
(document.activeElement as HTMLElement).blur();
}
};
};

export default useInputScroll;
4 changes: 4 additions & 0 deletions src/pages/addTime/AddTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const AddTime = () => {
const wrapperRef = useRef<HTMLDivElement>(null);

const [selectedMethod] = useRecoilState(selectedMethodState);
const [isResetButtonClick, setIsResetButtonClick] = useState<boolean>(false);

const [tableSelected, setTableSelected] = useState<TableSelectedTypes>({});
const [calendarSelected, setCalendarSelected] = useState<string[]>([]);
Expand Down Expand Up @@ -69,7 +70,10 @@ const AddTime = () => {
endTime={parseInt(endTime)}
selected={tableSelected}
setSelected={setTableSelected}
setTableSelected={setTableSelected}
dates={dates}
isResetButtonClick={isResetButtonClick}
setIsResetButtonClick={setIsResetButtonClick}
/>
) : (
<AddCalendar
Expand Down
Loading

0 comments on commit 0f1555a

Please sign in to comment.