Skip to content

Commit

Permalink
[chore] 린트 수정 및 프리티어 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
lybell-art committed Aug 19, 2024
1 parent 6a6716b commit 45fe21c
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 136 deletions.
15 changes: 7 additions & 8 deletions src/adminPage/features/eventEdit/businessLogic/FcfsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,12 @@ function verifyItems(map, { startTime, endTime, prevSnapshot = new Map() }) {
return result;
}

function hasDuplicatedDate(newDate, map)
{
if(newDate === undefined) return true;
if(newDate === null) return false;
const dateSet = new Set([...map.values()].map( ({date})=>date?.valueOf() ?? null ));
function hasDuplicatedDate(newDate, map) {
if (newDate === undefined) return true;
if (newDate === null) return false;
const dateSet = new Set([...map.values()].map(({ date }) => date?.valueOf() ?? null));

if(dateSet.has(newDate.valueOf())) return true;
if (dateSet.has(newDate.valueOf())) return true;
return false;
}

Expand Down Expand Up @@ -206,12 +205,12 @@ class FcfsData {
const oldItem = newData.map.get(key);

const verified = verifyItem(
{...oldItem, ...data},
{ ...oldItem, ...data },
{ startTime, endTime, prevSnapshot: oldItem },
);
if (verified === null) newData.map.delete(key);
else {
if(hasDuplicatedDate(verified.date, this.map)) verified.date = oldItem.date;
if (hasDuplicatedDate(verified.date, this.map)) verified.date = oldItem.date;

newData.map.set(key, verified);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mainPage/features/comment/commentForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function CommentForm() {
setButtonFetchState(submitted ? "disabled" : "enabled");
})
.catch((e) => {
if(e.status === 401) {
if (e.status === 401) {
setButtonFetchState("enabled");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mainPage/features/comment/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const handlers = [
http.get("/api/v1/comment/info", ({ request }) => {
const token = request.headers.get("authorization");

if (token === null) return HttpResponse.json({ submitted: false }, {status: 401});
if (token === null) return HttpResponse.json({ submitted: false }, { status: 401 });
return HttpResponse.json({ submitted: false });
}),
http.get("/api/v1/comment/:eventFrameId", () => {
Expand Down
33 changes: 19 additions & 14 deletions src/mainPage/features/header/Hamburger/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { useState } from "react";
import style from "./style.module.css";

function HamburgerButton({children})
{
const [opened, setOpened] = useState(false);
return <>
<button className="flex md:hidden justify-center items-center size-6 z-10" aria-label="open-menu" onClick={ ()=>setOpened((state)=>!state) }>
<div className={style.hamburger} data-opened={opened} >
<div></div>
</div>
</button>
<div className="fixed -z-10 w-full top-0 left-0 bg-white flex md:hidden flex-col justify-center items-center gap-2">
<div className="w-full mt-16 shadow-xl">{opened && children}</div>
</div>
</>
function HamburgerButton({ children }) {
const [opened, setOpened] = useState(false);
return (
<>
<button
className="flex md:hidden justify-center items-center size-6 z-10"
aria-label="open-menu"
onClick={() => setOpened((state) => !state)}
>
<div className={style.hamburger} data-opened={opened}>
<div></div>
</div>
</button>
<div className="fixed -z-10 w-full top-0 left-0 bg-white flex md:hidden flex-col justify-center items-center gap-2">
<div className="w-full mt-16 shadow-xl">{opened && children}</div>
</div>
</>
);
}

export default HamburgerButton;
export default HamburgerButton;
69 changes: 35 additions & 34 deletions src/mainPage/features/header/Hamburger/style.module.css
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
.hamburger {
display: flex;
justify-content: center;
align-items: center;
position: relative;
width: 24px;
height: 20px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
width: 24px;
height: 20px;
}

.hamburger > div, .hamburger > div::before, .hamburger > div::after{
width: 100%;
height: 2px;
box-sizing: border-box;
background-color: currentColor;
transition: all 0.3s;
.hamburger > div,
.hamburger > div::before,
.hamburger > div::after {
width: 100%;
height: 2px;
box-sizing: border-box;
background-color: currentColor;
transition: all 0.3s;
}

.hamburger > div{
position: absolute;
border-color: #24adaf;
.hamburger > div {
position: absolute;
border-color: #24adaf;
}

.hamburger > div::before
{
content: "";
display: block;
position: absolute;
top:0;
left:0;
transform: translateY(-10px);
.hamburger > div::before {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
transform: translateY(-10px);
}

.hamburger > div::after{
content: "";
display: block;
position: absolute;
top:0;
left:0;
transform: translateY(10px);
.hamburger > div::after {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
transform: translateY(10px);
}

.hamburger[data-opened="true"] > div {
transform: rotate(135deg);
transform: rotate(135deg);
}

.hamburger[data-opened="true"] > div::before {
transform: translateY(0px) rotate(180deg);
transform: translateY(0px) rotate(180deg);
}

.hamburger[data-opened="true"] > div::after {
transform: translateY(-0px) rotate(-270deg);
}
transform: translateY(-0px) rotate(-270deg);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function GiftDetail({ contentList }) {
<div className="flex flex-col font-bold">
{contentList.map((content, index) => (
<div key={index} className="bg-neutral-900 p-6 mb-5 flex z-0 relative">
<img src={content.src} alt="경품" width="130" height="89" loading="lazy" />
<img src={content.src} alt="경품" width="130" height="89" loading="lazy" />

<div className="pl-8 flex flex-col">
<span className="text-body-m sm:text-body-l text-white">
Expand Down
9 changes: 8 additions & 1 deletion src/mainPage/features/simpleInformation/contentSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ export default function ContentSection({ content }) {
onAnimationEnd={() => setIsHighlighted(true)}
className={`${isVisible ? style.fadeIn : "opacity-0"} z-0 flex flex-col font-bold`}
>
<img src={content.src} alt={content.title} width="1200" height="456" className="w-full" loading="lazy" />
<img
src={content.src}
alt={content.title}
width="1200"
height="456"
className="w-full"
loading="lazy"
/>

<span className="pt-10 text-body-m sm:text-body-l text-neutral-800">{content.title}</span>

Expand Down
3 changes: 2 additions & 1 deletion src/mainPage/shared/auth/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ function isValidInput(name, phoneNumber) {
return name.length >= 2 && phoneNumber.length < 12 && phoneNumber.startsWith("01");
}

const token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZWFtLW9yYW5nZSIsImlhdCI6MTcyNDA0NDc5MCwiZXhwIjoxNzI0MDQ4MzkwLCJzdWIiOiJldmVudFVzZXIiLCJ1c2VyTmFtZSI6Iuq5gOyCoeu6qSIsInVzZXJJZCI6ImtpbXBpcHB5YXAiLCJyb2xlIjoiZXZlbnRfdXNlciJ9.m5m_PkwmYz5Mt-kjn28435bQtwgph3WO-2J42X82lCg";
const token =
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZWFtLW9yYW5nZSIsImlhdCI6MTcyNDA0NDc5MCwiZXhwIjoxNzI0MDQ4MzkwLCJzdWIiOiJldmVudFVzZXIiLCJ1c2VyTmFtZSI6Iuq5gOyCoeu6qSIsInVzZXJJZCI6ImtpbXBpcHB5YXAiLCJyb2xlIjoiZXZlbnRfdXNlciJ9.m5m_PkwmYz5Mt-kjn28435bQtwgph3WO-2J42X82lCg";

const handlers = [
http.post("/api/v1/event-user/send-auth", async ({ request }) => {
Expand Down
40 changes: 18 additions & 22 deletions src/mainPage/shared/auth/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,32 @@ import { SERVICE_TOKEN_ID } from "@common/constants.js";
const defaultUserState = {
isLogin: false,
userName: "",
}
};

class UserStore
{
class UserStore {
state;
observers = new Set();
constructor()
{
constructor() {
this.state = createUserStore();
}
getState(getter)
{
getState(getter) {
return getter(this.state);
}
subscribe(callback)
{
subscribe(callback) {
this.observers.add(callback);
return ()=>this.observers.delete(callback);
return () => this.observers.delete(callback);
}
setState(mutateFunc)
{
setState(mutateFunc) {
const oldState = this.state;
const newState = typeof mutateFunc === "function" ? mutateFunc(oldState) : mutateFunc;
if(oldState === newState) return;
if (oldState === newState) return;
this.state = newState;
this.observers.forEach( callback=>callback() );
this.observers.forEach((callback) => callback());
}
}

function createUserStore()
{
if(typeof window === "undefined") return defaultUserState;
function createUserStore() {
if (typeof window === "undefined") return defaultUserState;
tokenSaver.init(SERVICE_TOKEN_ID);
const token = tokenSaver.get(SERVICE_TOKEN_ID);
const userName = parseTokenToUserName(token);
Expand All @@ -50,8 +44,7 @@ function parseTokenToUserName(token) {
try {
const { userName } = jwtDecode(token);
return userName;
}
catch {
} catch {
return "사용자";
}
}
Expand All @@ -69,9 +62,12 @@ export function logout() {
userStore.setState(() => ({ isLogin: false, userName: "" }));
}

function useUserStore(func, defaultValue=defaultUserState)
{
return useSyncExternalStore(userStore.subscribe.bind(userStore), ()=>userStore.getState(func), ()=>func(defaultValue));
function useUserStore(func, defaultValue = defaultUserState) {
return useSyncExternalStore(
userStore.subscribe.bind(userStore),
() => userStore.getState(func),
() => func(defaultValue),
);
}

export default useUserStore;
8 changes: 7 additions & 1 deletion src/mainPage/shared/components/ResetButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import RefreshIcon from "./refresh.svg?react";

export default function ResetButton({ onClick }) {
return (
<Button onClick={onClick} styleType="ghost" backdrop="dark" aria-label="refresh" className="p-1 xl:p-2">
<Button
onClick={onClick}
styleType="ghost"
backdrop="dark"
aria-label="refresh"
className="p-1 xl:p-2"
>
<RefreshIcon />
</Button>
);
Expand Down
Loading

0 comments on commit 45fe21c

Please sign in to comment.