Skip to content

Commit

Permalink
Merge pull request #89 from softeerbootcamp4th/refactor/88-directory
Browse files Browse the repository at this point in the history
[refactor] 폴더 구조 대규모 변경
  • Loading branch information
darkdulgi authored Aug 12, 2024
2 parents 0636436 + 2bfc8e8 commit 5a6389d
Show file tree
Hide file tree
Showing 160 changed files with 282 additions and 279 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy_preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
push:
branches:
- "dev"
paths:
- "common/**"
- "mainPage/**"
jobs:
deploy-preview:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/deploy_production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
push:
branches:
- "main"
paths:
- "common/**"
- "mainPage/**"
jobs:
deploy-production:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
</head>
<body>
<div id="root"><!--hydrate_root--></div>
<script type="module" src="/src/main-client.jsx"></script>
<script type="module" src="/src/mainPage/main-client.jsx"></script>
</body>
</html>
38 changes: 0 additions & 38 deletions src/App.jsx

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 1 addition & 7 deletions src/common/constants.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
export const EVENT_ID = "0";
export const TOKEN_ID = "AWESOME_ORANGE_ACCESS_TOKEN";

// scroll section constants
export const INTERACTION_SECTION = 1;
export const DETAIL_SECTION = 2;
export const COMMENT_SECTION = 3;
export const FCFS_SECTION = 4;
export const TOKEN_ID = "AWESOME_ORANGE_ACCESS_TOKEN";
2 changes: 1 addition & 1 deletion src/common/dataFetch/fetchServer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tokenSaver from "@/auth/tokenSaver.js";
import tokenSaver from "./tokenSaver.js";

class HTTPError extends Error {
constructor(response) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TOKEN_ID } from "@/common/constants.js";
import { TOKEN_ID } from "@common/constants.js";

class TokenSaver {
initialized = false;
Expand Down
9 changes: 6 additions & 3 deletions src/modal/modal.jsx → src/common/modal/modal.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createContext, useCallback, useEffect, useState, useRef } from "react";
import useModalStore, { closeModal } from "./store.js";
import { delay } from "@common/utils.js";

