-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
179 additions
and
34 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,32 @@ | ||
import {createApi, fetchBaseQuery} from "@reduxjs/toolkit/query/react"; | ||
import {BASE_URL, USED_ITEM_POST_LIST} from "../util/Api"; | ||
import {getCookie} from "../util/Cookie"; | ||
import {UsedItemPost, UsedItemPostListArgs} from "../model/usedItemPost"; | ||
|
||
export const usedItemApi = createApi({ | ||
reducerPath: 'usedItemApi', | ||
baseQuery: fetchBaseQuery({ | ||
baseUrl: BASE_URL, | ||
prepareHeaders: (headers, { getState, endpoint, type, forced }) => { | ||
headers.set("Authorization", 'Bearer ' + getCookie("access_token")); | ||
|
||
const townToken = getCookie("X-TOWN-TOKEN"); | ||
if(townToken) | ||
headers.set("X-TOWN-TOKEN", townToken); | ||
return headers | ||
} | ||
}), | ||
endpoints: (builder) => ({ | ||
getUsedItem: builder.query<UsedItemPost[],UsedItemPostListArgs>({ | ||
query: (UsedItemPostListArgs) => ({ | ||
url: USED_ITEM_POST_LIST, | ||
method : `GET`, | ||
params: {pageNum : UsedItemPostListArgs.pageNum, | ||
requestTime : UsedItemPostListArgs.requestTime} | ||
}) | ||
}) | ||
|
||
}) | ||
}) | ||
|
||
|
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
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
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,25 @@ | ||
export interface UsedItemPost{ | ||
previewPost : PreviewPost | ||
previewPostCount : PreviewPostCount | ||
} | ||
|
||
|
||
export interface PreviewPost{ | ||
postId : string; | ||
representPictureUrl : string; | ||
title : string; | ||
address : string; | ||
createdAt : string; | ||
price : number; | ||
tradeStatus:string, | ||
isHide: boolean, | ||
} | ||
export interface PreviewPostCount { | ||
interestCount : number; | ||
viewCount : number; | ||
} | ||
|
||
export interface UsedItemPostListArgs{ | ||
pageNum: number, | ||
requestTime: string, | ||
} |
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
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,24 @@ | ||
import {createSlice} from "@reduxjs/toolkit"; | ||
import {useSelector} from "react-redux"; | ||
import {RootState} from "./index"; | ||
import {UsedItemPost} from "../model/usedItemPost"; | ||
|
||
const initialState: UsedItemPost[] = []; | ||
|
||
export const usedItemSlice = createSlice({ | ||
name: 'usedItem', | ||
initialState, | ||
reducers: { | ||
ADD: (state,action) => { | ||
Array.prototype.push.apply(state, action.payload); | ||
return state; | ||
}, | ||
CLEAR: () => { | ||
return initialState; | ||
} | ||
|
||
}, | ||
}) | ||
export const useUsedItemSelector = () => | ||
useSelector((state: RootState) => state.usedItem) | ||
export const {ADD,CLEAR } = usedItemSlice.actions; |
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,7 @@ | ||
export function currentTime() { | ||
let cur = new Date(); | ||
return `${cur.getFullYear()}-${cur.getMonth() + 1 < 10 ? "0"+(cur.getMonth() + 1) | ||
:cur.getMonth() + 1}-${cur.getDate()<10?"0"+cur.getDate():cur.getDate()}T${cur.getHours() | ||
<10? "0"+cur.getHours():cur.getHours()}:${cur.getMinutes()<10? | ||
"0"+cur.getMinutes():cur.getMinutes()}:${cur.getSeconds()<10?"0"+cur.getSeconds():cur.getSeconds()}` | ||
} |
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
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