Skip to content

Commit

Permalink
chore: #1033 rename selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Truong An committed Jun 22, 2020
1 parent b2c85cb commit 847f713
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`WebComponentConfig Should match snapshot 1`] = `
initialEntries={
Array [
Object {
"key": "registerRoute",
"key": "appDetailsRoute",
"pathname": "/client/apps/:appid",
},
]
Expand All @@ -33,7 +33,7 @@ exports[`WebComponentConfig Should match snapshot 1`] = `
"entries": Array [
Object {
"hash": "",
"key": "registerRoute",
"key": "appDetailsRoute",
"pathname": "/client/apps/:appid",
"search": "",
},
Expand All @@ -46,7 +46,7 @@ exports[`WebComponentConfig Should match snapshot 1`] = `
"listen": [Function],
"location": Object {
"hash": "",
"key": "registerRoute",
"key": "appDetailsRoute",
"pathname": "/client/apps/:appid",
"search": "",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react'
import { Button } from '@reapit/elements'
import { useDispatch, useSelector } from 'react-redux'
import { selectIsWebComponentData } from '@/selector/client'
import { selectWebComponentData } from '@/selector/client'
import { clientFetchWebComponentConfig } from '@/actions/client'
import { Dispatch } from 'redux'
import WebComponentModal from '@/components/ui/web-component-config-modal'
Expand All @@ -26,7 +26,7 @@ export const WebComponentConfig: React.FC = () => {
const [isOpenConfigModal, setIsOpenConfigModal] = useState(false)

const clientId = useSelector(selectClientId) || ''
const webComponentData = useSelector(selectIsWebComponentData)
const webComponentData = useSelector(selectWebComponentData)
const { appid: applicationId } = useParams()

const handleToggleWebComponentModal = toggleWebComponentModal(setIsOpenConfigModal, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import styles from '@/styles/elements/radioselect.scss?mod'
import { useDispatch, useSelector } from 'react-redux'
import { clientUpdateWebComponentConfig } from '@/actions/client'
import {
selectIsWebComponentData,
selectIsWebComponentLoading,
selectIsWebComponentUpdating,
selectIsWebComponentNegotiators,
selectWebComponentData,
selectWebComponentLoading,
selectWebComponentUpdating,
selectWebComponentNegotiators,
} from '@/selector/client'
import { UpdateWebComponentConfigParams } from '@/services/web-component'
import { Dispatch } from 'redux'
Expand All @@ -47,7 +47,7 @@ export type WebComponentConfigModalBodyProps = {
}
export const WebComponentConfigModalBody = ({ subtext, formikProps }: WebComponentConfigModalBodyProps) => {
const { values, setFieldValue } = formikProps
const negotiators = useSelector(selectIsWebComponentNegotiators)
const negotiators = useSelector(selectWebComponentNegotiators)
const negotiatorOptions = genarateNegotiatorOptions(negotiators)

return (
Expand Down Expand Up @@ -118,7 +118,7 @@ export type WebComponentConfigModalFooterProps = {
}

export const WebComponentConfigModalFooter = ({ closeModal, formikProps }: WebComponentConfigModalFooterProps) => {
const updating = useSelector(selectIsWebComponentUpdating)
const updating = useSelector(selectWebComponentUpdating)
const { handleSubmit } = formikProps
return (
<>
Expand All @@ -139,8 +139,8 @@ export type WebComponentConfigModalInnerProps = {
export const WebComponentConfigModalInner = ({ closeModal }: WebComponentConfigModalInnerProps) => {
const dispatch = useDispatch()

const webComponentData = useSelector(selectIsWebComponentData)
const loading = useSelector(selectIsWebComponentLoading)
const webComponentData = useSelector(selectWebComponentData)
const loading = useSelector(selectWebComponentLoading)
const appDetails = useSelector(selectAppDetailData)
const { name, id = '' } = appDetails

Expand Down
20 changes: 10 additions & 10 deletions packages/marketplace/src/selector/__tests__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import {
selectClientId,
selectLoggedUserEmail,
selectFeaturedApps,
selectIsWebComponentOpen,
selectIsWebComponentData,
selectIsWebComponentLoading,
selectIsWebComponentUpdating,
selectIsWebComponentNegotiators,
selectWebComponentOpen,
selectWebComponentData,
selectWebComponentLoading,
selectWebComponentUpdating,
selectWebComponentNegotiators,
selectAppDetail,
selectMyApps,
selectInstalledApps,
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('selectFeaturedApps', () => {
},
},
} as ReduxState
const result = selectIsWebComponentOpen(input)
const result = selectWebComponentOpen(input)
expect(result).toEqual(true)
})

Expand All @@ -115,7 +115,7 @@ describe('selectFeaturedApps', () => {
},
},
} as ReduxState
const result = selectIsWebComponentData(input)
const result = selectWebComponentData(input)
expect(result).toEqual({})
})

Expand All @@ -127,7 +127,7 @@ describe('selectFeaturedApps', () => {
},
},
} as ReduxState
const result = selectIsWebComponentLoading(input)
const result = selectWebComponentLoading(input)
expect(result).toEqual(true)
})

Expand All @@ -139,7 +139,7 @@ describe('selectFeaturedApps', () => {
},
},
} as ReduxState
const result = selectIsWebComponentUpdating(input)
const result = selectWebComponentUpdating(input)
expect(result).toEqual(true)
})

Expand All @@ -152,7 +152,7 @@ describe('selectFeaturedApps', () => {
},
},
} as ReduxState
const result = selectIsWebComponentNegotiators(input)
const result = selectWebComponentNegotiators(input)
expect(result).toEqual([])
})
it('should run correctly and return {}', () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/marketplace/src/selector/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ export const selectInstalledApps = (state: ReduxState) => {
return state?.installedApps
}

export const selectIsWebComponentOpen = (state: ReduxState) => {
export const selectWebComponentOpen = (state: ReduxState) => {
return state?.client.webComponent?.isShowModal
}

export const selectIsWebComponentData = (state: ReduxState) => {
export const selectWebComponentData = (state: ReduxState) => {
return state?.client.webComponent?.data
}

export const selectIsWebComponentLoading = (state: ReduxState) => {
export const selectWebComponentLoading = (state: ReduxState) => {
return state?.client.webComponent?.loading
}

export const selectIsWebComponentUpdating = (state: ReduxState) => {
export const selectWebComponentUpdating = (state: ReduxState) => {
return state?.client.webComponent?.updating
}

export const selectIsWebComponentNegotiators = (state: ReduxState) => {
export const selectWebComponentNegotiators = (state: ReduxState) => {
return state?.client.webComponent?.negotiators?._embedded || []
}

Expand Down

0 comments on commit 847f713

Please sign in to comment.