Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] 4층 사물함 접근 제한 #1703 #1708

Merged
merged 8 commits into from
Nov 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
currentSectionCabinetState,
currentSectionColNumState,
} from "@/Cabinet/recoil/selectors";
import { DISABLED_FLOOR } from "@/Cabinet/pages/AvailablePage";
import CabinetList from "@/Cabinet/components/CabinetList/CabinetList";
import EmptySection from "@/Cabinet/components/CabinetList/EmptySection/EmptySection";
import RealViewNotification from "@/Cabinet/components/CabinetList/RealViewNotification/RealViewNotification";
Expand All @@ -19,10 +20,11 @@ import useMultiSelect from "@/Cabinet/hooks/useMultiSelect";

interface ICabinetListContainer {
isAdmin: boolean;
currentFloor: number;
}

const CabinetListContainer = ({
isAdmin,
isAdmin, currentFloor
}: ICabinetListContainer): JSX.Element => {
const colNum = useRecoilValue(currentSectionColNumState);
const currentSectionCabinets = useRecoilValue<CabinetPreviewInfo[]>(
Expand Down Expand Up @@ -50,17 +52,23 @@ const CabinetListContainer = ({
/>
</div>
)}
{currentFloorSectionNames.includes(currentSectionName) && (
{currentFloorSectionNames.includes(currentSectionName) && !(DISABLED_FLOOR.includes(currentFloor.toString())) && (
<RealViewNotification colNum={colNum as number} />
)}
<CabinetList
colNum={colNum as number}
cabinetInfo={currentSectionCabinets}
isAdmin={isAdmin}
/>
{(currentSectionName === SectionType.elevator ||
currentSectionName === SectionType.stairs) && (
<EmptySection message={"여기엔 사물함이 없어요!"} />
{(!isAdmin && DISABLED_FLOOR.includes(currentFloor.toString())) ? (
<EmptySection message={`${currentFloor}층은 현재 이용 불가입니다!`} />
) : (
<>
<CabinetList
colNum={colNum as number}
cabinetInfo={currentSectionCabinets}
isAdmin={isAdmin}
/>
{(currentSectionName === SectionType.elevator ||
currentSectionName === SectionType.stairs) && (
<EmptySection message={"여기엔 사물함이 없어요!"} />
)}
</>
)}
</React.Fragment>
);
Expand Down
29 changes: 16 additions & 13 deletions frontend/src/Cabinet/components/LeftNav/LeftMainNav/LeftMainNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ReactComponent as ProfileImg } from "@/Cabinet/assets/images/profile-ci
import { ReactComponent as SlackAlarmImg } from "@/Cabinet/assets/images/slack-alarm.svg";
import { ReactComponent as SlackImg } from "@/Cabinet/assets/images/slack.svg";
import { ReactComponent as StoreImg } from "@/Cabinet/assets/images/storeIconGray.svg";
import { DISABLED_FLOOR } from "@/Cabinet/pages/AvailablePage";

interface ILeftMainNav {
pathname: string;
Expand Down Expand Up @@ -57,19 +58,21 @@ const LeftMainNav = ({
Home
</TopBtnStyled>
{floors &&
floors.map((floor, index) => (
<TopBtnStyled
className={
pathname.includes("main") && floor === currentFloor
? "leftNavButtonActive cabiButton"
: "cabiButton"
}
onClick={() => onClickFloorButton(floor)}
key={index}
>
{floor + "층"}
</TopBtnStyled>
))}
floors.map((floor, index) =>
!(!isAdmin && DISABLED_FLOOR.includes(floor.toString())) ? (
<TopBtnStyled
className={
pathname.includes("main") && floor === currentFloor
? "leftNavButtonActive cabiButton"
: "cabiButton"
}
onClick={() => onClickFloorButton(floor)}
key={index}
>
{floor + "층"}
</TopBtnStyled>
) : null
)}
<TopBtnStyled
className={
pathname.includes("available")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { useLocation } from "react-router-dom";
import { useRecoilValue } from "recoil";
import { useRecoilState } from "recoil";
import styled from "styled-components";
import { currentSectionNameState } from "@/Cabinet/recoil/atoms";
import { currentSectionNameState, currentFloorNumberState } from "@/Cabinet/recoil/atoms";
import { DISABLED_FLOOR } from "@/Cabinet/pages/AvailablePage";
import { currentFloorSectionState } from "@/Cabinet/recoil/selectors";
import CabinetColorTable from "@/Cabinet/components/LeftNav/CabinetColorTable/CabinetColorTable";
import { clubSectionsData } from "@/Cabinet/assets/data/mapPositionData";
Expand All @@ -17,6 +18,7 @@ const LeftSectionNav = ({ closeLeftNav }: { closeLeftNav: () => void }) => {
const [currentFloorSection, setCurrentFloorSection] = useRecoilState<string>(
currentSectionNameState
);
const currentFloorNumber = useRecoilValue<number>(currentFloorNumberState);
const { pathname } = useLocation();
const isAdmin = pathname.includes("admin");

Expand Down Expand Up @@ -45,6 +47,7 @@ const LeftSectionNav = ({ closeLeftNav }: { closeLeftNav: () => void }) => {
<IconWrapperStyled>
{!isAdmin &&
!isClubSection &&
!DISABLED_FLOOR.includes(currentFloorNumber.toString()) &&
(section.alarmRegistered ? (
<FilledHeartIcon />
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from "styled-components";
import { DISABLED_FLOOR } from "@/Cabinet/pages/AvailablePage";

const MapFloorSelectOption: React.FC<{
selectFloor: Function;
Expand All @@ -7,6 +8,7 @@ const MapFloorSelectOption: React.FC<{
return (
<OptionWrapperStyled id="mapFloorOptionBox">
{floorInfo.map((info, idx) => (
!(DISABLED_FLOOR.includes(info.toString())) &&
<OptionStyled
className="cabiButton"
onClick={() => selectFloor(info)}
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/Cabinet/components/MapInfo/MapInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import styled from "styled-components";
import MapFloorSelect from "@/Cabinet/components/MapInfo/MapFloorSelect/MapFloorSelect";
import MapGrid from "@/Cabinet/components/MapInfo/MapGrid/MapGrid";
import { DISABLED_FLOOR } from "@/Cabinet/pages/AvailablePage";

const DEFAULT_FLOOR = 2;
const MapInfo = ({
touchStart,
touchEnd,
Expand All @@ -12,11 +14,16 @@ const MapInfo = ({
}: {
touchStart: React.TouchEventHandler;
touchEnd: React.TouchEventHandler;
floor: number;
floor: number | undefined;
setFloor: React.Dispatch<React.SetStateAction<number>>;
floorInfo: number[];
closeMap: React.MouseEventHandler;
}) => {
const currentFloor = floor ?? DEFAULT_FLOOR;
const validFloor = DISABLED_FLOOR.includes(currentFloor.toString())
? DEFAULT_FLOOR
: currentFloor;

return (
<MapInfoContainerStyled
id="mapInfo"
Expand All @@ -33,8 +40,8 @@ const MapInfo = ({
style={{ width: "24px", cursor: "pointer" }}
/>
</HeaderStyled>
<MapFloorSelect floor={floor} setFloor={setFloor} floorInfo={floorInfo} />
<MapGrid floor={floor} />
<MapFloorSelect floor={validFloor} setFloor={setFloor} floorInfo={floorInfo} />
<MapGrid floor={validFloor} />
</MapInfoContainerStyled>
);
};
Expand Down
1 change: 0 additions & 1 deletion frontend/src/Cabinet/pages/AvailablePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const toggleList: toggleItem[] = [
{ name: "공유", key: AvailableCabinetsType.SHARE },
];

/* TODO: DISABLED_FLOOR 을 환경변수로 넣기 */
seonmiki marked this conversation as resolved.
Show resolved Hide resolved
export const DISABLED_FLOOR = ["4"];

const AvailablePage = () => {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/Cabinet/pages/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ const MainPage = () => {
</AlertStyled>
<SectionPaginationContainer />
<CabinetListWrapperStyled>
<CabinetListContainer isAdmin={false} />
<CabinetListContainer isAdmin={false} currentFloor={currentFloor} />
{currentSectionName !== SectionType.elevator &&
currentSectionName !== SectionType.stairs && (
currentSectionName !== SectionType.stairs &&
currentFloor !== 4 && (
seonmiki marked this conversation as resolved.
Show resolved Hide resolved
<RefreshButtonStyled
className="cabiButton"
title="새로고침"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Cabinet/pages/admin/AdminMainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const AdminMainPage = () => {
/>
</MultiSelectButtonWrapperStyled>
<CabinetListWrapperStyled>
<CabinetListContainer isAdmin={true} />
<CabinetListContainer isAdmin={true} currentFloor={currentFloorNumber} />

<RefreshButtonStyled
className="cabiButton"
Expand Down
Loading