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

[REFACTOR] 자잘한 버그 해결 #43

Merged
merged 8 commits into from
Mar 10, 2024
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ function App() {
];

const businessHomeUrl = "/dashboard"
const adminHomeUrl = "/admin/plan"
const adminHomeUrl = "/admin/business"

return (
<BrowserRouter>
20 changes: 20 additions & 0 deletions src/api/business/planDetail/withdrawPlan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import userInstance from "../../userBaseApi";

/**
* @since 2024.03.10
* @author 김유빈
*/
const WithdrawPlan = {

/**
* 사업계획서 철회
*
* @since 2024.03.10
* @author 김유빈
*/
withdraw: async (planId) => {
return await userInstance.post(`/plans/${planId}/withdraw`)
}
}

export default WithdrawPlan;
2 changes: 1 addition & 1 deletion src/components/Plan/AdminPlanDetail.jsx
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ const AdminPlanDetail = ( {planId, onChangeStatus}) => {
return (
<>
<TwoInput
firstInput={<InputDate title="오픈 일정" placeholder={planData ? planData.openDate : ''} />}
firstInput={<InputDate title="오픈 일정" value={planData ? planData.openDate.replaceAll(".", "-") : ''} />}
secondInput={<InputText title="진행단계" value={planData ? planData.entranceStatus : ''} />}
/>
<TwoInput
79 changes: 46 additions & 33 deletions src/components/Plan/PlanDetail.jsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,20 @@
import {useEffect, useState} from "react";
import TwoInput from "../common/Input/TwoInput";
import InputDate from "../common/Input/InputDate";
import InputText from "../common/Input/InputText";
import MyPlanDetailApi from "../../api/business/planDetail/myPlanDetailApi";
import WithdrawPlan from "../../api/business/planDetail/withdrawPlan";

/**
* PlanDetail 컴포넌트 생성
*
* @since 2024.02.25
* @author 김유빈
*/
const PlanDetail = ( {planId, onChangeStatus}) => {
/**
* PlanDetail 컴포넌트 Plan으로 분리 및 API 연결
*
* @since 2024.02.29
* @author 이상민
*/
const [planData, setPlanData] = useState(null);
const [planDetailStatus, setPlanDetailStatus] = useState('');
useEffect(() => {
const fetchPlanData = async () => {
try {
const response = await MyPlanDetailApi.getPlan(planId);
console.log(response);
setPlanData(response.data.data);

setPlanDetailStatus(response.data.data.entranceStatus);
} catch (error) {
console.error('Error fetching plan data:', error);
}
};
fetchPlanData();
}, [planId]);
const PlanDetail = ({planData}) => {

if (!planData) {
return <p>Loading...</p>;
}

onChangeStatus(planDetailStatus);

/**
* 파일 다운로드
*
@@ -55,19 +30,36 @@ const PlanDetail = ( {planId, onChangeStatus}) => {
document.body.removeChild(link);
};

/**
* 입점 철회 api 연동
*
* @since 2024.03.10
* @author 김유빈
*/
const handleWithdraw = async () => {
try {
const response = await WithdrawPlan.withdraw(planData.planId);
if (response.status === 200) {
window.location.href = `/plans/${planData.planId}`
}
} catch (error) {
console.error('Error approving plan:', error);
}
};

return (
<>
<TwoInput
firstInput={<InputDate title="오픈 일정" placeholder={planData ? planData.openDate : ''} />}
secondInput={<InputText title="진행단계" value={planData ? planData.entranceStatus : ''} />}
firstInput={<InputDate title="오픈 일정" value={planData.openDate} />}
secondInput={<InputText title="진행단계" value={planData.entranceStatus} />}
/>
<TwoInput
firstInput={<InputText title="오픈 지점" value={`${planData ? planData.office : ''} ${planData ? planData.floor : ''}`} />}
secondInput={<InputText title="카테고리" value={planData ? planData.category : ''} />}
firstInput={<InputText title="오픈 지점" value={`${planData.office} ${planData.floor}`} />}
secondInput={<InputText title="카테고리" value={planData.category} />}
/>
<TwoInput
firstInput={<InputText title="연락처" value={planData ? planData.contactInformation : ''} />}
secondInput={<InputText title="작성일" value={planData ? planData.createdDate : ''} />}
firstInput={<InputText title="연락처" value={planData.contactInformation} />}
secondInput={<InputText title="작성일" value={planData.createdDate} />}
/>

<div className="flex-auto mr-5">
@@ -81,6 +73,27 @@ const PlanDetail = ( {planId, onChangeStatus}) => {
파일 다운로드
</button>
</div>
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<div style={{ display: 'flex', marginTop: '20px' }}>
{
planData.entranceStatus === '입점 요청' && (
<button
style={{
padding: '10px 20px',
backgroundColor: 'LightSkyBlue',
color: 'white',
borderRadius: '5px',
margin: '0 5px',
cursor: 'pointer',
}}
onClick={handleWithdraw}
disabled={false}>
입점 철회
</button>
)
}
</div>
</div>
</>
)
}
3 changes: 2 additions & 1 deletion src/components/common/Input/InputDate.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import 'flowbite/dist/datepicker.turbo.js';
* @since 2024.02.25
* @author 김유빈
*/
function InputDate({title, placeholder, onChange}) {
function InputDate({title, placeholder, value, onChange}) {
return (
<div className="relative mb-6">
<label htmlFor="default-input"
@@ -18,6 +18,7 @@ function InputDate({title, placeholder, onChange}) {
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500
focus:border-blue-500 block w-full p-2.5"
placeholder={placeholder}
value={value}
onChange={onChange}/>
</div>
)
14 changes: 10 additions & 4 deletions src/pages/administrator/adminPlanDetail.jsx
Original file line number Diff line number Diff line change
@@ -27,9 +27,11 @@ const AdminPlainDetail = () => {
console.log(longPlanId);
try {
alert("정말 입점 대기 시키실 건가요?")
await AdminPlanApi.postWait(longPlanId);
const response = await AdminPlanApi.postWait(longPlanId);
alert("입정 대기 완료되었습니다.")
navigate("/admin/plan"); // 페이지 이동
if (response.status === 200) {
window.location.href = `/admin/plan/${longPlanId}`
}
} catch (error) {
console.error('Error approving plan:', error);
}
@@ -40,7 +42,9 @@ const AdminPlainDetail = () => {
alert("정말 입정 승인 시키실 건가요?")
const response = await AdminPlanApi.postApprove(longPlanId);
alert('입점이 승인되었습니다.');
navigate('/admin/plan'); // 페이지 이동
if (response.status === 200) {
window.location.href = `/admin/plan/${longPlanId}`
}
} catch (error) {
console.error('Error approving plan:', error);
}
@@ -51,7 +55,9 @@ const AdminPlainDetail = () => {
alert("정말 입정 거절 시키실 건가요?")
const response = await AdminPlanApi.postDeny(longPlanId);
alert('입점이 거절되었습니다.');
navigate('/admin/plan'); // 페이지 이동
if (response.status === 200) {
window.location.href = `/admin/plan/${longPlanId}`
}
} catch (error) {
console.error('Error rejecting plan:', error);
}
2 changes: 1 addition & 1 deletion src/pages/business/ad.jsx
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ function convertAboutPost(setPrice, setPostType, setMainImage, setPosts, onChang
let data = null
let mainImage = <></>
if (value === "popup") {
price = 1_000_000
price = 500_000
const response = await MyPopupApi.getMyPopups(0, 5)
data = response.data.data.popups.map(popup => {
const createdDate = popup.pulledDate.split(" ")[0];
5 changes: 4 additions & 1 deletion src/pages/business/createPlan.jsx
Original file line number Diff line number Diff line change
@@ -48,7 +48,10 @@ const CreatePlan = () => {
"contactInformation": phoneNumber,
"category": category
}
const response = await PlanApi.save(data, file);
const response = await PlanApi.save(data, file)
if (response.status === 200) {
window.location.href = `/plans/${response.data.data}`
}
} catch (error) {
console.error("저장 중 에러 발생: ", error);
}
74 changes: 58 additions & 16 deletions src/pages/business/plan.jsx
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import 'tui-color-picker/dist/tui-color-picker.css';
import '@toast-ui/editor-plugin-color-syntax/dist/toastui-editor-plugin-color-syntax.css';
import './planViewer.css';
import FloatingButton from "../../components/business/FloatingButton/FloatingButton";
import MyPlanDetailApi from "../../api/business/planDetail/myPlanDetailApi";

/**
* Plan 페이지 제작
@@ -24,8 +25,8 @@ import FloatingButton from "../../components/business/FloatingButton/FloatingBut
const Plan = () => {

const { planId } = useParams();
const [planDetailStatus, setPlanDetailStatus] = useState('');

const [planData, setPlanData] = useState(null);
const [popupTitle, setPopupTitle] = useState("");
const [popupDescription, setPopupDescription] = useState("");

@@ -42,6 +43,37 @@ const Plan = () => {
popupView: 0
});

/**
* PlanDetail 컴포넌트 Plan으로 분리 및 API 연결
*
* @since 2024.02.29
* @author 이상민
*/
useEffect(() => {
const fetchPlanData = async () => {
try {
const response = await MyPlanDetailApi.getPlan(planId);
const data = response.data.data;
const plan = {
planId: data.planId,
openDate: data.openDate.replaceAll(".", "-"),
entranceStatus: data.entranceStatus ? data.entranceStatus : '',
category: data.category ? data.category : '',
office: data.office ? data.office : '',
floor: data.floor ? data.floor : '',
contactInformation: data.contactInformation ? data.contactInformation : '',
createdDate: data.createdDate ? data.createdDate : '',
businessPlanUrl: data.businessPlanUrl,
}
console.log(plan)
setPlanData(plan);
} catch (error) {
console.error('Error fetching plan data:', error);
}
};
fetchPlanData();
}, [planId]);

/**
* 사업계획서에 따른 팝업 게시글 정보 보기 api 연결
*
@@ -78,6 +110,9 @@ const Plan = () => {
if (result.data.message) {
alert(result.data.message);
}
if (result.status === 200) {
window.location.href = `/plans/${planId}`
}
const response = await PopupApi.findByPlanId(planId);
setPopupData(response.data.data);
} catch (error) {
@@ -88,21 +123,28 @@ const Plan = () => {
return (
<div className="plan">
<ContentBox title="사업계획서 정보"
content={<PlanDetail planId={planId} onChangeStatus={setPlanDetailStatus}/>}/>
<ContentBox title="팝업스토어 게시글 정보"
content={
<>
<PopupDetail
popupData={popupData}
onTitleChange={setPopupTitle}
onDescriptionChange={setPopupDescription}
/>
{popupData.popupWritten === false && (
<Button onClick={popupWrite} text="팝업게시글 작성하기"/>
)}
</>
}/>
<ContentBox title="팝업스토어 게시글 부가 정보" content={<PopupExtraDetail popupData={popupData}/>}/>
content={<PlanDetail planData={planData}/>}/>
{
planData && planData.entranceStatus === '입점 승인' && (
<>
<ContentBox title="팝업스토어 게시글 정보"
content={
<>
<PopupDetail
popupData={popupData}
onTitleChange={setPopupTitle}
onDescriptionChange={setPopupDescription}
/>
{popupData.popupWritten === false && (
<Button onClick={popupWrite} text="팝업게시글 작성하기"/>
)}
</>
}
/>
<ContentBox title="팝업스토어 게시글 부가 정보" content={<PopupExtraDetail popupData={popupData}/>}/>
</>
)
}
<FloatingButton />
</div>
);