Skip to content

Commit

Permalink
Merge pull request #69 from jobofbrothers-sobok/feature/#59
Browse files Browse the repository at this point in the history
feat: 점주 스탬프 정보 조회 및 권한 승인 API 연동
  • Loading branch information
ymj07168 authored Jul 9, 2023
2 parents ffb24d9 + 00aa3a9 commit 6251d86
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/Routers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import NoticePage from "./pages/main/NoticePage";
import NoticeDetail from "./pages/main/NoticeDetail";
import InquiryPage from "./pages/main/InquiryPage";
import AgreePage from "./pages/login/AgreePage";
import StampMemberDetail from "./pages/mypage/admin/StampMemberDetail";

const Routers = () => {
return (
Expand All @@ -57,10 +58,12 @@ const Routers = () => {
{/* 최고관리자 마이페이지 */}
<Route element={<AdminPage />} path='/admin' />
<Route element={<AdminMenuDetail />} path='/admin/menu/:id' />
<Route element={<MemberDetail />} path='/admin/menu/:id/member/:id' />
<Route element={<MemberDetail />} path='/admin/menu/0/member/:id' />
<Route element={<AddStampTour />} path='/admin/menu/2/add-stamp-tour' />
<Route element={<ManagerDetail />} path='/admin/menu/3/detail/:id' />
<Route element={<DeliveryDetail />} path='/admin/menu/4/detail/:id' />
<Route element={<AddStampTour />} path='/admin/menu/2/add-stamp-tour' />
<Route element={<StampMemberDetail />} path='/admin/menu/6/member/:id' />

{/* 점주 마이페이지 */}
<Route element={<OwnerPage />} path='/owner' />
<Route element={<OwnerMenuDetail />} path='/owner/menu/:id' />
Expand Down
27 changes: 26 additions & 1 deletion src/lib/api/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,18 @@ export const getAllStampTour = async (config) => {

// 스탬프 투어 등록
export const postStampTour = async (keyword, title, reward, cafeList, file, config) => {
return await axios.post(`${PROXY}/manager/tour`, config);
let formData = new FormData();
formData.append('keyword', keyword);
formData.append('title', title);
formData.append('reward', reward);
formData.append('cafeList', cafeList);
formData.append('file', file);
return await axios.post(`${PROXY}/manager/tour`, formData, config);
}

// 스탬프 투어 등록시 매장 검색
export const searchStore = async (keyword, config) => {
return await axios.get(`${PROXY}/manager/tour/search`, { storeName: keyword }, config);
}

// 배송 신청 전체 조회
Expand All @@ -65,3 +76,17 @@ export const postNotice = async (title, content, file, config) => {
return await axios.post(`${PROXY}/manager`, formData, config);
}

// 스탬프 사용 회원 전체 조회
export const getAllStampMember = async (config) => {
return await axios.get(`${PROXY}/manager/stamp`, config);
}

// 스탬프 사용 회원 상세 조회
export const getStampMemberDetail = async (id, config) => {
return await axios.get(`${PROXY}/manager/stamp/${id}`, config);
}

// 점주 회원가입 승인
export const postStampApproval = async (id, config) => {
return await axios.post(`${PROXY}/manager/stamp/${id}`, {}, config);
}
4 changes: 3 additions & 1 deletion src/pages/mypage/admin/AdminMenuDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import StampInfo from "./StampInfo";
import DeliveryList from "./DeliveryList";
import AddNotice from "./AddNotice";
import InquiriesList from "./InquiriesList";
import StampMemberInfo from "./StampMemberInfo";

const AdminMenuDetail = () => {

Expand All @@ -28,7 +29,8 @@ const AdminMenuDetail = () => {
id === '3' ? <DeliveryList /> :
id === '4' ? <AddNotice /> :
id === '5' ? <InquiriesList /> :
<>no menu</>}
id === '6' ? <StampMemberInfo /> :
<>no menu</>}
</Container>
<Footer />
</>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/mypage/admin/AdminPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const AdminPage = () => {

const navigator = useNavigate();

const menuList = ['소복 회원 정보', '스템프 정보', '소복 매니저 신청 리스트', '배송 신청 리스트', '공지글 작성하기', '문의사항 등록 리스트']
const menuList = ['소복 회원 정보', '스템프 정보', '소복 매니저 신청 리스트', '배송 신청 리스트', '공지글 작성하기', '문의사항 등록 리스트', '점주 스탬프 승인']
return (
<>
<NavBar />
Expand Down
4 changes: 2 additions & 2 deletions src/pages/mypage/admin/MemberInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { readAllClient, readAllOwner } from "../../../lib/api/admin";
import { getCookie, setCookie } from "../../../lib/cookie";


const NewOwnerList = () => {
const MemberInfo = () => {

const [isowner, setOwner] = useState(getCookie('isowner') === 'true' ? true : false);

Expand Down Expand Up @@ -108,7 +108,7 @@ const NewOwnerList = () => {
)
}

export default NewOwnerList;
export default MemberInfo;

const Container = styled.div`
width: 100%;
Expand Down
147 changes: 147 additions & 0 deletions src/pages/mypage/admin/StampMemberDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import React, { useEffect, useState } from "react";
import styled from "styled-components";
import Button from "../../../components/common/Button";
import NavBar from "../../../components/common/NavBar";
import BackButton from "../../../components/common/BackButton";
import Footer from "../../../components/common/Footer";
import { getStampMemberDetail, postOwnerApproval, postStampApproval } from "../../../lib/api/admin";
import { getCookie } from "../../../lib/cookie";
import { useNavigate, useParams } from "react-router-dom";

const StampMemberDetail = () => {

const navigator = useNavigate();

// 점주, 고객 id
const { id } = useParams();

const [ownerInfo, setOwnerInfo] = useState('');

// 점주 상세 정보
const { store, director, phone, email, address, licenseNumber, licenseImage, stampAuthorized } = ownerInfo;


let config = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${getCookie('token')}`,
'withCredentials': true,
}
}

// 점주 상세 정보 조회
const getDetailOwner = async () => {
const json = await getStampMemberDetail(id, config);
setOwnerInfo(json.data.data);
};


// 점주 스탬프 권한 승인
const StampApproval = async (id) => {
await postStampApproval(id, config)
.then((res) => { console.log(res); alert('점주 스탬프 권한 승인 완료되었습니다.'); navigator('/admin/menu/0'); })
.catch((err) => { console.log(err); alert('점주 스탬프 권한 승인에 실패하였습니다.'); })
}

useEffect(() => {
getDetailOwner();
}, []);

return (
<>
<NavBar />
<Container>
<BackButton />
<div className="info-form">
<br />
<p className="title">{director}</p>
{stampAuthorized ? <></> : <Button text="권한 승인" color="#7F7F7F" onClick={() => StampApproval(id)} />}
<div className="info-div">
<p className="info-title">회원 정보</p>
<hr />
<div className="info-item">
<p className="info-name">매장명</p>
<p className="info-value">{store}</p>
</div>
<div className="info-item">
<p className="info-name">담당자명</p>
<p className="info-value">{director}</p>
</div>
<div className="info-item">
<p className="info-name">담당자 번호</p>
<p className="info-value">{phone}</p>
</div>
<div className="info-item">
<p className="info-name">담당자 이메일</p>
<p className="info-value">{email}</p>
</div>
<div className="info-item">
<p className="info-name">가게 주소</p>
<p className="info-value">{address}</p>
</div>
<div className="info-item">
<p className="info-name">사업자 등록 번호</p>
<p className="info-value">{licenseNumber}</p>
</div>
<div className="info-item">
<p className="info-name">사업자 등록증</p>
</div>

</div>
<Button text="목록으로" color="#FF9F74" onClick={() => navigator('/admin/menu/0')} />
</div>
</Container>
<Footer />
</>
)
}

export default StampMemberDetail;

const Container = styled.div`
width: 100%;
padding: 0 20px 20px;
box-sizing: border-box;
display: flex;
flex-direction: column;
margin: 0 auto;
justify-content: center;
align-items: center;
margin-top: 70px;
.title{
text-align: center;
font-weight: 600;
font-size: 23px;
line-height: 20px;
letter-spacing: -0.08em;
color: #222222;
margin-bottom: 10px;
}
.info-title{
font-weight: 600;
font-size: 20px;
line-height: 20px;
letter-spacing: -0.08em;
color: #222222;
margin-bottom: 10px;
}
.info-item{
border-bottom: 1px solid #E0E0E0;
padding: 15px 2px;
line-height: 20px;
}
.info-form{
width: 100%;
display: flex;
flex-direction: column;
gap: 20px;
}
.info-name{
font-size: 13px;
color: #7F7F7F;
}
.info-value{
font-weight: 500;
color: #222222;
}
`
Loading

0 comments on commit 6251d86

Please sign in to comment.