Skip to content

Commit

Permalink
Merge pull request #203 from lotteon2/develop
Browse files Browse the repository at this point in the history
[FIX] fix sns service hotfix
  • Loading branch information
wakkpu authored Jan 17, 2024
2 parents ee83413 + f7b83ab commit f2434b3
Show file tree
Hide file tree
Showing 23 changed files with 909 additions and 500 deletions.
73 changes: 73 additions & 0 deletions src/apis/auction/Auction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { AxiosError, type AxiosResponse } from 'axios'
import { authAxiosInstance, defaultAxiosInstance, chatAuthAxiosInstance } from '@/apis/utils'
import type { CreateBidRequest, EnterResponse } from './AuctionDto'
import { useRouter } from 'vue-router'
const AUCTION_SERVICE_PREFIX_PATH = '/auction-service'

export const createBid = async (createBidRequest: CreateBidRequest): Promise<number> => {
try {
const { data } = await chatAuthAxiosInstance.post(
`${AUCTION_SERVICE_PREFIX_PATH}/bids`,
createBidRequest
)
return data
} catch (error) {
if (error instanceof AxiosError) {
if (error.response) {
if (error.response.status >= 400 && error.response.status < 500) {
alert(error.response.data.message)
console.error(`Client Error=${error.response.data.message}`)
} else if (error.response.status >= 500) {
alert('서버 내부 오류')
console.error('Internal Server Error')
}
}
}
throw error
}
}

export const enter = async (auctionId: string): Promise<EnterResponse> => {
const router = useRouter()
try {
const { data } = await authAxiosInstance.get(
`${AUCTION_SERVICE_PREFIX_PATH}/auctions/enter/${auctionId}`
)
return data
} catch (error) {
if (error instanceof AxiosError) {
if (error.response) {
if (error.response.status >= 400 && error.response.status < 500) {
alert(error.response.data.message)
console.error(`Client Error=${error.response.data.message}`)
router.replace('/')
} else if (error.response.status >= 500) {
alert('서버 내부 오류')
console.error('Internal Server Error')
router.replace('/')
}
}
}
throw error
}
}

export const startBid = async (): Promise<AxiosResponse> => {
try {
const response = await authAxiosInstance.get(`${AUCTION_SERVICE_PREFIX_PATH}/admin/bids/start`)
return response
} catch (error) {
if (error instanceof AxiosError) {
if (error.response) {
if (error.response.status >= 400 && error.response.status < 500) {
alert(error.response.data.message)
console.error(`Client Error=${error.response.data.message}`)
} else if (error.response.status >= 500) {
alert('서버 내부 오류')
console.error('Internal Server Error')
}
}
}
throw error
}
}
13 changes: 13 additions & 0 deletions src/apis/auction/AuctionDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,25 @@ export interface ReadAuctionResponse {
auctionProductId: number
auctionName: string
startBidPrice: number
askingPrice: number
maximumWinner: number
startAt: string
started: boolean
ended: boolean
}

export interface CreateBidRequest {
auctionId: string
round: string
bidAmount: number
nickname: string
}

export interface EnterResponse {
token: string
readAuctionDetailResponse: ReadAuctionDetailResponse
}

