Skip to content

Commit

Permalink
Merge pull request #130 from softeerbootcamp4th/feature/122-admin-user
Browse files Browse the repository at this point in the history
[fix] 잡다하게 수정
  • Loading branch information
lybell-art authored Aug 22, 2024
2 parents 95f374f + e04d7b5 commit 1924be5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 33 deletions.
19 changes: 3 additions & 16 deletions src/adminPage/features/comment/id/Comments.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from "@common/dataFetch/getQuery.js";
import { fetchServer } from "@common/dataFetch/fetchServer.js";
import { formatDate } from "@common/utils.js";
import Pagination from "@admin/components/Pagination";
import { useState } from "react";

Expand Down Expand Up @@ -27,20 +28,6 @@ export default function Comments({
[page, searchString],
);

function getDate(createdAt) {
const yy = createdAt.slice(2, 4);
const mm = createdAt.slice(5, 7);
const dd = createdAt.slice(8, 10);
return `${yy}-${mm}-${dd}`;
}

function getTime(createdAt) {
const hh = createdAt.slice(11, 13);
const mm = createdAt.slice(14, 16);
const ss = createdAt.slice(17, 19);
return `${hh}:${mm}:${ss}`;
}

function checkComment(id) {
if (checkedComments.has(id)) {
setCheckedComments((oldSet) => {
Expand Down Expand Up @@ -69,9 +56,9 @@ export default function Comments({
/>

<div className="place-self-center flex items-center gap-1 text-body-s">
<span>{getDate(comment.createdAt)}</span>
<span>{formatDate(comment.createdAt, "YY-MM-DD")}</span>

<span className="text-neutral-500">{getTime(comment.createdAt)}</span>
<span className="text-neutral-500">{formatDate(comment.createdAt, "hh:mm:ss")}</span>
</div>

<span className="pr-4 overflow-hidden text-body-s text-ellipsis">{comment.content}</span>
Expand Down
21 changes: 10 additions & 11 deletions src/adminPage/features/comment/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ export default function AdminComment() {
}

function onChangeForm(e) {
const newString = e.target.value.replace(/[^0-9]/g, "");
const filteredFormString = formString.replace(/[^0-9]/g, "");
let newString = e.target.value.replace(/[^0-9]/g, "");

if (newString.length > 9) return;
if (!newString) {
newString = "";
} else if (newString.length <= 6) {
newString = "HD_" + newString;
} else if (newString.length <= 9) {
newString = "HD_" + newString.slice(0, 6) + "_" + newString.slice(6);
} else return;

if (newString !== filteredFormString) {
if (newString !== formString) {
if (newString.length >= 6) {
setSelectedEvent(-1);
setIsSpread(true);
Expand All @@ -34,13 +39,7 @@ export default function AdminComment() {
setIsSpread(false);
}
}
if (!newString) {
setFormString("");
} else if (newString.length <= 6) {
setFormString("HD_" + newString);
} else {
setFormString("HD_" + newString.slice(0, 6) + "_" + newString.slice(6));
}
setFormString(newString);
}

function searchEvent(e, eventId) {
Expand Down
10 changes: 6 additions & 4 deletions src/adminPage/features/eventEdit/FcfsInput/FcfsItemInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { EventEditDispatchContext } from "../businessLogic/context.js";
import { Input } from "@admin/components/SmallInput.jsx";
import DateInput from "@admin/components/DateInput";
import DeleteButton from "@admin/components/DeleteButton";
import { formatDate, padNumber } from "@common/utils.js";
import { formatDate, padNumber, getDayDifference } from "@common/utils.js";
import fcfsInputGridStyle from "./tableStyle.js";
import serverTimeStore from "@admin/serverTime/store.js";

const MINUTE = 60;

Expand Down Expand Up @@ -34,9 +35,10 @@ function FcfsItemInput({ uniqueKey, date, start, end, participantCount, prizeInf
) : (
<DateInput
date={date}
setDate={(date) =>
dispatch({ type: "modify_fcfs_item", key: uniqueKey, value: { date } })
}
setDate={(date) => {
if (getDayDifference(serverTimeStore.getState().serverTime, date) <= 0) return;
dispatch({ type: "modify_fcfs_item", key: uniqueKey, value: { date } });
}}
required
size="4"
/>
Expand Down
5 changes: 3 additions & 2 deletions src/mainPage/shared/auth/requestAuthCode.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { fetchServer, handleError } from "@/common/dataFetch/fetchServer.js";
import { EVENT_ID } from "@common/constants";

async function requestAuthCode(name, phoneNumber) {
try {
const body = { name, phoneNumber: phoneNumber.replace(/\D+/g, "") };
await fetchServer("/api/v1/event-user/send-auth", {
await fetchServer(`/api/v1/event-user/send-auth/${EVENT_ID}`, {
method: "post",
body,
});
return "";
} catch (e) {
return handleError({
400: "잘못된 요청 형식입니다.",
409: "등록된 참여자 정보가 있습니다.",
409: "이미 등록된 전화번호가 존재합니다. 하단의 '이미 정보를 입력하신 적이 있으신가요?'를 클릭하세요.",
})(e);
}
}
Expand Down

0 comments on commit 1924be5

Please sign in to comment.