@payloadcms/next 3.0.0-canary.ef0a8d0 → 3.0.0-canary.f1f97ff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +5 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +1 -1
- package/dist/elements/Nav/index.client.js +10 -4
- package/dist/elements/Nav/index.client.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/handler.js +1 -4
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/rest/auth/login.d.ts.map +1 -1
- package/dist/routes/rest/auth/login.js +1 -1
- package/dist/routes/rest/auth/login.js.map +1 -1
- package/dist/routes/rest/auth/unlock.d.ts.map +1 -1
- package/dist/routes/rest/auth/unlock.js +7 -3
- package/dist/routes/rest/auth/unlock.js.map +1 -1
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +30 -5
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/routes/rest/routeError.d.ts.map +1 -1
- package/dist/routes/rest/routeError.js +3 -3
- package/dist/routes/rest/routeError.js.map +1 -1
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
- package/dist/utilities/createPayloadRequest.js +10 -7
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/getNextRequestI18n.d.ts +3 -3
- package/dist/utilities/getNextRequestI18n.d.ts.map +1 -1
- package/dist/utilities/getNextRequestI18n.js +3 -1
- package/dist/utilities/getNextRequestI18n.js.map +1 -1
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.js +5 -4
- package/dist/utilities/getPayloadHMR.js.map +1 -1
- package/dist/utilities/initPage/handleAdminPage.d.ts +4 -0
- package/dist/utilities/initPage/handleAdminPage.d.ts.map +1 -1
- package/dist/utilities/initPage/handleAdminPage.js +17 -4
- package/dist/utilities/initPage/handleAdminPage.js.map +1 -1
- package/dist/utilities/initPage/handleAuthRedirect.d.ts.map +1 -1
- package/dist/utilities/initPage/handleAuthRedirect.js +15 -3
- package/dist/utilities/initPage/handleAuthRedirect.js.map +1 -1
- package/dist/utilities/initPage/index.js.map +1 -1
- package/dist/utilities/initPage/shared.d.ts +14 -2
- package/dist/utilities/initPage/shared.d.ts.map +1 -1
- package/dist/utilities/initPage/shared.js +14 -4
- package/dist/utilities/initPage/shared.js.map +1 -1
- package/dist/utilities/mergeHeaders.d.ts +1 -1
- package/dist/utilities/mergeHeaders.d.ts.map +1 -1
- package/dist/utilities/mergeHeaders.js +7 -33
- package/dist/utilities/mergeHeaders.js.map +1 -1
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +14 -23
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.d.ts +2 -0
- package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +15 -7
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.js +30 -7
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/index.js +13 -4
- package/dist/views/Dashboard/Default/index.js.map +1 -1
- package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -1
- package/dist/views/Document/getViewsFromConfig.js +3 -3
- package/dist/views/Document/getViewsFromConfig.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +24 -32
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Edit/Default/Auth/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/Auth/index.js +34 -14
- package/dist/views/Edit/Default/Auth/index.js.map +1 -1
- package/dist/views/Edit/Default/Auth/types.d.ts +2 -1
- package/dist/views/Edit/Default/Auth/types.d.ts.map +1 -1
- package/dist/views/Edit/Default/Auth/types.js.map +1 -1
- package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/SetDocumentStepNav/index.js +15 -5
- package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -1
- package/dist/views/Edit/Default/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/index.js +13 -14
- package/dist/views/Edit/Default/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +11 -4
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +10 -4
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.d.ts.map +1 -1
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/Login/LoginField/index.d.ts +7 -0
- package/dist/views/Login/LoginField/index.d.ts.map +1 -0
- package/dist/views/Login/LoginField/index.js +101 -0
- package/dist/views/Login/LoginField/index.js.map +1 -0
- package/dist/views/Login/LoginForm/index.d.ts +3 -0
- package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
- package/dist/views/Login/LoginForm/index.js +29 -53
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Login/index.d.ts.map +1 -1
- package/dist/views/Login/index.js +7 -0
- package/dist/views/Login/index.js.map +1 -1
- package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
- package/dist/views/Logout/LogoutClient.js +5 -1
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Logout/index.js +2 -2
- package/dist/views/Logout/index.js.map +1 -1
- package/dist/views/NotFound/index.client.js +2 -2
- package/dist/views/NotFound/index.client.js.map +1 -1
- package/dist/views/NotFound/index.d.ts.map +1 -1
- package/dist/views/NotFound/index.js +5 -1
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/NotFound/meta.d.ts +2 -2
- package/dist/views/NotFound/meta.d.ts.map +1 -1
- package/dist/views/NotFound/meta.js.map +1 -1
- package/dist/views/ResetPassword/index.client.d.ts.map +1 -1
- package/dist/views/ResetPassword/index.client.js +9 -5
- package/dist/views/ResetPassword/index.client.js.map +1 -1
- package/dist/views/ResetPassword/index.d.ts.map +1 -1
- package/dist/views/ResetPassword/index.js +7 -3
- package/dist/views/ResetPassword/index.js.map +1 -1
- package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
- package/dist/views/Root/getViewFromConfig.js +5 -1
- package/dist/views/Root/getViewFromConfig.js.map +1 -1
- package/dist/views/Root/index.d.ts +2 -2
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +14 -8
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Verify/index.d.ts.map +1 -1
- package/dist/views/Verify/index.js +9 -2
- package/dist/views/Verify/index.js.map +1 -1
- package/dist/views/Version/Default/SetStepNav.d.ts +1 -2
- package/dist/views/Version/Default/SetStepNav.d.ts.map +1 -1
- package/dist/views/Version/Default/SetStepNav.js +21 -6
- package/dist/views/Version/Default/SetStepNav.js.map +1 -1
- package/dist/views/Version/Default/index.d.ts.map +1 -1
- package/dist/views/Version/Default/index.js +3 -2
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts +1 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts +3 -3
- package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts +1 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/types.d.ts +1 -2
- package/dist/views/Version/RenderFieldsToDiff/types.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/types.js.map +1 -1
- package/dist/views/Version/Restore/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.js +11 -5
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Version/index.d.ts.map +1 -1
- package/dist/views/Version/index.js +4 -4
- package/dist/views/Version/index.js.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.d.ts.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.js +10 -4
- package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/ResetPassword/index.client.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport {\n ConfirmPasswordField,\n Form,\n FormSubmit,\n HiddenField,\n PasswordField,\n useAuth,\n useConfig,\n useFormFields,\n useTranslation,\n} from '@payloadcms/ui'\nimport { useRouter } from 'next/navigation.js'\nimport React from 'react'\nimport { toast } from 'sonner'\n\ntype Args = {\n token: string\n}\n\nconst initialState: FormState = {\n 'confirm-password': {\n initialValue: '',\n valid: false,\n value: '',\n },\n password: {\n initialValue: '',\n valid: false,\n value: '',\n },\n}\n\nexport const ResetPasswordClient: React.FC<Args> = ({ token }) => {\n const i18n = useTranslation()\n const {\n admin: { user: userSlug
|
|
1
|
+
{"version":3,"sources":["../../../src/views/ResetPassword/index.client.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport {\n ConfirmPasswordField,\n Form,\n FormSubmit,\n HiddenField,\n PasswordField,\n useAuth,\n useConfig,\n useFormFields,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { useRouter } from 'next/navigation.js'\nimport React from 'react'\nimport { toast } from 'sonner'\n\ntype Args = {\n token: string\n}\n\nconst initialState: FormState = {\n 'confirm-password': {\n initialValue: '',\n valid: false,\n value: '',\n },\n password: {\n initialValue: '',\n valid: false,\n value: '',\n },\n}\n\nexport const ResetPasswordClient: React.FC<Args> = ({ token }) => {\n const i18n = useTranslation()\n const {\n admin: {\n routes: { login: loginRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute, api: apiRoute },\n serverURL,\n } = useConfig()\n\n const history = useRouter()\n\n const { fetchFullUser } = useAuth()\n\n const onSuccess = React.useCallback(\n async (data) => {\n if (data.token) {\n await fetchFullUser()\n history.push(adminRoute)\n } else {\n history.push(\n formatAdminURL({\n adminRoute,\n path: loginRoute,\n }),\n )\n toast.success(i18n.t('general:updatedSuccessfully'))\n }\n },\n [fetchFullUser, history, adminRoute, i18n],\n )\n\n return (\n <Form\n action={`${serverURL}${apiRoute}/${userSlug}/reset-password`}\n initialState={initialState}\n method=\"POST\"\n onSuccess={onSuccess}\n >\n <PasswordToConfirm />\n <ConfirmPasswordField />\n <HiddenField forceUsePathFromProps name=\"token\" value={token} />\n <FormSubmit>{i18n.t('authentication:resetPassword')}</FormSubmit>\n </Form>\n )\n}\n\nconst PasswordToConfirm = () => {\n const { t } = useTranslation()\n const { value: confirmValue } = useFormFields(\n ([fields]) => (fields && fields?.['confirm-password']) || null,\n )\n\n const validate = React.useCallback(\n (value: string) => {\n if (!value) {\n return t('validation:required')\n }\n\n if (value === confirmValue) {\n return true\n }\n\n return t('fields:passwordsDoNotMatch')\n },\n [confirmValue, t],\n )\n\n return (\n <PasswordField\n autoComplete=\"off\"\n label={t('authentication:newPassword')}\n name=\"password\"\n required\n validate={validate}\n />\n )\n}\n"],"names":["ConfirmPasswordField","Form","FormSubmit","HiddenField","PasswordField","useAuth","useConfig","useFormFields","useTranslation","formatAdminURL","useRouter","React","toast","initialState","initialValue","valid","value","password","ResetPasswordClient","token","i18n","admin","routes","login","loginRoute","user","userSlug","adminRoute","api","apiRoute","serverURL","history","fetchFullUser","onSuccess","useCallback","data","push","path","success","t","action","method","PasswordToConfirm","forceUsePathFromProps","name","confirmValue","fields","validate","autoComplete","label","required"],"mappings":"AAAA;;AAGA,SACEA,oBAAoB,EACpBC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,SAAS,QAAQ,qBAAoB;AAC9C,OAAOC,WAAW,QAAO;AACzB,SAASC,KAAK,QAAQ,SAAQ;AAM9B,MAAMC,eAA0B;IAC9B,oBAAoB;QAClBC,cAAc;QACdC,OAAO;QACPC,OAAO;IACT;IACAC,UAAU;QACRH,cAAc;QACdC,OAAO;QACPC,OAAO;IACT;AACF;AAEA,OAAO,MAAME,sBAAsC,CAAC,EAAEC,KAAK,EAAE;IAC3D,MAAMC,OAAOZ;IACb,MAAM,EACJa,OAAO,EACLC,QAAQ,EAAEC,OAAOC,UAAU,EAAE,EAC7BC,MAAMC,QAAQ,EACf,EACDJ,QAAQ,EAAED,OAAOM,UAAU,EAAEC,KAAKC,QAAQ,EAAE,EAC5CC,SAAS,EACV,GAAGxB;IAEJ,MAAMyB,UAAUrB;IAEhB,MAAM,EAAEsB,aAAa,EAAE,GAAG3B;IAE1B,MAAM4B,YAAYtB,MAAMuB,WAAW,CACjC,OAAOC;QACL,IAAIA,KAAKhB,KAAK,EAAE;YACd,MAAMa;YACND,QAAQK,IAAI,CAACT;QACf,OAAO;YACLI,QAAQK,IAAI,CACV3B,eAAe;gBACbkB;gBACAU,MAAMb;YACR;YAEFZ,MAAM0B,OAAO,CAAClB,KAAKmB,CAAC,CAAC;QACvB;IACF,GACA;QAACP;QAAeD;QAASJ;QAAYP;KAAK;IAG5C,qBACE,MAACnB;QACCuC,QAAQ,CAAC,EAAEV,UAAU,EAAED,SAAS,CAAC,EAAEH,SAAS,eAAe,CAAC;QAC5Db,cAAcA;QACd4B,QAAO;QACPR,WAAWA;;0BAEX,KAACS;0BACD,KAAC1C;0BACD,KAACG;gBAAYwC,qBAAqB;gBAACC,MAAK;gBAAQ5B,OAAOG;;0BACvD,KAACjB;0BAAYkB,KAAKmB,CAAC,CAAC;;;;AAG1B,EAAC;AAED,MAAMG,oBAAoB;IACxB,MAAM,EAAEH,CAAC,EAAE,GAAG/B;IACd,MAAM,EAAEQ,OAAO6B,YAAY,EAAE,GAAGtC,cAC9B,CAAC,CAACuC,OAAO,GAAK,AAACA,UAAUA,QAAQ,CAAC,mBAAmB,IAAK;IAG5D,MAAMC,WAAWpC,MAAMuB,WAAW,CAChC,CAAClB;QACC,IAAI,CAACA,OAAO;YACV,OAAOuB,EAAE;QACX;QAEA,IAAIvB,UAAU6B,cAAc;YAC1B,OAAO;QACT;QAEA,OAAON,EAAE;IACX,GACA;QAACM;QAAcN;KAAE;IAGnB,qBACE,KAACnC;QACC4C,cAAa;QACbC,OAAOV,EAAE;QACTK,MAAK;QACLM,QAAQ;QACRH,UAAUA;;AAGhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/ResetPassword/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/ResetPassword/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,sBAAsB,mBAAmB,CAAA;AAItD,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAA;AAEzD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA4DlD,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Translation } from '@payloadcms/ui';
|
|
3
|
+
import { formatAdminURL } from '@payloadcms/ui/shared';
|
|
3
4
|
import LinkImport from 'next/link.js';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { MinimalTemplate } from '../../templates/Minimal/index.js';
|
|
@@ -11,7 +12,7 @@ export const ResetPassword = ({ initPageResult, params })=>{
|
|
|
11
12
|
const { req } = initPageResult;
|
|
12
13
|
const { segments: [_, token] } = params;
|
|
13
14
|
const { i18n, payload: { config }, user } = req;
|
|
14
|
-
const { admin: { routes: { account: accountRoute } }, routes: { admin } } = config;
|
|
15
|
+
const { admin: { routes: { account: accountRoute } }, routes: { admin: adminRoute } } = config;
|
|
15
16
|
if (user) {
|
|
16
17
|
return /*#__PURE__*/ _jsx(MinimalTemplate, {
|
|
17
18
|
className: resetPasswordBaseClass,
|
|
@@ -25,7 +26,10 @@ export const ResetPassword = ({ initPageResult, params })=>{
|
|
|
25
26
|
children: /*#__PURE__*/ _jsx(Translation, {
|
|
26
27
|
elements: {
|
|
27
28
|
'0': ({ children })=>/*#__PURE__*/ _jsx(Link, {
|
|
28
|
-
href:
|
|
29
|
+
href: formatAdminURL({
|
|
30
|
+
adminRoute,
|
|
31
|
+
path: accountRoute
|
|
32
|
+
}),
|
|
29
33
|
children: children
|
|
30
34
|
})
|
|
31
35
|
},
|
|
@@ -38,7 +42,7 @@ export const ResetPassword = ({ initPageResult, params })=>{
|
|
|
38
42
|
Link: Link,
|
|
39
43
|
buttonStyle: "secondary",
|
|
40
44
|
el: "link",
|
|
41
|
-
to:
|
|
45
|
+
to: adminRoute,
|
|
42
46
|
children: i18n.t('general:backToDashboard')
|
|
43
47
|
})
|
|
44
48
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/ResetPassword/index.tsx"],"sourcesContent":["import type { AdminViewProps } from 'payload'\n\nimport { Button, Translation } from '@payloadcms/ui'\nimport LinkImport from 'next/link.js'\nimport React from 'react'\n\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { ResetPasswordClient } from './index.client.js'\nimport './index.scss'\n\nexport const resetPasswordBaseClass = 'reset-password'\n\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nexport { generateResetPasswordMetadata } from './meta.js'\n\nexport const ResetPassword: React.FC<AdminViewProps> = ({ initPageResult, params }) => {\n const { req } = initPageResult\n\n const {\n segments: [_, token],\n } = params\n\n const {\n i18n,\n payload: { config },\n user,\n } = req\n\n const {\n admin: {\n routes: { account: accountRoute },\n },\n routes: { admin },\n } = config\n\n if (user) {\n return (\n <MinimalTemplate className={resetPasswordBaseClass}>\n <div className={`${resetPasswordBaseClass}__wrap`}>\n <h1>{i18n.t('authentication:alreadyLoggedIn')}</h1>\n <p>\n <Translation\n elements={{\n '0': ({ children }) => <Link
|
|
1
|
+
{"version":3,"sources":["../../../src/views/ResetPassword/index.tsx"],"sourcesContent":["import type { AdminViewProps } from 'payload'\n\nimport { Button, Translation } from '@payloadcms/ui'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport LinkImport from 'next/link.js'\nimport React from 'react'\n\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { ResetPasswordClient } from './index.client.js'\nimport './index.scss'\n\nexport const resetPasswordBaseClass = 'reset-password'\n\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nexport { generateResetPasswordMetadata } from './meta.js'\n\nexport const ResetPassword: React.FC<AdminViewProps> = ({ initPageResult, params }) => {\n const { req } = initPageResult\n\n const {\n segments: [_, token],\n } = params\n\n const {\n i18n,\n payload: { config },\n user,\n } = req\n\n const {\n admin: {\n routes: { account: accountRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (user) {\n return (\n <MinimalTemplate className={resetPasswordBaseClass}>\n <div className={`${resetPasswordBaseClass}__wrap`}>\n <h1>{i18n.t('authentication:alreadyLoggedIn')}</h1>\n <p>\n <Translation\n elements={{\n '0': ({ children }) => (\n <Link\n href={formatAdminURL({\n adminRoute,\n path: accountRoute,\n })}\n >\n {children}\n </Link>\n ),\n }}\n i18nKey=\"authentication:loggedInChangePassword\"\n t={i18n.t}\n />\n </p>\n <br />\n <Button Link={Link} buttonStyle=\"secondary\" el=\"link\" to={adminRoute}>\n {i18n.t('general:backToDashboard')}\n </Button>\n </div>\n </MinimalTemplate>\n )\n }\n\n return (\n <MinimalTemplate className={resetPasswordBaseClass}>\n <div className={`${resetPasswordBaseClass}__wrap`}>\n <h1>{i18n.t('authentication:resetPassword')}</h1>\n <ResetPasswordClient token={token} />\n </div>\n </MinimalTemplate>\n )\n}\n"],"names":["Button","Translation","formatAdminURL","LinkImport","React","MinimalTemplate","ResetPasswordClient","resetPasswordBaseClass","Link","default","generateResetPasswordMetadata","ResetPassword","initPageResult","params","req","segments","_","token","i18n","payload","config","user","admin","routes","account","accountRoute","adminRoute","className","div","h1","t","p","elements","children","href","path","i18nKey","br","buttonStyle","el","to"],"mappings":";AAEA,SAASA,MAAM,EAAEC,WAAW,QAAQ,iBAAgB;AACpD,SAASC,cAAc,QAAQ,wBAAuB;AACtD,OAAOC,gBAAgB,eAAc;AACrC,OAAOC,WAAW,QAAO;AAEzB,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,mBAAmB,QAAQ,oBAAmB;AAGvD,OAAO,MAAMC,yBAAyB,iBAAgB;AAEtD,MAAMC,OAAQL,WAAWM,OAAO,IAAIN;AAEpC,SAASO,6BAA6B,QAAQ,YAAW;AAEzD,OAAO,MAAMC,gBAA0C,CAAC,EAAEC,cAAc,EAAEC,MAAM,EAAE;IAChF,MAAM,EAAEC,GAAG,EAAE,GAAGF;IAEhB,MAAM,EACJG,UAAU,CAACC,GAAGC,MAAM,EACrB,GAAGJ;IAEJ,MAAM,EACJK,IAAI,EACJC,SAAS,EAAEC,MAAM,EAAE,EACnBC,IAAI,EACL,GAAGP;IAEJ,MAAM,EACJQ,OAAO,EACLC,QAAQ,EAAEC,SAASC,YAAY,EAAE,EAClC,EACDF,QAAQ,EAAED,OAAOI,UAAU,EAAE,EAC9B,GAAGN;IAEJ,IAAIC,MAAM;QACR,qBACE,KAAChB;YAAgBsB,WAAWpB;sBAC1B,cAAA,MAACqB;gBAAID,WAAW,CAAC,EAAEpB,uBAAuB,MAAM,CAAC;;kCAC/C,KAACsB;kCAAIX,KAAKY,CAAC,CAAC;;kCACZ,KAACC;kCACC,cAAA,KAAC9B;4BACC+B,UAAU;gCACR,KAAK,CAAC,EAAEC,QAAQ,EAAE,iBAChB,KAACzB;wCACC0B,MAAMhC,eAAe;4CACnBwB;4CACAS,MAAMV;wCACR;kDAECQ;;4BAGP;4BACAG,SAAQ;4BACRN,GAAGZ,KAAKY,CAAC;;;kCAGb,KAACO;kCACD,KAACrC;wBAAOQ,MAAMA;wBAAM8B,aAAY;wBAAYC,IAAG;wBAAOC,IAAId;kCACvDR,KAAKY,CAAC,CAAC;;;;;IAKlB;IAEA,qBACE,KAACzB;QAAgBsB,WAAWpB;kBAC1B,cAAA,MAACqB;YAAID,WAAW,CAAC,EAAEpB,uBAAuB,MAAM,CAAC;;8BAC/C,KAACsB;8BAAIX,KAAKY,CAAC,CAAC;;8BACZ,KAACxB;oBAAoBW,OAAOA;;;;;AAIpC,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getViewFromConfig.d.ts","sourceRoot":"","sources":["../../../src/views/Root/getViewFromConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getViewFromConfig.d.ts","sourceRoot":"","sources":["../../../src/views/Root/getViewFromConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAA;AAsCjE,eAAO,MAAM,iBAAiB,kEAM3B;IACD,UAAU,MAAA;IACV,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAA;IACD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,KAAG;IACF,WAAW,EAAE,kBAAkB,CAAA;IAC/B,eAAe,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/C,iBAAiB,EAAE,MAAM,CAAA;IACzB,YAAY,EAAE,SAAS,GAAG,SAAS,CAAA;CAkIpC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatAdminURL } from '@payloadcms/ui/shared';
|
|
1
2
|
import { Account } from '../Account/index.js';
|
|
2
3
|
import { CreateFirstUserView } from '../CreateFirstUser/index.js';
|
|
3
4
|
import { Dashboard } from '../Dashboard/index.js';
|
|
@@ -60,7 +61,10 @@ export const getViewFromConfig = ({ adminRoute, config, currentRoute, searchPara
|
|
|
60
61
|
return isPathMatchingRoute({
|
|
61
62
|
currentRoute,
|
|
62
63
|
exact: true,
|
|
63
|
-
path:
|
|
64
|
+
path: formatAdminURL({
|
|
65
|
+
adminRoute,
|
|
66
|
+
path: route
|
|
67
|
+
})
|
|
64
68
|
});
|
|
65
69
|
});
|
|
66
70
|
if (matchedRoute) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Root/getViewFromConfig.tsx"],"sourcesContent":["import type { AdminViewComponent, SanitizedConfig } from 'payload'\n\nimport type { initPage } from '../../utilities/initPage/index.js'\n\nimport { Account } from '../Account/index.js'\nimport { CreateFirstUserView } from '../CreateFirstUser/index.js'\nimport { Dashboard } from '../Dashboard/index.js'\nimport { Document as DocumentView } from '../Document/index.js'\nimport { ForgotPasswordView, forgotPasswordBaseClass } from '../ForgotPassword/index.js'\nimport { ListView } from '../List/index.js'\nimport { LoginView, loginBaseClass } from '../Login/index.js'\nimport { LogoutInactivity, LogoutView } from '../Logout/index.js'\nimport { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { Verify, verifyBaseClass } from '../Verify/index.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\nconst baseClasses = {\n account: 'account',\n forgot: forgotPasswordBaseClass,\n login: loginBaseClass,\n reset: resetPasswordBaseClass,\n verify: verifyBaseClass,\n}\n\ntype OneSegmentViews = {\n [K in Exclude<keyof SanitizedConfig['admin']['routes'], 'reset'>]: AdminViewComponent\n}\n\nconst oneSegmentViews: OneSegmentViews = {\n account: Account,\n createFirstUser: CreateFirstUserView,\n forgot: ForgotPasswordView,\n inactivity: LogoutInactivity,\n login: LoginView,\n logout: LogoutView,\n unauthorized: UnauthorizedView,\n}\n\nexport const getViewFromConfig = ({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n}: {\n adminRoute\n config: SanitizedConfig\n currentRoute: string\n searchParams: {\n [key: string]: string | string[]\n }\n segments: string[]\n}): {\n DefaultView: AdminViewComponent\n initPageOptions: Parameters<typeof initPage>[0]\n templateClassName: string\n templateType: 'default' | 'minimal'\n} => {\n let ViewToRender: AdminViewComponent = null\n let templateClassName: string\n let templateType: 'default' | 'minimal' | undefined\n\n const initPageOptions: Parameters<typeof initPage>[0] = {\n config,\n route: currentRoute,\n searchParams,\n }\n\n const [segmentOne, segmentTwo] = segments\n\n const isGlobal = segmentOne === 'globals'\n const isCollection = segmentOne === 'collections'\n\n switch (segments.length) {\n case 0: {\n if (currentRoute === adminRoute) {\n ViewToRender = Dashboard\n templateClassName = 'dashboard'\n templateType = 'default'\n initPageOptions.redirectUnauthenticatedUser = true\n }\n break\n }\n case 1: {\n // users can override the default routes via `admin.routes` config\n // i.e.{ admin: { routes: { logout: '/sign-out', inactivity: '/idle' }}}\n let viewToRender: keyof typeof oneSegmentViews\n\n if (config.admin.routes) {\n const matchedRoute = Object.entries(config.admin.routes).find(([, route]) => {\n return isPathMatchingRoute({\n currentRoute,\n exact: true,\n path:
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Root/getViewFromConfig.tsx"],"sourcesContent":["import type { AdminViewComponent, SanitizedConfig } from 'payload'\n\nimport { formatAdminURL } from '@payloadcms/ui/shared'\n\nimport type { initPage } from '../../utilities/initPage/index.js'\n\nimport { Account } from '../Account/index.js'\nimport { CreateFirstUserView } from '../CreateFirstUser/index.js'\nimport { Dashboard } from '../Dashboard/index.js'\nimport { Document as DocumentView } from '../Document/index.js'\nimport { ForgotPasswordView, forgotPasswordBaseClass } from '../ForgotPassword/index.js'\nimport { ListView } from '../List/index.js'\nimport { LoginView, loginBaseClass } from '../Login/index.js'\nimport { LogoutInactivity, LogoutView } from '../Logout/index.js'\nimport { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { Verify, verifyBaseClass } from '../Verify/index.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\nconst baseClasses = {\n account: 'account',\n forgot: forgotPasswordBaseClass,\n login: loginBaseClass,\n reset: resetPasswordBaseClass,\n verify: verifyBaseClass,\n}\n\ntype OneSegmentViews = {\n [K in Exclude<keyof SanitizedConfig['admin']['routes'], 'reset'>]: AdminViewComponent\n}\n\nconst oneSegmentViews: OneSegmentViews = {\n account: Account,\n createFirstUser: CreateFirstUserView,\n forgot: ForgotPasswordView,\n inactivity: LogoutInactivity,\n login: LoginView,\n logout: LogoutView,\n unauthorized: UnauthorizedView,\n}\n\nexport const getViewFromConfig = ({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n}: {\n adminRoute\n config: SanitizedConfig\n currentRoute: string\n searchParams: {\n [key: string]: string | string[]\n }\n segments: string[]\n}): {\n DefaultView: AdminViewComponent\n initPageOptions: Parameters<typeof initPage>[0]\n templateClassName: string\n templateType: 'default' | 'minimal'\n} => {\n let ViewToRender: AdminViewComponent = null\n let templateClassName: string\n let templateType: 'default' | 'minimal' | undefined\n\n const initPageOptions: Parameters<typeof initPage>[0] = {\n config,\n route: currentRoute,\n searchParams,\n }\n\n const [segmentOne, segmentTwo] = segments\n\n const isGlobal = segmentOne === 'globals'\n const isCollection = segmentOne === 'collections'\n\n switch (segments.length) {\n case 0: {\n if (currentRoute === adminRoute) {\n ViewToRender = Dashboard\n templateClassName = 'dashboard'\n templateType = 'default'\n initPageOptions.redirectUnauthenticatedUser = true\n }\n break\n }\n case 1: {\n // users can override the default routes via `admin.routes` config\n // i.e.{ admin: { routes: { logout: '/sign-out', inactivity: '/idle' }}}\n let viewToRender: keyof typeof oneSegmentViews\n\n if (config.admin.routes) {\n const matchedRoute = Object.entries(config.admin.routes).find(([, route]) => {\n return isPathMatchingRoute({\n currentRoute,\n exact: true,\n path: formatAdminURL({ adminRoute, path: route }),\n })\n })\n\n if (matchedRoute) {\n viewToRender = matchedRoute[0] as keyof typeof oneSegmentViews\n }\n }\n\n if (oneSegmentViews[viewToRender]) {\n // --> /account\n // --> /create-first-user\n // --> /forgot\n // --> /login\n // --> /logout\n // --> /logout-inactivity\n // --> /unauthorized\n\n ViewToRender = oneSegmentViews[viewToRender]\n templateClassName = baseClasses[viewToRender]\n templateType = 'minimal'\n\n if (viewToRender === 'account') {\n initPageOptions.redirectUnauthenticatedUser = true\n templateType = 'default'\n }\n }\n break\n }\n case 2: {\n if (segmentOne === 'reset') {\n // --> /reset/:token\n ViewToRender = ResetPassword\n templateClassName = baseClasses[segmentTwo]\n templateType = 'minimal'\n }\n\n if (isCollection) {\n // --> /collections/:collectionSlug\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = ListView\n templateClassName = `${segmentTwo}-list`\n templateType = 'default'\n } else if (isGlobal) {\n // --> /globals/:globalSlug\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = 'global-edit'\n templateType = 'default'\n }\n break\n }\n default:\n if (segmentTwo === 'verify') {\n // --> /:collectionSlug/verify/:token\n ViewToRender = Verify\n templateClassName = 'verify'\n templateType = 'minimal'\n } else if (isCollection) {\n // Custom Views\n // --> /collections/:collectionSlug/:id\n // --> /collections/:collectionSlug/:id/preview\n // --> /collections/:collectionSlug/:id/versions\n // --> /collections/:collectionSlug/:id/versions/:versionId\n // --> /collections/:collectionSlug/:id/api\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = `collection-default-edit`\n templateType = 'default'\n } else if (isGlobal) {\n // Custom Views\n // --> /globals/:globalSlug/versions\n // --> /globals/:globalSlug/preview\n // --> /globals/:globalSlug/versions/:versionId\n // --> /globals/:globalSlug/api\n initPageOptions.redirectUnauthenticatedUser = true\n ViewToRender = DocumentView\n templateClassName = `global-edit`\n templateType = 'default'\n }\n break\n }\n\n if (!ViewToRender) {\n ViewToRender = getCustomViewByRoute({ config, currentRoute })\n }\n\n return {\n DefaultView: ViewToRender,\n initPageOptions,\n templateClassName,\n templateType,\n }\n}\n"],"names":["formatAdminURL","Account","CreateFirstUserView","Dashboard","Document","DocumentView","ForgotPasswordView","forgotPasswordBaseClass","ListView","LoginView","loginBaseClass","LogoutInactivity","LogoutView","ResetPassword","resetPasswordBaseClass","UnauthorizedView","Verify","verifyBaseClass","getCustomViewByRoute","isPathMatchingRoute","baseClasses","account","forgot","login","reset","verify","oneSegmentViews","createFirstUser","inactivity","logout","unauthorized","getViewFromConfig","adminRoute","config","currentRoute","searchParams","segments","ViewToRender","templateClassName","templateType","initPageOptions","route","segmentOne","segmentTwo","isGlobal","isCollection","length","redirectUnauthenticatedUser","viewToRender","admin","routes","matchedRoute","Object","entries","find","exact","path","DefaultView"],"mappings":"AAEA,SAASA,cAAc,QAAQ,wBAAuB;AAItD,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,mBAAmB,QAAQ,8BAA6B;AACjE,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,YAAYC,YAAY,QAAQ,uBAAsB;AAC/D,SAASC,kBAAkB,EAAEC,uBAAuB,QAAQ,6BAA4B;AACxF,SAASC,QAAQ,QAAQ,mBAAkB;AAC3C,SAASC,SAAS,EAAEC,cAAc,QAAQ,oBAAmB;AAC7D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,qBAAoB;AACjE,SAASC,aAAa,EAAEC,sBAAsB,QAAQ,4BAA2B;AACjF,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,MAAM,EAAEC,eAAe,QAAQ,qBAAoB;AAC5D,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,MAAMC,cAAc;IAClBC,SAAS;IACTC,QAAQf;IACRgB,OAAOb;IACPc,OAAOV;IACPW,QAAQR;AACV;AAMA,MAAMS,kBAAmC;IACvCL,SAASpB;IACT0B,iBAAiBzB;IACjBoB,QAAQhB;IACRsB,YAAYjB;IACZY,OAAOd;IACPoB,QAAQjB;IACRkB,cAAcf;AAChB;AAEA,OAAO,MAAMgB,oBAAoB,CAAC,EAChCC,UAAU,EACVC,MAAM,EACNC,YAAY,EACZC,YAAY,EACZC,QAAQ,EAST;IAMC,IAAIC,eAAmC;IACvC,IAAIC;IACJ,IAAIC;IAEJ,MAAMC,kBAAkD;QACtDP;QACAQ,OAAOP;QACPC;IACF;IAEA,MAAM,CAACO,YAAYC,WAAW,GAAGP;IAEjC,MAAMQ,WAAWF,eAAe;IAChC,MAAMG,eAAeH,eAAe;IAEpC,OAAQN,SAASU,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2BAA2B,GAAG;oBAC9CV,eAAehC;oBACfiC,oBAAoB;oBACpBC,eAAe;gBACjB;gBACA;YACF;QACA;YACE,IAAII,eAAe,UAAU;gBAC3B,qCAAqC;gBACrCN,eAAerB;gBACfsB,oBAAoB;gBACpBC,eAAe;YACjB,OAAO,IAAIM,cAAc;gBACvB,eAAe;gBACf,uCAAuC;gBACvC,+CAA+C;gBAC/C,gDAAgD;gBAChD,2DAA2D;gBAC3D,2CAA2C;gBAC3CL,gBAAgBO,2BAA2B,GAAG;gBAC9CV,eAAehC;gBACfiC,oBAAoB,CAAC,uBAAuB,CAAC;gBAC7CC,eAAe;YACjB,OAAO,IAAIK,UAAU;gBACnB,eAAe;gBACf,oCAAoC;gBACpC,mCAAmC;gBACnC,+CAA+C;gBAC/C,+BAA+B;gBAC/BJ,gBAAgBO,2BAA2B,GAAG;gBAC9CV,eAAehC;gBACfiC,oBAAoB,CAAC,WAAW,CAAC;gBACjCC,eAAe;YACjB;YACA;IACJ;IAEA,IAAI,CAACF,cAAc;QACjBA,eAAenB,qBAAqB;YAAEe;YAAQC;QAAa;IAC7D;IAEA,OAAO;QACLuB,aAAapB;QACbG;QACAF;QACAC;IACF;AACF,EAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
2
|
import type { Metadata } from 'next';
|
|
3
3
|
import type { SanitizedConfig } from 'payload';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
export { generatePageMetadata } from './meta.js';
|
|
6
6
|
export type GenerateViewMetadata = (args: {
|
|
7
7
|
config: SanitizedConfig;
|
|
8
|
-
i18n:
|
|
8
|
+
i18n: I18nClient;
|
|
9
9
|
isEditing?: boolean;
|
|
10
10
|
params?: {
|
|
11
11
|
[key: string]: string | string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAmB,MAAM,OAAO,CAAA;AAOvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE;IACxC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;CAC9C,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvB,eAAO,MAAM,QAAQ,qDAIlB;IACD,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAChC,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,CAAA;IACD,YAAY,EAAE;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAA;CACF,+BAoGA,CAAA"}
|
package/dist/views/Root/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { WithServerSideProps } from '@payloadcms/ui/shared';
|
|
2
|
+
import { WithServerSideProps, formatAdminURL } from '@payloadcms/ui/shared';
|
|
3
3
|
import { notFound, redirect } from 'next/navigation.js';
|
|
4
4
|
import React, { Fragment } from 'react';
|
|
5
5
|
import { DefaultTemplate } from '../../templates/Default/index.js';
|
|
@@ -9,8 +9,11 @@ import { getViewFromConfig } from './getViewFromConfig.js';
|
|
|
9
9
|
export { generatePageMetadata } from './meta.js';
|
|
10
10
|
export const RootPage = async ({ config: configPromise, params, searchParams })=>{
|
|
11
11
|
const config = await configPromise;
|
|
12
|
-
const { admin: { routes: { createFirstUser:
|
|
13
|
-
const currentRoute =
|
|
12
|
+
const { admin: { routes: { createFirstUser: _createFirstUserRoute }, user: userSlug }, routes: { admin: adminRoute } } = config;
|
|
13
|
+
const currentRoute = formatAdminURL({
|
|
14
|
+
adminRoute,
|
|
15
|
+
path: `${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`
|
|
16
|
+
});
|
|
14
17
|
const segments = Array.isArray(params.segments) ? params.segments : [];
|
|
15
18
|
const { DefaultView, initPageOptions, templateClassName, templateType } = getViewFromConfig({
|
|
16
19
|
adminRoute,
|
|
@@ -29,16 +32,19 @@ export const RootPage = async ({ config: configPromise, params, searchParams })=
|
|
|
29
32
|
collection: userSlug,
|
|
30
33
|
req: initPageResult?.req
|
|
31
34
|
})?.then((doc)=>!!doc);
|
|
32
|
-
const
|
|
35
|
+
const createFirstUserRoute = formatAdminURL({
|
|
36
|
+
adminRoute,
|
|
37
|
+
path: _createFirstUserRoute
|
|
38
|
+
});
|
|
33
39
|
const collectionConfig = config.collections.find(({ slug })=>slug === userSlug);
|
|
34
40
|
const disableLocalStrategy = collectionConfig?.auth?.disableLocalStrategy;
|
|
35
|
-
if (disableLocalStrategy && currentRoute ===
|
|
41
|
+
if (disableLocalStrategy && currentRoute === createFirstUserRoute) {
|
|
36
42
|
redirect(adminRoute);
|
|
37
43
|
}
|
|
38
|
-
if (!dbHasUser && currentRoute !==
|
|
39
|
-
redirect(
|
|
44
|
+
if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {
|
|
45
|
+
redirect(createFirstUserRoute);
|
|
40
46
|
}
|
|
41
|
-
if (dbHasUser && currentRoute ===
|
|
47
|
+
if (dbHasUser && currentRoute === createFirstUserRoute) {
|
|
42
48
|
redirect(adminRoute);
|
|
43
49
|
}
|
|
44
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { SanitizedConfig } from 'payload'\n\nimport { WithServerSideProps, formatAdminURL } from '@payloadcms/ui/shared'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { initPage } from '../../utilities/initPage/index.js'\nimport { getViewFromConfig } from './getViewFromConfig.js'\n\nexport { generatePageMetadata } from './meta.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n params,\n searchParams,\n}: {\n config: Promise<SanitizedConfig>\n params: {\n segments: string[]\n }\n searchParams: {\n [key: string]: string | string[]\n }\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const currentRoute = formatAdminURL({\n adminRoute,\n path: `${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const { DefaultView, initPageOptions, templateClassName, templateType } = getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n })\n\n let dbHasUser = false\n\n if (!DefaultView) {\n notFound()\n }\n\n const initPageResult = await initPage(initPageOptions)\n\n if (initPageResult) {\n dbHasUser = await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc)\n\n const createFirstUserRoute = formatAdminURL({ adminRoute, path: _createFirstUserRoute })\n\n const collectionConfig = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = collectionConfig?.auth?.disableLocalStrategy\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n }\n\n const RenderedView = (\n <WithServerSideProps\n Component={DefaultView}\n serverOnlyProps={\n {\n initPageResult,\n params,\n searchParams,\n } as any\n }\n />\n )\n\n return (\n <Fragment>\n {!templateType && <Fragment>{RenderedView}</Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n i18n={initPageResult?.req.i18n}\n locale={initPageResult?.locale}\n params={params}\n payload={initPageResult?.req.payload}\n permissions={initPageResult?.permissions}\n searchParams={searchParams}\n user={initPageResult?.req.user}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: initPageResult.visibleEntities?.collections,\n globals: initPageResult.visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </Fragment>\n )\n}\n"],"names":["WithServerSideProps","formatAdminURL","notFound","redirect","React","Fragment","DefaultTemplate","MinimalTemplate","initPage","getViewFromConfig","generatePageMetadata","RootPage","config","configPromise","params","searchParams","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","DefaultView","initPageOptions","templateClassName","templateType","dbHasUser","initPageResult","req","payload","db","findOne","collection","then","doc","createFirstUserRoute","collectionConfig","collections","find","slug","disableLocalStrategy","auth","Ren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ACZc,KAAKD,gBAAgBC;QACvB,IACEK,KAAK,CAACC,MAAQ,CAAC,CAACA;QAEpB,MAAMC,uBAAuBzC,eAAe;YAAEqB;YAAYE,MAAML;QAAsB;QAEtF,MAAMwB,mBAAmB/B,OAAOgC,WAAW,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASzB;QACxE,MAAM0B,uBAAuBJ,kBAAkBK,MAAMD;QAErD,IAAIA,wBAAwBxB,iBAAiBmB,sBAAsB;YACjEvC,SAASmB;QACX;QAEA,IAAI,CAACW,aAAaV,iBAAiBmB,wBAAwB,CAACK,sBAAsB;YAChF5C,SAASuC;QACX;QAEA,IAAIT,aAAaV,iBAAiBmB,sBAAsB;YACtDvC,SAASmB;QACX;IACF;IAEA,MAAM2B,6BACJ,KAACjD;QACCkD,WAAWrB;QACXsB,iBACE;YACEjB;YACApB;YACAC;QACF;;IAKN,qBACE,MAACV;;YACE,CAAC2B,8BAAgB,KAAC3B;0BAAU4C;;YAC5BjB,iBAAiB,2BAChB,KAACzB;gBAAgB6C,WAAWrB;0BAAoBkB;;YAEjDjB,iBAAiB,2BAChB,KAAC1B;gBACC+C,MAAMnB,gBAAgBC,IAAIkB;gBAC1BC,QAAQpB,gBAAgBoB;gBACxBxC,QAAQA;gBACRsB,SAASF,gBAAgBC,IAAIC;gBAC7BmB,aAAarB,gBAAgBqB;gBAC7BxC,cAAcA;gBACdK,MAAMc,gBAAgBC,IAAIf;gBAC1BoC,iBAAiB;oBACf,+KAA+K;oBAC/K,2EAA2E;oBAC3EZ,aAAaV,eAAesB,eAAe,EAAEZ;oBAC7Ca,SAASvB,eAAesB,eAAe,EAAEC;gBAC3C;0BAECR;;;;AAKX,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Verify/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Verify/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,eAAe,WAAW,CAAA;AAEvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAElD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoD3C,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatAdminURL } from '@payloadcms/ui/shared';
|
|
2
3
|
import { redirect } from 'next/navigation.js';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import { Logo } from '../../elements/Logo/index.js';
|
|
@@ -17,10 +18,16 @@ export const Verify = async ({ initPageResult, params, searchParams })=>{
|
|
|
17
18
|
collection: collectionSlug,
|
|
18
19
|
token
|
|
19
20
|
});
|
|
20
|
-
return redirect(
|
|
21
|
+
return redirect(formatAdminURL({
|
|
22
|
+
adminRoute,
|
|
23
|
+
path: '/login'
|
|
24
|
+
}));
|
|
21
25
|
} catch (e) {
|
|
22
26
|
// already verified
|
|
23
|
-
if (e?.status === 202) redirect(
|
|
27
|
+
if (e?.status === 202) redirect(formatAdminURL({
|
|
28
|
+
adminRoute,
|
|
29
|
+
path: '/login'
|
|
30
|
+
}));
|
|
24
31
|
textToRender = req.t('authentication:unableToVerify');
|
|
25
32
|
}
|
|
26
33
|
return /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Verify/index.tsx"],"sourcesContent":["import type { AdminViewProps } from 'payload'\n\nimport { redirect } from 'next/navigation.js'\nimport React from 'react'\n\nimport { Logo } from '../../elements/Logo/index.js'\nimport './index.scss'\n\nexport const verifyBaseClass = 'verify'\n\nexport { generateVerifyMetadata } from './meta.js'\n\nexport const Verify: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\n // /:collectionSlug/verify/:token\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [collectionSlug, verify, token] = params.segments\n const { locale, permissions, req } = initPageResult\n\n const {\n i18n,\n payload: { config },\n payload,\n user,\n } = req\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n let textToRender\n\n try {\n await req.payload.verifyEmail({\n collection: collectionSlug,\n token,\n })\n\n return redirect(
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Verify/index.tsx"],"sourcesContent":["import type { AdminViewProps } from 'payload'\n\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React from 'react'\n\nimport { Logo } from '../../elements/Logo/index.js'\nimport './index.scss'\n\nexport const verifyBaseClass = 'verify'\n\nexport { generateVerifyMetadata } from './meta.js'\n\nexport const Verify: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\n // /:collectionSlug/verify/:token\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [collectionSlug, verify, token] = params.segments\n const { locale, permissions, req } = initPageResult\n\n const {\n i18n,\n payload: { config },\n payload,\n user,\n } = req\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n let textToRender\n\n try {\n await req.payload.verifyEmail({\n collection: collectionSlug,\n token,\n })\n\n return redirect(formatAdminURL({ adminRoute, path: '/login' }))\n } catch (e) {\n // already verified\n if (e?.status === 202) redirect(formatAdminURL({ adminRoute, path: '/login' }))\n textToRender = req.t('authentication:unableToVerify')\n }\n\n return (\n <React.Fragment>\n <div className={`${verifyBaseClass}__brand`}>\n <Logo\n i18n={i18n}\n locale={locale}\n params={params}\n payload={payload}\n permissions={permissions}\n searchParams={searchParams}\n user={user}\n />\n </div>\n <h2>{textToRender}</h2>\n </React.Fragment>\n )\n}\n"],"names":["formatAdminURL","redirect","React","Logo","verifyBaseClass","generateVerifyMetadata","Verify","initPageResult","params","searchParams","collectionSlug","verify","token","segments","locale","permissions","req","i18n","payload","config","user","routes","admin","adminRoute","textToRender","verifyEmail","collection","path","e","status","t","Fragment","div","className","h2"],"mappings":";AAEA,SAASA,cAAc,QAAQ,wBAAuB;AACtD,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,OAAOC,WAAW,QAAO;AAEzB,SAASC,IAAI,QAAQ,+BAA8B;AAGnD,OAAO,MAAMC,kBAAkB,SAAQ;AAEvC,SAASC,sBAAsB,QAAQ,YAAW;AAElD,OAAO,MAAMC,SAAmC,OAAO,EACrDC,cAAc,EACdC,MAAM,EACNC,YAAY,EACb;IACC,iCAAiC;IACjC,6DAA6D;IAC7D,MAAM,CAACC,gBAAgBC,QAAQC,MAAM,GAAGJ,OAAOK,QAAQ;IACvD,MAAM,EAAEC,MAAM,EAAEC,WAAW,EAAEC,GAAG,EAAE,GAAGT;IAErC,MAAM,EACJU,IAAI,EACJC,SAAS,EAAEC,MAAM,EAAE,EACnBD,OAAO,EACPE,IAAI,EACL,GAAGJ;IAEJ,MAAM,EACJK,QAAQ,EAAEC,OAAOC,UAAU,EAAE,EAC9B,GAAGJ;IAEJ,IAAIK;IAEJ,IAAI;QACF,MAAMR,IAAIE,OAAO,CAACO,WAAW,CAAC;YAC5BC,YAAYhB;YACZE;QACF;QAEA,OAAOX,SAASD,eAAe;YAAEuB;YAAYI,MAAM;QAAS;IAC9D,EAAE,OAAOC,GAAG;QACV,mBAAmB;QACnB,IAAIA,GAAGC,WAAW,KAAK5B,SAASD,eAAe;YAAEuB;YAAYI,MAAM;QAAS;QAC5EH,eAAeR,IAAIc,CAAC,CAAC;IACvB;IAEA,qBACE,MAAC5B,MAAM6B,QAAQ;;0BACb,KAACC;gBAAIC,WAAW,CAAC,EAAE7B,gBAAgB,OAAO,CAAC;0BACzC,cAAA,KAACD;oBACCc,MAAMA;oBACNH,QAAQA;oBACRN,QAAQA;oBACRU,SAASA;oBACTH,aAAaA;oBACbN,cAAcA;oBACdW,MAAMA;;;0BAGV,KAACc;0BAAIV;;;;AAGX,EAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { FieldMap } from '
|
|
2
|
-
import type { ClientCollectionConfig, ClientGlobalConfig } from 'payload';
|
|
1
|
+
import type { ClientCollectionConfig, ClientGlobalConfig, FieldMap } from 'payload';
|
|
3
2
|
import type React from 'react';
|
|
4
3
|
export declare const SetStepNav: React.FC<{
|
|
5
4
|
collectionConfig?: ClientCollectionConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetStepNav.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/Default/SetStepNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"SetStepNav.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/Default/SetStepNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACnF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;IAChC,gBAAgB,CAAC,EAAE,sBAAsB,CAAA;IACzC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,GAAG,EAAE,GAAG,CAAA;IACR,QAAQ,EAAE,QAAQ,CAAA;IAClB,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CA4GA,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
2
|
import { useConfig, useLocale, useStepNav, useTranslation } from '@payloadcms/ui';
|
|
3
|
-
import { formatDate } from '@payloadcms/ui/shared';
|
|
3
|
+
import { formatAdminURL, formatDate } from '@payloadcms/ui/shared';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
export const SetStepNav = ({ id, collectionConfig, collectionSlug, doc, fieldMap, globalConfig, globalSlug })=>{
|
|
6
6
|
const config = useConfig();
|
|
@@ -38,15 +38,24 @@ export const SetStepNav = ({ id, collectionConfig, collectionSlug, doc, fieldMap
|
|
|
38
38
|
nav = [
|
|
39
39
|
{
|
|
40
40
|
label: getTranslation(pluralLabel, i18n),
|
|
41
|
-
url:
|
|
41
|
+
url: formatAdminURL({
|
|
42
|
+
adminRoute,
|
|
43
|
+
path: `/collections/${collectionSlug}`
|
|
44
|
+
})
|
|
42
45
|
},
|
|
43
46
|
{
|
|
44
47
|
label: docLabel,
|
|
45
|
-
url:
|
|
48
|
+
url: formatAdminURL({
|
|
49
|
+
adminRoute,
|
|
50
|
+
path: `/collections/${collectionSlug}/${id}`
|
|
51
|
+
})
|
|
46
52
|
},
|
|
47
53
|
{
|
|
48
54
|
label: 'Versions',
|
|
49
|
-
url:
|
|
55
|
+
url: formatAdminURL({
|
|
56
|
+
adminRoute,
|
|
57
|
+
path: `/collections/${collectionSlug}/${id}/versions`
|
|
58
|
+
})
|
|
50
59
|
},
|
|
51
60
|
{
|
|
52
61
|
label: doc?.createdAt ? formatDate({
|
|
@@ -61,11 +70,17 @@ export const SetStepNav = ({ id, collectionConfig, collectionSlug, doc, fieldMap
|
|
|
61
70
|
nav = [
|
|
62
71
|
{
|
|
63
72
|
label: globalConfig.label,
|
|
64
|
-
url:
|
|
73
|
+
url: formatAdminURL({
|
|
74
|
+
adminRoute,
|
|
75
|
+
path: `/globals/${globalConfig.slug}`
|
|
76
|
+
})
|
|
65
77
|
},
|
|
66
78
|
{
|
|
67
79
|
label: 'Versions',
|
|
68
|
-
url:
|
|
80
|
+
url: formatAdminURL({
|
|
81
|
+
adminRoute,
|
|
82
|
+
path: `/globals/${globalConfig.slug}/versions`
|
|
83
|
+
})
|
|
69
84
|
},
|
|
70
85
|
{
|
|
71
86
|
label: doc?.createdAt ? formatDate({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/views/Version/Default/SetStepNav.tsx"],"sourcesContent":["import type { StepNavItem } from '@payloadcms/ui'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/views/Version/Default/SetStepNav.tsx"],"sourcesContent":["import type { StepNavItem } from '@payloadcms/ui'\nimport type { ClientCollectionConfig, ClientGlobalConfig, FieldMap } from 'payload'\nimport type React from 'react'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useConfig, useLocale, useStepNav, useTranslation } from '@payloadcms/ui'\nimport { formatAdminURL, formatDate } from '@payloadcms/ui/shared'\nimport { useEffect } from 'react'\n\nexport const SetStepNav: React.FC<{\n collectionConfig?: ClientCollectionConfig\n collectionSlug?: string\n doc: any\n fieldMap: FieldMap\n globalConfig?: ClientGlobalConfig\n globalSlug?: string\n id?: number | string\n}> = ({ id, collectionConfig, collectionSlug, doc, fieldMap, globalConfig, globalSlug }) => {\n const config = useConfig()\n const { setStepNav } = useStepNav()\n const { i18n, t } = useTranslation()\n const locale = useLocale()\n\n useEffect(() => {\n let nav: StepNavItem[] = []\n\n const {\n admin: { dateFormat },\n routes: { admin: adminRoute },\n } = config\n\n if (collectionSlug) {\n let docLabel = ''\n\n const useAsTitle = collectionConfig?.admin?.useAsTitle || 'id'\n const pluralLabel = collectionConfig?.labels?.plural\n const formattedDoc = doc.version ? doc.version : doc\n\n if (formattedDoc) {\n if (useAsTitle !== 'id') {\n const titleField = fieldMap.find((f) => {\n const { isFieldAffectingData } = f\n const fieldName = 'name' in f ? f.name : undefined\n return Boolean(isFieldAffectingData && fieldName === useAsTitle)\n })\n\n if (titleField && formattedDoc[useAsTitle]) {\n if (titleField.localized) {\n docLabel = formattedDoc[useAsTitle]?.[locale.code]\n } else {\n docLabel = formattedDoc[useAsTitle]\n }\n } else {\n docLabel = `[${t('general:untitled')}]`\n }\n } else {\n docLabel = doc.id\n }\n }\n\n nav = [\n {\n label: getTranslation(pluralLabel, i18n),\n url: formatAdminURL({ adminRoute, path: `/collections/${collectionSlug}` }),\n },\n {\n label: docLabel,\n url: formatAdminURL({ adminRoute, path: `/collections/${collectionSlug}/${id}` }),\n },\n {\n label: 'Versions',\n url: formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${id}/versions`,\n }),\n },\n {\n label: doc?.createdAt\n ? formatDate({ date: doc.createdAt, i18n, pattern: dateFormat })\n : '',\n },\n ]\n }\n\n if (globalSlug) {\n nav = [\n {\n label: globalConfig.label,\n url: formatAdminURL({\n adminRoute,\n path: `/globals/${globalConfig.slug}`,\n }),\n },\n {\n label: 'Versions',\n url: formatAdminURL({\n adminRoute,\n path: `/globals/${globalConfig.slug}/versions`,\n }),\n },\n {\n label: doc?.createdAt\n ? formatDate({ date: doc.createdAt, i18n, pattern: dateFormat })\n : '',\n },\n ]\n }\n\n setStepNav(nav)\n }, [\n config,\n setStepNav,\n collectionSlug,\n globalSlug,\n doc,\n id,\n locale,\n t,\n i18n,\n collectionConfig,\n fieldMap,\n globalConfig,\n ])\n\n return null\n}\n"],"names":["getTranslation","useConfig","useLocale","useStepNav","useTranslation","formatAdminURL","formatDate","useEffect","SetStepNav","id","collectionConfig","collectionSlug","doc","fieldMap","globalConfig","globalSlug","config","setStepNav","i18n","t","locale","nav","admin","dateFormat","routes","adminRoute","docLabel","useAsTitle","pluralLabel","labels","plural","formattedDoc","version","titleField","find","f","isFieldAffectingData","fieldName","name","undefined","Boolean","localized","code","label","url","path","createdAt","date","pattern","slug"],"mappings":"AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAAEC,cAAc,QAAQ,iBAAgB;AACjF,SAASC,cAAc,EAAEC,UAAU,QAAQ,wBAAuB;AAClE,SAASC,SAAS,QAAQ,QAAO;AAEjC,OAAO,MAAMC,aAQR,CAAC,EAAEC,EAAE,EAAEC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,EAAElC,eAAe,CAAC;oBAAC;gBAC3E;gBACA;oBACEgC,OAAOjB;oBACPkB,KAAKvC,eAAe;wBAAEoB;wBAAYoB,MAAM,CAAC,aAAa,EAAElC,eAAe,CAAC,EAAEF,GAAG,CAAC;oBAAC;gBACjF;gBACA;oBACEkC,OAAO;oBACPC,KAAKvC,eAAe;wBAClBoB;wBACAoB,MAAM,CAAC,aAAa,EAAElC,eAAe,CAAC,EAAEF,GAAG,SAAS,CAAC;oBACvD;gBACF;gBACA;oBACEkC,OAAO/B,KAAKkC,YACRxC,WAAW;wBAAEyC,MAAMnC,IAAIkC,SAAS;wBAAE5B;wBAAM8B,SAASzB;oBAAW,KAC5D;gBACN;aACD;QACH;QAEA,IAAIR,YAAY;YACdM,MAAM;gBACJ;oBACEsB,OAAO7B,aAAa6B,KAAK;oBACzBC,KAAKvC,eAAe;wBAClBoB;wBACAoB,MAAM,CAAC,SAAS,EAAE/B,aAAamC,IAAI,CAAC,CAAC;oBACvC;gBACF;gBACA;oBACEN,OAAO;oBACPC,KAAKvC,eAAe;wBAClBoB;wBACAoB,MAAM,CAAC,SAAS,EAAE/B,aAAamC,IAAI,CAAC,SAAS,CAAC;oBAChD;gBACF;gBACA;oBACEN,OAAO/B,KAAKkC,YACRxC,WAAW;wBAAEyC,MAAMnC,IAAIkC,SAAS;wBAAE5B;wBAAM8B,SAASzB;oBAAW,KAC5D;gBACN;aACD;QACH;QAEAN,WAAWI;IACb,GAAG;QACDL;QACAC;QACAN;QACAI;QACAH;QACAH;QACAW;QACAD;QACAD;QACAR;QACAG;QACAC;KACD;IAED,OAAO;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/Default/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAiB,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAQzE,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/Default/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAiB,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAQzE,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAgIjE,CAAA"}
|
|
@@ -40,12 +40,13 @@ export const DefaultVersionView = ({ doc, docPermissions, initialComparisonDoc,
|
|
|
40
40
|
initialParams: {
|
|
41
41
|
depth: 1,
|
|
42
42
|
draft: 'true',
|
|
43
|
-
locale: '
|
|
43
|
+
locale: 'all'
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
const comparison = compareValue?.value && currentComparisonDoc?.version // the `version` key is only present on `versions` documents
|
|
47
47
|
;
|
|
48
48
|
const canUpdate = docPermissions?.update?.permission;
|
|
49
|
+
const localeValues = locales.map((locale)=>locale.value);
|
|
49
50
|
return /*#__PURE__*/ _jsxs("main", {
|
|
50
51
|
className: baseClass,
|
|
51
52
|
children: [
|
|
@@ -117,7 +118,7 @@ export const DefaultVersionView = ({ doc, docPermissions, initialComparisonDoc,
|
|
|
117
118
|
fieldMap: fieldMap,
|
|
118
119
|
fieldPermissions: docPermissions?.fields,
|
|
119
120
|
i18n: i18n,
|
|
120
|
-
locales:
|
|
121
|
+
locales: localeValues,
|
|
121
122
|
version: globalConfig ? {
|
|
122
123
|
...doc?.version,
|
|
123
124
|
createdAt: doc?.version?.createdAt || doc.createdAt,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/views/Version/Default/index.tsx"],"sourcesContent":["'use client'\nimport type { OptionObject } from 'payload'\n\nimport {\n Gutter,\n SetViewActions,\n useComponentMap,\n useConfig,\n useDocumentInfo,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport React, { useState } from 'react'\n\nimport type { CompareOption, DefaultVersionsViewProps } from './types.js'\n\nimport diffComponents from '../RenderFieldsToDiff/fields/index.js'\nimport RenderFieldsToDiff from '../RenderFieldsToDiff/index.js'\nimport Restore from '../Restore/index.js'\nimport { SelectComparison } from '../SelectComparison/index.js'\nimport { SelectLocales } from '../SelectLocales/index.js'\nimport { SetStepNav } from './SetStepNav.js'\nimport './index.scss'\n\nconst baseClass = 'view-version'\n\nexport const DefaultVersionView: React.FC<DefaultVersionsViewProps> = ({\n doc,\n docPermissions,\n initialComparisonDoc,\n latestDraftVersion,\n latestPublishedVersion,\n localeOptions,\n versionID,\n}) => {\n const config = useConfig()\n\n const { i18n } = useTranslation()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n\n const { getComponentMap, getFieldMap } = useComponentMap()\n\n const componentMap = getComponentMap({ collectionSlug, globalSlug })\n\n const [fieldMap] = useState(() => getFieldMap({ collectionSlug, globalSlug }))\n\n const [collectionConfig] = useState(() =>\n config.collections.find((collection) => collection.slug === collectionSlug),\n )\n\n const [globalConfig] = useState(() => config.globals.find((global) => global.slug === globalSlug))\n\n const [locales, setLocales] = useState<OptionObject[]>(localeOptions)\n\n const [compareValue, setCompareValue] = useState<CompareOption>()\n\n const {\n admin: { dateFormat },\n localization,\n routes: { api: apiRoute },\n serverURL,\n } = config\n\n const versionCreatedAt = doc?.updatedAt\n ? formatDate({ date: doc.updatedAt, i18n, pattern: dateFormat })\n : ''\n\n const compareBaseURL = `${serverURL}${apiRoute}/${globalSlug ? 'globals/' : ''}${\n collectionSlug || globalSlug\n }/versions`\n\n const compareFetchURL = compareValue?.value && `${compareBaseURL}/${compareValue.value}`\n\n const [{ data: currentComparisonDoc }] = usePayloadAPI(compareFetchURL, {\n initialData: initialComparisonDoc,\n initialParams: { depth: 1, draft: 'true', locale: '
|
|
1
|
+
{"version":3,"sources":["../../../../src/views/Version/Default/index.tsx"],"sourcesContent":["'use client'\nimport type { OptionObject } from 'payload'\n\nimport {\n Gutter,\n SetViewActions,\n useComponentMap,\n useConfig,\n useDocumentInfo,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport React, { useState } from 'react'\n\nimport type { CompareOption, DefaultVersionsViewProps } from './types.js'\n\nimport diffComponents from '../RenderFieldsToDiff/fields/index.js'\nimport RenderFieldsToDiff from '../RenderFieldsToDiff/index.js'\nimport Restore from '../Restore/index.js'\nimport { SelectComparison } from '../SelectComparison/index.js'\nimport { SelectLocales } from '../SelectLocales/index.js'\nimport { SetStepNav } from './SetStepNav.js'\nimport './index.scss'\n\nconst baseClass = 'view-version'\n\nexport const DefaultVersionView: React.FC<DefaultVersionsViewProps> = ({\n doc,\n docPermissions,\n initialComparisonDoc,\n latestDraftVersion,\n latestPublishedVersion,\n localeOptions,\n versionID,\n}) => {\n const config = useConfig()\n\n const { i18n } = useTranslation()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n\n const { getComponentMap, getFieldMap } = useComponentMap()\n\n const componentMap = getComponentMap({ collectionSlug, globalSlug })\n\n const [fieldMap] = useState(() => getFieldMap({ collectionSlug, globalSlug }))\n\n const [collectionConfig] = useState(() =>\n config.collections.find((collection) => collection.slug === collectionSlug),\n )\n\n const [globalConfig] = useState(() => config.globals.find((global) => global.slug === globalSlug))\n\n const [locales, setLocales] = useState<OptionObject[]>(localeOptions)\n\n const [compareValue, setCompareValue] = useState<CompareOption>()\n\n const {\n admin: { dateFormat },\n localization,\n routes: { api: apiRoute },\n serverURL,\n } = config\n\n const versionCreatedAt = doc?.updatedAt\n ? formatDate({ date: doc.updatedAt, i18n, pattern: dateFormat })\n : ''\n\n const compareBaseURL = `${serverURL}${apiRoute}/${globalSlug ? 'globals/' : ''}${\n collectionSlug || globalSlug\n }/versions`\n\n const compareFetchURL = compareValue?.value && `${compareBaseURL}/${compareValue.value}`\n\n const [{ data: currentComparisonDoc }] = usePayloadAPI(compareFetchURL, {\n initialData: initialComparisonDoc,\n initialParams: { depth: 1, draft: 'true', locale: 'all' },\n })\n\n const comparison = compareValue?.value && currentComparisonDoc?.version // the `version` key is only present on `versions` documents\n\n const canUpdate = docPermissions?.update?.permission\n\n const localeValues = locales.map((locale) => locale.value)\n\n return (\n <main className={baseClass}>\n <SetViewActions actions={componentMap?.actionsMap?.Edit?.Version} />\n <SetStepNav\n collectionConfig={collectionConfig}\n collectionSlug={collectionSlug}\n doc={doc}\n fieldMap={fieldMap}\n globalConfig={globalConfig}\n globalSlug={globalSlug}\n id={id}\n />\n <Gutter className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header-wrap`}>\n <p className={`${baseClass}__created-at`}>\n {i18n.t('version:versionCreatedOn', {\n version: i18n.t(doc?.autosave ? 'version:autosavedVersion' : 'version:version'),\n })}\n </p>\n <header className={`${baseClass}__header`}>\n <h2>{versionCreatedAt}</h2>\n {canUpdate && (\n <Restore\n className={`${baseClass}__restore`}\n collectionSlug={collectionSlug}\n globalSlug={globalSlug}\n label={collectionConfig?.labels.singular || globalConfig?.label}\n originalDocID={id}\n versionDate={versionCreatedAt}\n versionID={versionID}\n />\n )}\n </header>\n </div>\n <div className={`${baseClass}__controls`}>\n <SelectComparison\n baseURL={compareBaseURL}\n latestDraftVersion={latestDraftVersion}\n latestPublishedVersion={latestPublishedVersion}\n onChange={setCompareValue}\n parentID={id}\n value={compareValue}\n versionID={versionID}\n />\n {localization && (\n <SelectLocales onChange={setLocales} options={localeOptions} value={locales} />\n )}\n </div>\n {doc?.version && (\n <RenderFieldsToDiff\n comparison={comparison}\n diffComponents={diffComponents}\n fieldMap={fieldMap}\n fieldPermissions={docPermissions?.fields}\n i18n={i18n}\n locales={localeValues}\n version={\n globalConfig\n ? {\n ...doc?.version,\n createdAt: doc?.version?.createdAt || doc.createdAt,\n updatedAt: doc?.version?.updatedAt || doc.updatedAt,\n }\n : doc?.version\n }\n />\n )}\n </Gutter>\n </main>\n )\n}\n"],"names":["Gutter","SetViewActions","useComponentMap","useConfig","useDocumentInfo","usePayloadAPI","useTranslation","formatDate","React","useState","diffComponents","RenderFieldsToDiff","Restore","SelectComparison","SelectLocales","SetStepNav","baseClass","DefaultVersionView","doc","docPermissions","initialComparisonDoc","latestDraftVersion","latestPublishedVersion","localeOptions","versionID","config","i18n","id","collectionSlug","globalSlug","getComponentMap","getFieldMap","componentMap","fieldMap","collectionConfig","collections","find","collection","slug","globalConfig","globals","global","locales","setLocales","compareValue","setCompareValue","admin","dateFormat","localization","routes","api","apiRoute","serverURL","versionCreatedAt","updatedAt","date","pattern","compareBaseURL","compareFetchURL","value","data","currentComparisonDoc","initialData","initialParams","depth","draft","locale","comparison","version","canUpdate","update","permission","localeValues","map","main","className","actions","actionsMap","Edit","Version","div","p","t","autosave","header","h2","label","labels","singular","originalDocID","versionDate","baseURL","onChange","parentID","options","fieldPermissions","fields","createdAt"],"mappings":"AAAA;;AAGA,SACEA,MAAM,EACNC,cAAc,EACdC,eAAe,EACfC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,SAASC,UAAU,QAAQ,wBAAuB;AAClD,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAIvC,OAAOC,oBAAoB,wCAAuC;AAClE,OAAOC,wBAAwB,iCAAgC;AAC/D,OAAOC,aAAa,sBAAqB;AACzC,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,UAAU,QAAQ,kBAAiB;AAG5C,MAAMC,YAAY;AAElB,OAAO,MAAMC,qBAAyD,CAAC,EACrEC,GAAG,EACHC,cAAc,EACdC,oBAAoB,EACpBC,kBAAkB,EAClBC,sBAAsB,EACtBC,aAAa,EACbC,SAAS,EACV;IACC,MAAMC,SAAStB;IAEf,MAAM,EAAEuB,IAAI,EAAE,GAAGpB;IACjB,MAAM,EA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D;wBACCwD,YAAYA;wBACZzD,gBAAgBA;wBAChBuB,UAAUA;wBACV8D,kBAAkB5E,gBAAgB6E;wBAClCtE,MAAMA;wBACNgB,SAAS8B;wBACTJ,SACE7B,eACI;4BACE,GAAGrB,KAAKkD,OAAO;4BACf6B,WAAW/E,KAAKkD,SAAS6B,aAAa/E,IAAI+E,SAAS;4BACnD3C,WAAWpC,KAAKkD,SAASd,aAAapC,IAAIoC,SAAS;wBACrD,IACApC,KAAKkD;;;;;;AAOvB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/views/Version/RenderFieldsToDiff/fields/Iterable/index.tsx"],"sourcesContent":["import type { MappedField } from '
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/views/Version/RenderFieldsToDiff/fields/Iterable/index.tsx"],"sourcesContent":["import type { MappedField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getUniqueListBy } from 'payload/shared'\nimport React from 'react'\n\nimport type { Props } from '../types.js'\n\nimport Label from '../../Label/index.js'\nimport RenderFieldsToDiff from '../../index.js'\nimport './index.scss'\n\nconst baseClass = 'iterable-diff'\n\nconst Iterable: React.FC<Props> = ({\n comparison,\n diffComponents,\n field,\n i18n,\n locale,\n locales,\n permissions,\n version,\n}) => {\n const versionRowCount = Array.isArray(version) ? version.length : 0\n const comparisonRowCount = Array.isArray(comparison) ? comparison.length : 0\n const maxRows = Math.max(versionRowCount, comparisonRowCount)\n\n return (\n <div className={baseClass}>\n {'label' in field.fieldComponentProps &&\n field.fieldComponentProps.label &&\n typeof field.fieldComponentProps.label !== 'function' && (\n <Label>\n {locale && <span className={`${baseClass}__locale-label`}>{locale}</span>}\n {getTranslation(field.fieldComponentProps.label, i18n)}\n </Label>\n )}\n {maxRows > 0 && (\n <React.Fragment>\n {Array.from(Array(maxRows).keys()).map((row, i) => {\n const versionRow = version?.[i] || {}\n const comparisonRow = comparison?.[i] || {}\n\n let fieldMap: MappedField[] = []\n\n if (field.type === 'array' && 'fieldMap' in field.fieldComponentProps)\n fieldMap = field.fieldComponentProps.fieldMap\n\n if (field.type === 'blocks') {\n fieldMap = [\n // {\n // name: 'blockType',\n // label: i18n.t('fields:blockType'),\n // type: 'text',\n // },\n ]\n\n if (versionRow?.blockType === comparisonRow?.blockType) {\n const matchedBlock = ('blocks' in field.fieldComponentProps &&\n field.fieldComponentProps.blocks?.find(\n (block) => block.slug === versionRow?.blockType,\n )) || {\n fieldMap: [],\n }\n\n fieldMap = [...fieldMap, ...matchedBlock.fieldMap]\n } else {\n const matchedVersionBlock = ('blocks' in field.fieldComponentProps &&\n field.fieldComponentProps.blocks?.find(\n (block) => block.slug === versionRow?.blockType,\n )) || {\n fieldMap: [],\n }\n\n const matchedComparisonBlock = ('blocks' in field.fieldComponentProps &&\n field.fieldComponentProps.blocks?.find(\n (block) => block.slug === comparisonRow?.blockType,\n )) || {\n fieldMap: [],\n }\n\n fieldMap = getUniqueListBy<MappedField>(\n [\n ...fieldMap,\n ...matchedVersionBlock.fieldMap,\n ...matchedComparisonBlock.fieldMap,\n ],\n 'name',\n )\n }\n }\n\n return (\n <div className={`${baseClass}__wrap`} key={i}>\n <RenderFieldsToDiff\n comparison={comparisonRow}\n diffComponents={diffComponents}\n fieldMap={fieldMap}\n fieldPermissions={permissions}\n i18n={i18n}\n locales={locales}\n version={versionRow}\n />\n </div>\n )\n })}\n </React.Fragment>\n )}\n {maxRows === 0 && (\n <div className={`${baseClass}__no-rows`}>\n {i18n.t('version:noRowsFound', {\n label:\n 'labels' in field.fieldComponentProps && field.fieldComponentProps.labels?.plural\n ? getTranslation(field.fieldComponentProps.labels.plural, i18n)\n : i18n.t('general:rows'),\n })}\n </div>\n )}\n </div>\n )\n}\n\nexport default Iterable\n"],"names":["getTranslation","getUniqueListBy","React","Label","RenderFieldsToDiff","baseClass","Iterable","comparison","diffComponents","field","i18n","locale","locales","permissions","version","versionRowCount","Array","isArray","length","comparisonRowCount","maxRows","Math","max","div","className","fieldComponentProps","label","span","Fragment","from","keys","map","row","i","versionRow","comparisonRow","fieldMap","type","blockType","matchedBlock","blocks","find","block","slug","matchedVersionBlock","matchedComparisonBlock","fieldPermissions","t","labels","plural"],"mappings":";AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,eAAe,QAAQ,iBAAgB;AAChD,OAAOC,WAAW,QAAO;AAIzB,OAAOC,WAAW,uBAAsB;AACxC,OAAOC,wBAAwB,iBAAgB;AAG/C,MAAMC,YAAY;AAElB,MAAMC,WAA4B,CAAC,EACjCC,UAAU,EACVC,cAAc,EACdC,KAAK,EACLC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,WAAW,EACXC,OAAO,EACR;IACC,MAAMC,kBAAkBC,MAAMC,OAAO,CAACH,WAAWA,QAAQI,MAAM,GAAG;IAClE,MAAMC,qBAAqBH,MAAMC,OAAO,CAACV,cAAcA,WAAWW,MAAM,GAAG;IAC3E,MAAME,UAAUC,KAAKC,GAAG,CAACP,iBAAiBI;IAE1C,qBACE,MAACI;QAAIC,WAAWnB;;YACb,WAAWI,MAAMgB,mBAAmB,IACnChB,MAAMgB,mBAAmB,CAACC,KAAK,IAC/B,OAAOjB,MAAMgB,mBAAmB,CAACC,KAAK,KAAK,4BACzC,MAACvB;;oBACEQ,wBAAU,KAACgB;wBAAKH,WAAW,CAAC,EAAEnB,UAAU,cAAc,CAAC;kCAAGM;;oBAC1DX,eAAeS,MAAMgB,mBAAmB,CAACC,KAAK,EAAEhB;;;YAGtDU,UAAU,mBACT,KAAClB,MAAM0B,QAAQ;0BACZZ,MAAMa,IAAI,CAACb,MAAMI,SAASU,IAAI,IAAIC,GAAG,CAAC,CAACC,KAAKC;oBAC3C,MAAMC,aAAapB,SAAS,CAACmB,EAAE,IAAI,CAAC;oBACpC,MAAME,gBAAgB5B,YAAY,CAAC0B,EAAE,IAAI,CAAC;oBAE1C,IAAIG,WAA0B,EAAE;oBAEhC,IAAI3B,MAAM4B,IAAI,KAAK,WAAW,cA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