export interface ReadAuctionHistoryPageResponse {
totalElements: number
totalPages: number
Expand Down
37 changes: 37 additions & 0 deletions src/apis/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,42 @@ const axiosAuthApi = (baseURL: string) => {
return instance
}

const axiosChatAuthApi = (baseURL: string) => {
const instance: AxiosInstance = axios.create({
baseURL,
withCredentials: true
})

instance.interceptors.request.use((config) => {
const data = sessionStorage.getItem('auctions')
const jsonObject = JSON.parse(data!)
if (jsonObject) {
config.headers.Authorization = `Bearer ${jsonObject.chatToken}`
}

return config
})

instance.interceptors.response.use(
(response) => {
return response
},
async (error) => {
const originalRequest = error.config

if (error.response.status === 401) {
originalRequest._retry = true
showAlert('로그인 정보가 만료되었습니다. 다시 로그인해주세요.(code1)')
window.location.href = '/login'
}

return Promise.reject(error)
}
)

return instance
}

const refreshToken = async () => {
try {
const memberString = localStorage.getItem('member')
Expand Down Expand Up @@ -178,3 +214,4 @@ const showAlert = (message: string): void => {

export const defaultAxiosInstance: AxiosInstance = axiosApi(BASE_URL)
export const authAxiosInstance: AxiosInstance = axiosAuthApi(BASE_URL)
export const chatAuthAxiosInstance: AxiosInstance = axiosChatAuthApi(BASE_URL)
152 changes: 152 additions & 0 deletions src/assets/css/auction/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
text-decoration-line: line-through;
color: #c6c6c6;
}
.my-current-bid {
font-style: normal;
font-weight: 500;
font-size: 25px;
color: #000000;
padding-bottom: 15px;
}
.current-bid {
font-style: normal;
font-weight: 500;
Expand Down Expand Up @@ -275,6 +282,17 @@
cursor: pointer;
}

.disabled-button {
width: 100%;
margin: 5px;
background: grey;
color: #fff;
border-radius: 5px;
border: none;
font-size: 20px;
cursor: not-allowed;
}

.input-btn {
width: 100%;
margin: 5px;
Expand All @@ -285,6 +303,16 @@
cursor: pointer;
}

.disabled-button2 {
width: 100%;
margin: 5px;
background: gray;
border-radius: 5px;
border: none;
font-size: 20px;
cursor: not-allowed;
}

/* 채팅 보내기 */
.chat-input {
display: flex;
Expand Down Expand Up @@ -312,3 +340,127 @@
.btn-text {
cursor: pointer;
}

.timer-header {
display: flex;
justify-self: center;
}

:deep(.remain-time .ant-statistic .ant-statistic-content) {
color: black !important;
font-weight: 500;
font-size: 25px;
vertical-align: baseline;
}

:deep(.timer-header .ant-statistic .ant-statistic-content) {
color: black !important;
font-weight: 400;
font-size: 30px;
}

.timer {
font-size: 25px;
}
.modal {
display: block;
position: fixed;
z-index: 5;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
position: fixed;
top: 30%;
padding: 50px;
border: 1px solid var(--Grayscale4, #c6c6c6);
border-radius: 15px;
left: 35%;
width: 428.17px;
height: 251.33px;
overflow-y: scroll;
}

.modal-content {
-ms-overflow-style: none;
scrollbar-width: none;
}
.modal-content::-webkit-scrollbar {
display: none;
}

.close {
right: 23.5%;
top: 11%;
position: fixed;
color: #aaa;
float: right;
font-size: 25px;
font-weight: bold;
}

.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}

/* */
.loader {
height: 70px;
display: flex;
width: 510px;
/* border: 1px solid yellow; */
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
position: absolute;
}
.circle {
width: 70px;
height: 70px;
border-radius: 50%;
margin: 0 50px;
animation: jump 1s linear infinite;
}
.circle:nth-child(1) {
background: #f87c7b;
}
.circle:nth-child(2) {
background: #f9cf5c;
}
.circle:nth-child(3) {
background: #77a4cc;
}
.caption {
font-size: 35px;
color: black;
top: 80%;
left: 50%;
transform: translate(-50%, -70%);
position: absolute;
}
@keyframes jump {
0% {
margin-top: 0;
}
35% {
margin-top: -50px;
}
70% {
margin-top: 0px;
}
}

#b {
animation-delay: 0.2s;
}
#c {
animation-delay: 0.4s;
}
8 changes: 7 additions & 1 deletion src/components/auction/AuctionEntranceModal.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<script setup lang="ts">
import { ref, watch } from 'vue'
import { getAuctionDetail } from '@/apis/auction/AuctionClient'
import { useRouter } from 'vue-router'
import { useAuctionStore } from '@/stores/auction/AuctionStore'
import type { ReadAuctionDetailResponse } from '@/apis/auction/AuctionDto'
const auctionStore = useAuctionStore()
import { infoModal } from '@/utils/Modal'
const VITE_STATIC_IMG_URL = ref<string>(import.meta.env.VITE_STATIC_IMG_URL)
const router = useRouter()
const props = defineProps({
showModal: {
type: Boolean,
Expand All @@ -24,6 +27,7 @@ const auctionDetail = ref<ReadAuctionDetailResponse>({
auctionName: '',
auctionProductId: 0,
startBidPrice: 0,
askingPrice: 0,
startAt: '',
maximumWinner: 0,
ended: false,
Expand Down Expand Up @@ -56,6 +60,8 @@ const closeModal = () => {
const enterAuction = () => {
infoModal('알림', '경매 입장')
auctionStore.setAuctionDetail(auctionDetail.value)
router.push({ path: `/chat/${props.auctionId}` })
emits('close-modal')
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/member/AddressModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const submitForm = async () => {
}
props.closeModal()
await successModal('알림', '배송지 저장이 완료되었습니다.')
window.location.reload()
await successModal('알림', '배송지 저장이 완료되었습니다.')
} catch (error) {
console.error('API 호출 중 오류 발생:', error)
} finally {
Expand Down
8 changes: 4 additions & 4 deletions src/components/member/MemberInfoComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ const closeModal = () => {
const setDefault = async (addressId: number) => {
setDefaultAddress(addressId)
await successModal('알림', '기본 배송지가 저장되었습니다.')
window.location.reload()
await successModal('알림', '기본 배송지가 저장되었습니다.')
}
const deleteAdd = async (addressId: number) => {
if (await confirmModal('진행 여부 확인', '정말로 삭제하시겠습니까?')) {
deleteAddress(addressId)
await successModal('알림', '배송지가 삭제되었습니다.')
window.location.reload()
await successModal('알림', '배송지가 삭제되었습니다.')
}
}
Expand Down Expand Up @@ -118,8 +118,8 @@ const setMemberInfo = async () => {
if (await confirmModal('진행 여부 확인', '수정된 정보를 저장하시겠습니까?')) {
setMember(memberDto)
await getMember()
await successModal('알림', '수정이 완료되었습니다!')
window.location.reload()
await successModal('알림', '수정이 완료되었습니다!')
}
}
Expand Down
Loading

0 comments on commit f2434b3

Please sign in to comment.