export const ModalCloseContext = createContext(() => {
console.log("모달이 닫힙니다.");
Expand All @@ -9,10 +10,12 @@ function Modal({ layer }) {
const timeoutRef = useRef(null);
const child = useModalStore(layer);
const [opacity, setOpacity] = useState(0);
const close = useCallback(() => {
const close = useCallback(async () => {
setOpacity(0);
if (timeoutRef.current === null)
timeoutRef.current = setTimeout(() => closeModal(layer), 150);
if (timeoutRef.current === null) {
await delay(150);
closeModal(layer);
}
}, [layer]);

useEffect(() => {
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ export function convertSecondsToString(time) {

return `${days > 0 ? days + " : " : ""}${[hours, minutes, seconds].map(padNumber).join(" : ")}`;
}

export function delay(ms) {
return new Promise( resolve=>setTimeout(resolve, ms) );
}
40 changes: 40 additions & 0 deletions src/mainPage/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { useEffect } from "react";

import IntroSection from "./features/introSection";
import Header from "./features/header";
import SimpleInformation from "./features/simpleInformation";
import InteractionPage from "./features/interactions";
import DetailInformation from "./features/detailInformation";
import CommentSection from "./features/comment";
import FcfsSection from "./features/fcfs";
import QnA from "./features/qna";
import Footer from "./features/footer";

import Modal from "@common/modal/modal.jsx";
import { initLoginState } from "@main/auth/store.js";

function App() {
useEffect(() => {
window.scrollTo(0, 0);
history.scrollRestoration = "manual";
initLoginState();
}, []);

return (
<>
<IntroSection />
<Header />
<SimpleInformation />
<InteractionPage />
<DetailInformation />
<CommentSection />
<FcfsSection />
<QnA />
<Footer />
<Modal layer="interaction" />
<Modal layer="alert" />
</>
);
}

export default App;
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect, useRef, useCallback } from "react";
import useMountDragEvent from "@/common/useMountDragEvent";
import useMountDragEvent from "@main/hooks/useMountDragEvent";

const FRICTION_RATE = 0.1;
const MOMENTUM_THRESHOLD = 0.6;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from "@/common/dataFetch/getQuery.js";
import { fetchServer } from "@/common/dataFetch/fetchServer.js";
import { useQuery } from "@common/dataFetch/getQuery.js";
import { fetchServer } from "@common/dataFetch/fetchServer.js";
import AutoScrollCarousel from "../autoScrollCarousel";

function mask(string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Spinner from "@/common/Spinner.jsx";
import DelaySkeleton from "@/common/DelaySkeleton.jsx";
import Spinner from "@common/components/Spinner.jsx";
import DelaySkeleton from "@common/components/DelaySkeleton.jsx";

function CommentCarouselSkeleton() {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Suspense from "@/common/Suspense.jsx";
import ErrorBoundary from "@/common/ErrorBoundary.jsx";
import Suspense from "@common/components/Suspense.jsx";
import ErrorBoundary from "@common/components/ErrorBoundary.jsx";
import CommentCarousel from "./CommentCarousel.jsx";
import CommentCarouselSkeleton from "./CommentCarouselSkeleton.jsx";
import CommentCarouselError from "./CommentCarouselError.jsx";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from "@/common/Button.jsx";
import Button from "@common/components/Button.jsx";

function getMessageFromButtonFetchState(state) {
if (state === "pending") return "...";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { useState, useEffect } from "react";
import CommentSuccessModal from "../modals/CommentSuccessModal.jsx";
import CommentNegativeModal from "../modals/CommentNegativeModal.jsx";
import CommentNoUserModal from "../modals/CommentNoUserModal.jsx";
import NoServerModal from "@/common/NoServerModal.jsx";
import NoServerModal from "@main/components/NoServerModal.jsx";
import SubmitButton from "./SubmitButton";
import useAuthState from "@/auth/store.js";
import useAuthState from "@main/auth/store.js";

import { fetchServer, handleError } from "@/common/dataFetch/fetchServer.js";
import { EVENT_ID } from "@/common/constants.js";
import openModal from "@/modal/openModal.js";
import { fetchServer, handleError } from "@common/dataFetch/fetchServer.js";
import { EVENT_ID } from "@common/constants.js";
import openModal from "@common/modal/openModal.js";

const submitCommentErrorHandle = {
400: "negative",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRef } from "react";
import CommentCarousel from "./commentCarousel";
import CommentForm from "./commentForm";
import useSectionInitialize from "../scroll/useSectionInitialize";
import useSectionInitialize from "@main/scroll/useSectionInitialize";
import decoration from "./assets/decoration.svg";

function CommentSection() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext } from "react";
import { ModalCloseContext } from "@/modal/modal.jsx";
import Button from "@/common/Button.jsx";
import { ModalCloseContext } from "@common/modal/modal.jsx";
import Button from "@common/components/Button.jsx";

function CommentNegativeModal() {
const close = useContext(ModalCloseContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useContext } from "react";
import { ModalCloseContext } from "@/modal/modal.jsx";
import Button from "@/common/Button.jsx";
import scrollTo from "@/scroll/scrollTo.js";
import { INTERACTION_SECTION } from "@/common/constants.js";
import { ModalCloseContext } from "@common/modal/modal.jsx";
import Button from "@common/components/Button.jsx";
import scrollTo from "@main/scroll/scrollTo.js";
import { INTERACTION_SECTION } from "@main/scroll/constants.js";

function CommentNoUserModal() {
const close = useContext(ModalCloseContext);

function toMoveInteraction() {
close();
async function toMoveInteraction() {
await close();
scrollTo(INTERACTION_SECTION);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext } from "react";
import { ModalCloseContext } from "@/modal/modal.jsx";
import Button from "@/common/Button.jsx";
import { ModalCloseContext } from "@common/modal/modal.jsx";
import Button from "@common/components/Button.jsx";

function CommentSuccessModal() {
const close = useContext(ModalCloseContext);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import useSwiperState from "@/common/useSwiperState.js";
import useSwiperState from "@main/hooks/useSwiperState.js";
import DetailItem from "./DetailItem.jsx";
import left from "./assets/left.svg";
import right from "./assets/right.svg";
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import DetailSwiper from "./DetailSwiper.jsx";
import content from "./content.json";
import decoration from "./assets/decoration.svg";
import { useRef } from "react";
import useSectionInitialize from "../scroll/useSectionInitialize.js";
import useSectionInitialize from "@main/scroll/useSectionInitialize.js";

function DetailInformation() {
const SECTION_IDX = 2;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { useState } from "react";
import CardGameTitle from "./CardGameTitle.jsx";
import Card from "./Card.jsx";

import openModal from "@/modal/openModal.js";
import openModal from "@common/modal/openModal.js";
import FcfsWinModal from "../modals/FcfsWinModal.jsx";
import FcfsLoseModal from "../modals/FcfsLoseModal.jsx";
import FcfsInvalidModal from "../modals/FcfsInvalidModal.jsx";
import AuthModal from "@/auth/AuthModal.jsx";
import AuthModal from "@main/auth/AuthModal.jsx";

import useFcfsStore from "../store.js";
import * as Status from "../constants.js";
import { EVENT_ID } from "@/common/constants.js";
import { fetchServer, handleError } from "@/common/dataFetch/fetchServer.js";
import ResetButton from "@/common/ResetButton.jsx";
import useFcfsStore from "@main/realtimeEvent/store.js";
import * as Status from "@main/realtimeEvent/constants.js";
import { EVENT_ID } from "@common/constants.js";
import { fetchServer, handleError } from "@common/dataFetch/fetchServer.js";
import ResetButton from "@main/components/ResetButton.jsx";

function getLocked(eventStatus, isParticipated, offline) {
if (offline) return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import useFcfsStore from "../store.js";
import * as Status from "../constants.js";
import { convertSecondsToString } from "@/common/utils.js";
import useFcfsStore from "@main/realtimeEvent/store.js";
import * as Status from "@main/realtimeEvent/constants.js";
import { convertSecondsToString } from "@common/utils.js";

function CardGameCountdown() {
const countdown = useFcfsStore((store) => store.countdown);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useDeferredValue } from "react";
import Suspense from "@/common/Suspense.jsx";
import ErrorBoundary from "@/common/ErrorBoundary.jsx";
import useFcfsStore from "../store.js";
import useAuthStore from "@/auth/store.js";
import Suspense from "@common/components/Suspense.jsx";
import ErrorBoundary from "@common/components/ErrorBoundary.jsx";
import useFcfsStore from "@main/realtimeEvent/store.js";
import useAuthStore from "@main/auth/store.js";
import CardGame from "./CardGame.jsx";

function CardGameInitializer() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect, useRef } from "react";
import useFcfsStore from "../store.js";
import { OFFLINE } from "../constants.js";
import useFcfsStore from "@main/realtimeEvent/store.js";
import { OFFLINE } from "@main/realtimeEvent/constants.js";
import CountdownController from "./CountdownController";
import Suspense from "@/common/Suspense.jsx";
import ErrorBoundary from "@/common/ErrorBoundary.jsx";
import Suspense from "@common/components/Suspense.jsx";
import ErrorBoundary from "@common/components/ErrorBoundary.jsx";

function CountStarterDummy() {
const controller = useRef(new CountdownController(0, 0));
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import useFcfsStore from "../store.js";
import { OFFLINE } from "../constants.js";

const ONE_DAY = 24 * 60 * 60 * 1000;
function getEventDateState(currrentTimeDate, eventTimeDate) {
const currentTime = currrentTimeDate.valueOf();
const eventTime = eventTimeDate.valueOf();
const eventEndTime = eventTimeDate.valueOf() + ONE_DAY;
if (currentTime < eventTime) return "default";
if (currentTime < eventEndTime) return "active";
return "ended";
}
import useFcfsStore from "@main/realtimeEvent/store.js";
import { OFFLINE } from "@main/realtimeEvent/constants.js";
import getEventDateState from "@main/realtimeEvent/getEventDateState.js";

function DateEventPrize({ date, title, capacity, image }) {
const currentServerTime = useFcfsStore((store) => store.currentServerTime);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EventDescriptionLayout from "@/eventDescription/EventDescriptionLayout.jsx";
import EventDescriptionLayout from "@main/eventDescription/EventDescriptionLayout.jsx";
import DateEventPrize from "./DateEventPrize.jsx";
import content from "./content.json";

Expand Down
4 changes: 2 additions & 2 deletions src/fcfs/index.jsx → src/mainPage/features/fcfs/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRef } from "react";
import useSectionInitialize from "@/scroll/useSectionInitialize.js";
import { FCFS_SECTION } from "@/common/constants.js";
import useSectionInitialize from "@main/scroll/useSectionInitialize.js";
import { FCFS_SECTION } from "@main/scroll/constants.js";
import CardGame from "./cardGame";
import CountStarter from "./countdown/CountStarter.jsx";
import FcfsDescription from "./description";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext } from "react";
import { ModalCloseContext } from "@/modal/modal.jsx";
import Button from "@/common/Button.jsx";
import { ModalCloseContext } from "@common/modal/modal.jsx";
import Button from "@common/components/Button.jsx";

function FcfsInvalidModal() {
const close = useContext(ModalCloseContext);
Expand Down
Loading

0 comments on commit 5a6389d

Please sign in to comment.