feat: 修改军团长
This commit is contained in:
parent
4105fed6e2
commit
0449882249
|
|
@ -1,8 +1,11 @@
|
|||
import { useSelector } from 'react-redux'
|
||||
import { State } from '../types'
|
||||
|
||||
export const useReferralConfigInfo = () => {
|
||||
return useSelector((state: State) => state.referral.configInfo)
|
||||
export const useReferralCommanderConfigInfo = () => {
|
||||
return useSelector((state: State) => state.referral.commanderConfigInfo)
|
||||
}
|
||||
export const useReferralNormalConfigInfo = () => {
|
||||
return useSelector((state: State) => state.referral.normalConfigInfo)
|
||||
}
|
||||
|
||||
export const useReferralRewardInfo = () => {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
import { createSlice } from '@reduxjs/toolkit'
|
||||
import { getReferralInfo } from 'services/referral'
|
||||
import { ReferralInfo } from 'types/referral'
|
||||
import { ReferralInfo, ReferralConfigType } from 'types/referral'
|
||||
import { ReferralState } from '../types'
|
||||
|
||||
const initialState: ReferralState = { configInfo: {}, isCommander: false, rewardInfo: {} }
|
||||
const initialState: ReferralState = {
|
||||
commanderConfigInfo: {},
|
||||
normalConfigInfo: {},
|
||||
isCommander: false,
|
||||
rewardInfo: {},
|
||||
}
|
||||
export const referralSlice = createSlice({
|
||||
name: 'Referral',
|
||||
initialState,
|
||||
reducers: {
|
||||
setReferralInfo: (state, action) => {
|
||||
state.configInfo = action.payload.configInfo
|
||||
state.commanderConfigInfo = action.payload.commanderConfigInfo
|
||||
state.normalConfigInfo = action.payload.normalConfigInfo
|
||||
state.isCommander = action.payload.isCommander
|
||||
state.rewardInfo = action.payload.rewardInfo
|
||||
},
|
||||
|
|
@ -27,7 +33,8 @@ export const fetchReferralInfoAsync = (account) => async (dispatch) => {
|
|||
const data: ReferralInfo = await getReferralInfo()
|
||||
dispatch(
|
||||
setReferralInfo({
|
||||
configInfo: data.inviteConfigList[0],
|
||||
commanderConfigInfo: data.inviteConfigList?.find((item) => item.type === ReferralConfigType.COMMANDER),
|
||||
normalConfigInfo: data.inviteConfigList?.find((item) => item.type === ReferralConfigType.NORMAL),
|
||||
isCommander: data.isCommander,
|
||||
rewardInfo: data.reward,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -484,7 +484,8 @@ export interface UserInfoState {
|
|||
}
|
||||
|
||||
export interface ReferralState {
|
||||
configInfo: ReferralConfigInfo
|
||||
commanderConfigInfo: ReferralConfigInfo
|
||||
normalConfigInfo: ReferralConfigInfo
|
||||
isCommander: boolean
|
||||
rewardInfo: ReferralRewardInfo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
export enum ReferralConfigType {
|
||||
COMMANDER = 'COMMANDER',
|
||||
NORMAL = 'NORMAL',
|
||||
}
|
||||
|
||||
export interface ReferralConfigInfo {
|
||||
dividendFirst?: number
|
||||
dividendSecond?: number
|
||||
|
|
@ -14,7 +19,7 @@ export interface ReferralRewardInfo {
|
|||
}
|
||||
|
||||
export interface ReferralInfo {
|
||||
inviteConfigList: ReferralConfigInfo
|
||||
inviteConfigList: ReferralConfigInfo[]
|
||||
isCommander: boolean
|
||||
reward: ReferralRewardInfo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ export const initAxios = (dispatch: Dispatch<any>, toast) => {
|
|||
hasInit = true
|
||||
request.interceptors.request.use(
|
||||
(memo: any) => {
|
||||
memo.headers.Authorization = `Bearer ${localStorage.getItem(CACHE_TOKEN)} `
|
||||
const token = localStorage.getItem(CACHE_TOKEN)
|
||||
token && (memo.headers.Authorization = `Bearer ${token}`)
|
||||
return memo
|
||||
},
|
||||
(error) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue