mirror of
https://github.com/strapi/strapi.git
synced 2025-12-13 07:55:33 +00:00
Chore: Simplify selector access across the page
This commit is contained in:
parent
9cf1567604
commit
d7b18b9ece
@ -15,7 +15,7 @@ import { setWorkflow } from './actions';
|
||||
export function ReviewWorkflowsPage() {
|
||||
const { formatMessage } = useIntl();
|
||||
const { workflows: workflowsData } = useReviewWorkflows();
|
||||
const workflow = useSelector((state) => state?.[REDUX_NAMESPACE]);
|
||||
const state = useSelector((state) => state?.[REDUX_NAMESPACE]);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useInjectReducer(REDUX_NAMESPACE, reducer);
|
||||
@ -27,10 +27,12 @@ export function ReviewWorkflowsPage() {
|
||||
// useInjectReducer() runs on the first rendering after useSelector
|
||||
// which will return undefined. This helps to avoid too many optional
|
||||
// chaining operators down the component.
|
||||
if (!workflow) {
|
||||
if (!state) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { workflows } = state;
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<SettingsPageTitle
|
||||
@ -58,11 +60,11 @@ export function ReviewWorkflowsPage() {
|
||||
id: 'Settings.review-workflows.page.subtitle',
|
||||
defaultMessage: '{count, plural, one {# stage} other {# stages}}',
|
||||
},
|
||||
{ count: workflow.workflows.stages.length }
|
||||
{ count: workflows.stages.length }
|
||||
)}
|
||||
/>
|
||||
<ContentLayout>
|
||||
{workflow.workflows.state === 'loading' ? (
|
||||
{workflows.state === 'loading' ? (
|
||||
<Loader>
|
||||
{formatMessage({
|
||||
id: 'Settings.review-workflows.page.isLoading',
|
||||
@ -70,7 +72,7 @@ export function ReviewWorkflowsPage() {
|
||||
})}
|
||||
</Loader>
|
||||
) : (
|
||||
<Stages stages={workflow.workflows.stages} />
|
||||
<Stages stages={workflows.stages} />
|
||||
)}
|
||||
</ContentLayout>
|
||||
</Main>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user