collection.slug === userSlug);
-
const baseClass = 'create-first-user';
const CreateFirstUser = (props) => {
const { setInitialized } = props;
- const { setToken } = useUser();
+ const { setToken } = useAuthentication();
+ const {
+ admin: { user: userSlug }, collections, serverURL, routes: { admin, api },
+ } = useConfig();
+
+ const userConfig = collections.find((collection) => collection.slug === userSlug);
const onSuccess = (json) => {
if (json?.user?.token) {
diff --git a/src/client/components/views/Dashboard/Default.js b/src/client/components/views/Dashboard/Default.js
index db36a3158..1e41b84fd 100644
--- a/src/client/components/views/Dashboard/Default.js
+++ b/src/client/components/views/Dashboard/Default.js
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useHistory } from 'react-router-dom';
-import config from 'payload/config';
+import { useConfig } from '../../providers/Config';
import Eyebrow from '../../elements/Eyebrow';
import Card from '../../elements/Card';
@@ -9,12 +9,6 @@ import Button from '../../elements/Button';
import './index.scss';
-const {
- routes: {
- admin,
- },
-} = config;
-
const baseClass = 'dashboard';
const Dashboard = (props) => {
@@ -26,6 +20,12 @@ const Dashboard = (props) => {
const { push } = useHistory();
+ const {
+ routes: {
+ admin,
+ },
+ } = useConfig();
+
return (
diff --git a/src/client/components/views/Dashboard/index.js b/src/client/components/views/Dashboard/index.js
index 812368e93..b4ed16acb 100644
--- a/src/client/components/views/Dashboard/index.js
+++ b/src/client/components/views/Dashboard/index.js
@@ -1,25 +1,30 @@
import React, { useState, useEffect } from 'react';
-import config from 'payload/config';
-import { useUser } from '../../data/User';
+import { useConfig } from '../../providers/Config';
+import { useAuthentication } from '../../providers/Authentication';
import { useStepNav } from '../../elements/StepNav';
import RenderCustomComponent from '../../utilities/RenderCustomComponent';
import DefaultDashboard from './Default';
-const {
- collections,
- globals,
-} = config;
-
const Dashboard = () => {
- const { permissions } = useUser();
+ const { permissions } = useAuthentication();
const { setStepNav } = useStepNav();
const [filteredGlobals, setFilteredGlobals] = useState([]);
+ const {
+ collections,
+ globals,
+ admin: {
+ components: {
+ dashboard: CustomDashboard,
+ } = {},
+ } = {},
+ } = useConfig();
+
useEffect(() => {
setFilteredGlobals(
globals.filter((global) => permissions?.[global.slug]?.read?.permission),
);
- }, [permissions]);
+ }, [permissions, globals]);
useEffect(() => {
setStepNav([]);
@@ -28,7 +33,7 @@ const Dashboard = () => {
return (
permissions?.[collection.slug]?.read?.permission),
diff --git a/src/client/components/views/ForgotPassword/index.js b/src/client/components/views/ForgotPassword/index.js
index 45ae693e3..3eb8136dc 100644
--- a/src/client/components/views/ForgotPassword/index.js
+++ b/src/client/components/views/ForgotPassword/index.js
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { Link } from 'react-router-dom';
-import config from 'payload/config';
+import { useConfig } from '../../providers/Config';
import MinimalTemplate from '../../templates/Minimal';
import StatusList, { useStatusList } from '../../elements/Status';
import Form from '../../forms/Form';
@@ -8,25 +8,24 @@ import Email from '../../forms/field-types/Email';
import FormSubmit from '../../forms/Submit';
import Button from '../../elements/Button';
import Meta from '../../utilities/Meta';
-import { useUser } from '../../data/User';
+import { useAuthentication } from '../../providers/Authentication';
import './index.scss';
const baseClass = 'forgot-password';
-const {
- admin: { user: userSlug },
- serverURL,
- routes: {
- admin,
- api,
- },
-} = config;
-
const ForgotPassword = () => {
const { addStatus } = useStatusList();
const [hasSubmitted, setHasSubmitted] = useState(false);
- const { user } = useUser();
+ const { user } = useAuthentication();
+ const {
+ admin: { user: userSlug },
+ serverURL,
+ routes: {
+ admin,
+ api,
+ },
+ } = useConfig();
const handleResponse = (res) => {
res.json()
diff --git a/src/client/components/views/Global/Default.js b/src/client/components/views/Global/Default.js
index 023008a21..33a61b883 100644
--- a/src/client/components/views/Global/Default.js
+++ b/src/client/components/views/Global/Default.js
@@ -62,7 +62,6 @@ const DefaultGlobalView = (props) => {
filter={(field) => (!field.position || (field.position && field.position !== 'sidebar'))}
fieldTypes={fieldTypes}
fieldSchema={fields}
- customComponentsPath={`${slug}.fields.`}
/>