Skip to content

Commit

Permalink
Merge pull request #64 from jobofbrothers-sobok/feature/#59
Browse files Browse the repository at this point in the history
feat: 최고관리자 회원정보 조회 및 회원가입 승인 API 연동
  • Loading branch information
ymj07168 authored Jul 7, 2023
2 parents f1a3cd5 + f9c38d5 commit fe7bf61
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 29 deletions.
37 changes: 37 additions & 0 deletions src/lib/api/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import axios from "axios";
import { getCookie } from "../cookie";

const PROXY = window.location.hostname === 'localhost' ? '' : '/proxy';

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

// 점주 회원정보 전체 조회
export const readAllOwner = async (sort, config) => {
return await axios.get(`${PROXY}/manager/owner?sort=${sort}`, config)
}

// 점주 회원정보 상세 조회
export const readDetailOwner = async (id, config) => {
return await axios.get(`${PROXY}/manager/owner/${id}`, config)
}

// 점주 회원가입 승인
export const postOwnerApproval = async (id, config) => {
return await axios.post(`${PROXY}/manager/grant/${id}`, {}, config)
}

// 고객 회원정보 전체 조회
export const readAllClient = async (config) => {
return await axios.get(`${PROXY}/manager/client`, config)
}

// 고객 회원정보 상세 조회
export const readDetailClient = async (id, config) => {
return await axios.get(`${PROXY}/manager/client/${id}`, config)
}
87 changes: 70 additions & 17 deletions src/pages/mypage/admin/MemberDetail.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,67 @@
import React, { useState } from "react";
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 { postOwnerApproval, readDetailClient, readDetailOwner } from "../../../lib/api/admin";
import { getCookie } from "../../../lib/cookie";
import { useNavigate, useParams } from "react-router-dom";

const MemberDetail = () => {

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

const navigator = useNavigate();

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

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

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

// 고객 상세 정보
const { name, stampCount, couponCount } = clientInfo;

let config = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${getCookie('token')}`,
'withCredentials': true,
}
}
// 점주 상세 정보 조회
const getDetailOwner = async (id) => {
console.log('id', id);
const json = await readDetailOwner(id, config);
setOwnerInfo(json.data.data);
};

// 고객 상세 정보 조회
const getDetailClient = async (id) => {
const json = await readDetailClient(id, config);
setClientInfo(json.data.data);
};

// 점주 회원가입 승인
const OwnerApproval = async (id) => {
await postOwnerApproval(id, config)
.then((res) => { console.log(res); alert('점주 회원가입 승인 완료되었습니다.'); navigator('/admin/menu/0'); })
.catch((err) => { console.log(err); alert('점주 회원가입 승인 실패하였습니다.'); })
}

useEffect(() => {
if (isowner) {
getDetailOwner(id);
}
else {
getDetailClient(id);
}
}, []);

return (
<>
Expand All @@ -16,69 +70,68 @@ const MemberDetail = () => {
<BackButton />
<div className="info-form">
<br />
<p className="title">고법짱짱123</p>
{isowner ? <Button text="권한 승인" color="#7F7F7F" /> : <></>}
<p className="title">{isowner ? director : name}</p>
{isowner && !authorized ? <Button text="권한 승인" color="#7F7F7F" onClick={() => OwnerApproval(id)} /> : <></>}
<div className="info-div">
<p className="info-title">회원 정보</p>
<hr />
{isowner ?
<>
<div className="info-item">
<p className="info-name">매장명</p>
<p className="info-value">메가커피</p>
<p className="info-value">{store}</p>
</div>
<div className="info-item">
<p className="info-name">담당자명</p>
<p className="info-value">메가커피</p>
<p className="info-value">{director}</p>
</div>
<div className="info-item">
<p className="info-name">담당자 번호</p>
<p className="info-value">메가커피</p>
<p className="info-value">{phone}</p>
</div>
<div className="info-item">
<p className="info-name">담당자 이메일</p>
<p className="info-value">메가커피</p>
<p className="info-value">{email}</p>
</div>
<div className="info-item">
<p className="info-name">가게 주소</p>
<p className="info-value">메가커피</p>
<p className="info-value">{address}</p>
</div>
<div className="info-item">
<p className="info-name">사업자 등록 번호</p>
<p className="info-value">메가커피</p>
<p className="info-value">{licenseNumber}</p>
</div>
<div className="info-item">
<p className="info-name">사업자 등록증</p>
<input type="file" />
</div>
</>
:
<>
<div className="info-item">
<p className="info-name">이름</p>
<p className="info-value">고법</p>
<p className="info-value">{name}</p>
</div>
<div className="info-item">
<p className="info-name">이메일</p>
<p className="info-value">[email protected]</p>
<p className="info-value">{clientInfo?.email}</p>
</div>
<div className="info-item">
<p className="info-name">핸드폰 번호</p>
<p className="info-value">010-6270-1143</p>
<p className="info-value">{clientInfo?.phone}</p>
</div>
<div className="info-item">
<p className="info-name">스템프 정보</p>
<p className="info-value">34 스템프 적립</p>
<p className="info-value">{stampCount} 스템프 적립</p>
</div>
<div className="info-item">
<p className="info-name">쿠폰 사용</p>
<p className="info-value">3장 사용</p>
<p className="info-value">{couponCount} 사용</p>
</div>
</>
}

</div>
<Button text="목록으로" color="#FF9F74" />
<Button text="목록으로" color="#FF9F74" onClick={() => navigator('/admin/menu/0')} />
</div>
</Container>
<Footer />
Expand Down
63 changes: 51 additions & 12 deletions src/pages/mypage/admin/MemberInfo.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import SearchBox from "../../../components/common/SearchBox";
import styled from "styled-components";
import dummy from "../../../data/data.json";
import active from '../../../asset/images/active.svg';
import { useNavigate } from "react-router-dom";
import MoreButton from "../../../components/common/MoreButton";
import filterbtn from "../../../asset/images/filter-arrow.svg";
import { readAllClient, readAllOwner } from "../../../lib/api/admin";
import { getCookie, setCookie } from "../../../lib/cookie";


const NewOwnerList = () => {

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

const navigator = useNavigate();


const [sort, setSort] = useState('all');

const [ownerList, setOwnerList] = useState([]);
const [clientList, setClientList] = useState([]);

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

const getAllOwner = async () => {
const json = await readAllOwner(sort, config);
setOwnerList(json.data.data);
};

const getAllClient = async () => {
const json = await readAllClient(config);
setClientList(json.data.data);
};

useEffect(() => {
if (isowner) {
getAllOwner();
setCookie('isowner', isowner);
}
else {
getAllClient();
setCookie('isowner', isowner);
}
}, [sort, isowner]);


return (
<>
<Container>
Expand All @@ -33,28 +71,29 @@ const NewOwnerList = () => {
<br />
<div className="list-top-box">
<p className="info-title">회원정보</p>
<FilterBox name="category">
<option value="event">미승인</option>
<option value="new-menu">승인완료</option>
</FilterBox>
{isowner ? <FilterBox name="category" onChange={(e) => setSort(e.target.value)}>
<option value="all">전체</option>
<option value="pending">미승인</option>
<option value="auth">승인완료</option>
</FilterBox> : <></>}
</div>
<hr />
{
isowner ?
dummy.owner.map((item, index) => (
ownerList.map((item, index) => (
<div className='apply-item' key={item.id} onClick={() => navigator(`/admin/menu/0/member/${item.id}`)}>
<div>
<div className='item-title'>{item.active ? <img src={active} alt='확인요청' width="10px" /> : null}{item.name}</div>
<div className='item-category'>{item.store} / {item.tel}</div>
<div className='item-title'>{item.active ? <img src={active} alt='확인요청' width="10px" /> : null}{item.director}</div>
<div className='item-category'>{item.store} / {item.phone}</div>
</div>
</div>
))
:
dummy.customer.map((item, index) => (
clientList.map((item, index) => (
<div className='apply-item' key={item.id} onClick={() => navigator(`/admin/menu/0/member/${item.id}`)}>
<div>
<div className='item-title'>{item.active ? <img src={active} alt='확인요청' width="10px" /> : null}{item.nickname}</div>
<div className='item-category'>{item.name} / {item.email} / {item.tel}</div>
<div className='item-title'>{item.active ? <img src={active} alt='확인요청' width="10px" /> : null}{item.loginId}</div>
<div className='item-category'>{item.name} / {item.email} / {item.phone}</div>
</div>
<div className="cupon-stamp">
보유쿠폰 {item.cupon}<br />
Expand Down

0 comments on commit fe7bf61

Please sign in to comment.