-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: 최고관리자 회원정보 조회 및 회원가입 승인 API 연동
- Loading branch information
Showing
3 changed files
with
158 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( | ||
<> | ||
|
@@ -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 /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters