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

Feat 회원정보 조회, 수정, 회원탈퇴 팝업 구현 #69

Merged
merged 11 commits into from
Dec 19, 2023
28 changes: 13 additions & 15 deletions src/axios-interceptor.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
import axios from "axios"
import sweetAlert from './util/modal.js'

var apiClient = null;
var apiClient = null
apiClient = axios.create({
// baseURL: "//" + "192.168.1.116:8881/codesparring",
baseURL: import.meta.env.VITE_BACK_URL,
withCredentials: true
});
})

apiClient.interceptors.request.use(
function (config) {
// config.headers["Content-Type"] = "application/json";
// config.headers["Content-Type"] = "multipart/form-data";
config.headers["Authorization"] = `Bearer ${sessionStorage.getItem('accessToken')}`;
return config;
config.headers["Authorization"] = `Bearer ${sessionStorage.getItem('accessToken')}`
return config
}
)



apiClient.interceptors.response.use(res => {
if (!(res.status === 200 || res.status === 201 || res.status === 204)) throw new Error();
if (res.data.errors) throw new Error(res.data.errors);
if (!(res.status === 200 || res.status === 201 || res.status === 204)) throw new Error()
if (res.data.errors) throw new Error(res.data.errors)

return res;
return res
}

,async (error) => {
if (error.response?.status === 401) {
sweetAlert.warning("로그인이 필요합니다", '', '로그인창으로 가기').then(() =>{
window.location.href='/login';
window.location.href='/login'
})
}
if (error.response?.status === 403) {
console.error("403 Forbidden 에러 발생 :", error.response);
console.error("403 Forbidden 에러 발생 :", error.response)
sweetAlert.error("권한이 없습니다", '', '뒤로 가기').then(() =>{
window.history.back();
window.history.back()
})
}

if (error.response?.status === 500) {
console.error("500 Internal Server Error 발생 :", error.response)
sweetAlert.error("오류가 발생했습니다", '', '닫기').then(() =>{
// window.history.back();
sweetAlert.error(error.response.data.errors[0], '', '닫기').then(() =>{
})

}
return Promise.reject(error);
return Promise.reject(error)
}

// ,async (error) => {
Expand Down Expand Up @@ -94,4 +92,4 @@ apiClient.interceptors.response.use(res => {
// }
);

export {apiClient};
export {apiClient}
75 changes: 36 additions & 39 deletions src/components/admin/AdminReportPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@
<AddReportComment v-if="reportModal" id="report-popup" @close-modal="offReportModal"
:reportNo="selectedReportNo" @report-deleted="handleReportDeleted"></AddReportComment>

{{ totalPage }} : {{ startPage }} : {{ endPage }}
<div v-if="!reportModal" id="report-page">
<button v-if="startPage > 1" class="page-bt" id="prev" @click="pgPrevClick">◀</button>&nbsp;
<button v-for="pg in endPage - startPage + 1" :key="pg"
:class="['page-bt-num', { 'current-page': startPage + pg - 1 == currentPage }]"
:id="'pg' + (startPage + pg - 1)" @click="pgClick">
{{ startPage + pg - 1 }}
</button>&nbsp;
<button v-if="endPage < totalPage" class="page-bt" id="next" @click="pgNextClick">▶︎</button>
<button v-if="endPage < totalPages" class="page-bt" id="next" @click="pgNextClick">▶︎</button>
</div>


</div>
</main>
</template>
Expand All @@ -54,12 +51,11 @@ export default {
currentPage: 1,
startPage: '',
endPage: '',
totalPage: '',
totalPages: '',
reportModal: false,
}
},
mounted() {
console.log(this.$route.params.filter)
const filter = this.$route.params.filter
if (filter == 'all') {
const onBt = document.getElementById('report-all')
Expand All @@ -83,12 +79,13 @@ export default {
.then((res) => {
console.log(res.data)
this.reportList = res.data.content
this.totalPage = res.data.totalPages
this.startPage = Math.floor((this.currentPage - 1) / 5) * 5 + 1;
this.endPage = Math.ceil(res.data.totalElements / 10);
this.totalPages = res.data.totalPages
this.startPage = Math.floor((this.currentPage - 1) / 5) * 5 + 1
this.endPage = Math.min(this.startPage + 4, this.totalPages)

})
.catch((error) => {
console.error('Error fetching reports:', error.message);
console.error('Error fetching reports:', error.message)
// alert('신고목록을 조회할 수 없습니다')
})
} else if (filter == 'unprocessed') {
Expand All @@ -112,23 +109,22 @@ export default {
})
.then((res) => {
this.reportList = res.data.content
this.startPage = Math.floor((this.currentPage - 1) / 5) * 5 + 1;
this.endPage = Math.ceil(res.data.totalElements / 10);
this.totalPage = res.data.totalPages;

this.totalPages = res.data.totalPages
this.startPage = Math.floor((this.currentPage - 1) / 5) * 5 + 1
this.endPage = Math.min(this.startPage + 4, this.totalPages)
})
.catch(() => {
window.history.back()
console.error('Error fetching reports:', error.message)
})

}
},
methods: {
handleReportDeleted() {
const index = this.reportList.findIndex((report) => report.reportNo === this.selectedReportNo);
const index = this.reportList.findIndex((report) => report.reportNo === this.selectedReportNo)
if (index !== -1) {
this.reportList.splice(index, 1);
this.reportList.splice(index, 1)
}

},
allReport() {
location.href = '/admin/report/all/1'
Expand All @@ -138,32 +134,32 @@ export default {
},
searchReport(e) {
if (this.reportModal) {
if (e.target.id == 'search-icon') return;
const onBt = document.getElementById('report-all');
onBt.style.opacity = '100%';
this.reportModal = false;
if (e.target.id == 'search-icon') return
const onBt = document.getElementById('report-all')
onBt.style.opacity = '100%'
this.reportModal = false
} else {
if (e.target.id == 'search-icon') {
const onBt = document.getElementById('report-all');
onBt.style.opacity = '50%';
const offBt = document.getElementById('report-upc');
offBt.style.opacity = '50%';
this.reportModal = false;

const searchText = document.getElementById('search-text').value;
const filteredReports = this.reportList.filter(report => report.reportNo == searchText);
this.reportList = filteredReports;
const onBt = document.getElementById('report-all')
onBt.style.opacity = '50%'
const offBt = document.getElementById('report-upc')
offBt.style.opacity = '50%'
this.reportModal = false

const searchText = document.getElementById('search-text').value
const filteredReports = this.reportList.filter(report => report.reportNo == searchText)
this.reportList = filteredReports
}
}
},


pgClick(e) {
const pg = parseInt(e.target.id.replace("pg", ""));
this.currentPage = pg;
const pg = parseInt(e.target.id.replace("pg", ""))
this.currentPage = pg
const filter = this.$route.params.filter
location.href = '/admin/report/' + filter + '/' + this.currentPage
},

pgPrevClick() {
this.currentPage = Math.floor(((this.currentPage - 1) / 5)) * 5
const filter = this.$route.params.filter
Expand All @@ -178,24 +174,25 @@ export default {
formatReportType(reportType) {
switch (reportType) {
case 1:
return '테스트케이스 추가요청';
return '테스트케이스 추가요청'
case 2:
return '문제 오류 제보';
return '문제 오류 제보'
case 3:
return '기타';
return '기타'
}
},
reportView(report) {
console.log(report.reportNo)
this.selectedReportNo = report.reportNo;
this.selectedReportNo = report.reportNo
this.reportModal = true
},
offReportModal() {
this.reportModal = false
},
}
};
}
</script>

<style scoped>
#layout {
width: 100%;
Expand Down
Loading