Skip to content

Commit

Permalink
feat: #1125: Update client app detail redux action name
Browse files Browse the repository at this point in the history
  • Loading branch information
nphivu414 committed May 11, 2020
1 parent 863268d commit f4917e4
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
8 changes: 3 additions & 5 deletions packages/marketplace/src/actions/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export const clientAppSummaryRequestDataFailure = actionCreator<string>(ActionTy
export const clientAppSummaryClearData = actionCreator<null>(ActionTypes.CLIENT_APP_SUMMARY_CLEAR_DATA)

// Client App Detail
export const clientAppDetailRequestData = actionCreator<ClientAppDetailParams>(
ActionTypes.CLIENT_APP_DETAIL_REQUEST_DATA,
)
export const clientAppDetailReceiveData = actionCreator<AppDetailData>(ActionTypes.CLIENT_APP_DETAIL_RECEIVE_DATA)
export const clientAppDetailRequestFailure = actionCreator<string>(ActionTypes.CLIENT_APP_DETAIL_REQUEST_FAILURE)
export const clientFetchAppDetail = actionCreator<ClientAppDetailParams>(ActionTypes.CLIENT_FETCH_APP_DETAIL)
export const clientFetchAppDetailSuccess = actionCreator<AppDetailData>(ActionTypes.CLIENT_FETCH_APP_DETAIL_SUCCESS)
export const clientFetchAppDetailFailed = actionCreator<string>(ActionTypes.CLIENT_FETCH_APP_DETAIL_FAILED)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppDetailModel } from '@reapit/foundations-ts-definitions'
import appPermissionContentStyles from '@/styles/pages/app-permission-content.scss?mod'
import { Button, Modal } from '@reapit/elements'
import { appInstallationsRequestInstall } from '@/actions/app-installations'
import { clientAppDetailRequestData } from '@/actions/client'
import { clientFetchAppDetail } from '@/actions/client'
import { Dispatch } from 'redux'
import CallToAction from '../call-to-action'
import { selectClientId } from '@/selector/client'
Expand All @@ -30,7 +30,7 @@ export const handleInstallButtonClick = (
appId,
callback: () => {
dispatch(
clientAppDetailRequestData({
clientFetchAppDetail({
id: appId,
clientId,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDispatch, useSelector } from 'react-redux'
import { AppDetailModel } from '@reapit/foundations-ts-definitions'
import appPermissionContentStyles from '@/styles/pages/app-permission-content.scss?mod'
import { Button, Modal } from '@reapit/elements'
import { clientAppDetailRequestData } from '@/actions/client'
import { clientFetchAppDetail } from '@/actions/client'
import { appInstallationsRequestUninstall } from '@/actions/app-installations'
import CallToAction from '../call-to-action'
import { selectClientId } from '@/selector/client'
Expand Down Expand Up @@ -33,7 +33,7 @@ export const onUninstallButtonClick = (
terminatedReason: 'User uninstall',
callback: () => {
dispatch(
clientAppDetailRequestData({
clientFetchAppDetail({
id: appId,
clientId,
}),
Expand Down
6 changes: 3 additions & 3 deletions packages/marketplace/src/constants/action-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ const ActionTypes = {
CLIENT_APP_SUMMARY_CLEAR_DATA: 'CLIENT_APP_SUMMARY_CLEAR_DATA',

// Client App Detail
CLIENT_APP_DETAIL_REQUEST_DATA: 'CLIENT_APP_DETAIL_REQUEST_DATA',
CLIENT_APP_DETAIL_REQUEST_FAILURE: 'CLIENT_APP_DETAIL_REQUEST_FAILURE',
CLIENT_APP_DETAIL_RECEIVE_DATA: 'CLIENT_APP_DETAIL_RECEIVE_DATA',
CLIENT_FETCH_APP_DETAIL: 'CLIENT_FETCH_APP_DETAIL',
CLIENT_FETCH_APP_DETAIL_FAILED: 'CLIENT_FETCH_APP_DETAIL_FAILED',
CLIENT_FETCH_APP_DETAIL_SUCCESS: 'CLIENT_FETCH_APP_DETAIL_SUCCESS',

// Installed apps actions
INSTALLED_APPS_REQUEST_DATA: 'INSTALLED_APPS_REQUEST_DATA',
Expand Down
8 changes: 4 additions & 4 deletions packages/marketplace/src/reducers/client/app-detail.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppDetailModel } from '@reapit/foundations-ts-definitions'
import { Action } from '@/types/core'
import { clientAppDetailRequestData, clientAppDetailReceiveData, clientAppDetailRequestFailure } from '@/actions/client'
import { clientFetchAppDetail, clientFetchAppDetailSuccess, clientFetchAppDetailFailed } from '@/actions/client'
import { isType } from '@/utils/actions'

export type AppDetailData = (AppDetailModel & { apiKey?: string }) | null
Expand All @@ -22,22 +22,22 @@ export const defaultState: ClientAppDetailState = {
}

const appDetailReducer = (state: ClientAppDetailState = defaultState, action: Action<any>): ClientAppDetailState => {
if (isType(action, clientAppDetailRequestData)) {
if (isType(action, clientFetchAppDetail)) {
return {
...state,
isAppDetailLoading: true,
}
}

if (isType(action, clientAppDetailReceiveData)) {
if (isType(action, clientFetchAppDetailSuccess)) {
return {
...state,
isAppDetailLoading: false,
data: action.data,
}
}

if (isType(action, clientAppDetailRequestFailure)) {
if (isType(action, clientFetchAppDetailFailed)) {
return {
...state,
isAppDetailLoading: false,
Expand Down
8 changes: 4 additions & 4 deletions packages/marketplace/src/sagas/apps/apps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClientAppDetailParams, clientAppDetailReceiveData, clientAppDetailRequestFailure } from '@/actions/client'
import { ClientAppDetailParams, clientFetchAppDetailSuccess, clientFetchAppDetailFailed } from '@/actions/client'
import { put, call, fork, takeLatest, all } from '@redux-saga/core/effects'
import ActionTypes from '@/constants/action-types'
import { errorThrownServer } from '@/actions/error'
Expand All @@ -15,10 +15,10 @@ export const fetchAppDetailSaga = function*({ data }: Action<ClientAppDetailPara
const apiKeyResponse = yield call(fetchAppApiKey, { installationId: appDetailResponse.installationId })
appDetailResponse.apiKey = apiKeyResponse?.apiKey || ''
}
yield put(clientAppDetailReceiveData(appDetailResponse))
yield put(clientFetchAppDetailSuccess(appDetailResponse))
} catch (err) {
logger(err)
yield put(clientAppDetailRequestFailure(err.message))
yield put(clientFetchAppDetailFailed(err.message))
yield put(
errorThrownServer({
type: 'SERVER',
Expand All @@ -29,7 +29,7 @@ export const fetchAppDetailSaga = function*({ data }: Action<ClientAppDetailPara
}

export const clientAppDetailDataListen = function*() {
yield takeLatest<Action<ClientAppDetailParams>>(ActionTypes.CLIENT_APP_DETAIL_REQUEST_DATA, fetchAppDetailSaga)
yield takeLatest<Action<ClientAppDetailParams>>(ActionTypes.CLIENT_FETCH_APP_DETAIL, fetchAppDetailSaga)
}

const appDetailSagas = function*() {
Expand Down
6 changes: 3 additions & 3 deletions packages/marketplace/src/utils/route-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RouteValue, StringMap } from '../types/core'
import Routes from '../constants/routes'
import { GET_ALL_PAGE_SIZE } from '../constants/paginator'
import store from '../core/store'
import { clientAppSummaryRequestData, clientAppDetailRequestData } from '../actions/client'
import { clientAppSummaryRequestData, clientFetchAppDetail } from '../actions/client'
import { myAppsRequestData } from '../actions/my-apps'
import { installedAppsRequestData } from '../actions/installed-apps'
import { developerRequestData, fetchMyIdentity } from '@/actions/developer'
Expand All @@ -31,14 +31,14 @@ const routeDispatcher = async (route: RouteValue, params?: StringMap, search?: s
case Routes.CLIENT_APP_DETAIL: {
if (id) {
const clientId = selectClientId(store.state)
store.dispatch(clientAppDetailRequestData({ id, clientId }))
store.dispatch(clientFetchAppDetail({ id, clientId }))
}
break
}
case Routes.CLIENT_APP_DETAIL_MANAGE: {
if (id) {
const clientId = selectClientId(store.state)
store.dispatch(clientAppDetailRequestData({ id, clientId }))
store.dispatch(clientFetchAppDetail({ id, clientId }))
}
break
}
Expand Down

0 comments on commit f4917e4

Please sign in to comment.