@payloadcms/next 3.89.0 → 3.90.1

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.
Files changed (82) hide show
  1. package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts +2 -1
  2. package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +1 -1
  3. package/dist/elements/DocumentHeader/Tabs/Tab/index.js +3 -2
  4. package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
  5. package/dist/elements/DocumentHeader/Tabs/index.d.ts +2 -1
  6. package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +1 -1
  7. package/dist/elements/DocumentHeader/Tabs/index.js +5 -3
  8. package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
  9. package/dist/elements/DocumentHeader/index.d.ts +2 -1
  10. package/dist/elements/DocumentHeader/index.d.ts.map +1 -1
  11. package/dist/elements/DocumentHeader/index.js +4 -2
  12. package/dist/elements/DocumentHeader/index.js.map +1 -1
  13. package/dist/layouts/Root/index.js +6 -5
  14. package/dist/layouts/Root/index.js.map +1 -1
  15. package/dist/prod/styles.css +1 -1
  16. package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
  17. package/dist/utilities/handleServerFunctions.js +4 -2
  18. package/dist/utilities/handleServerFunctions.js.map +1 -1
  19. package/dist/utilities/initReq.d.ts.map +1 -1
  20. package/dist/utilities/initReq.js +35 -2
  21. package/dist/utilities/initReq.js.map +1 -1
  22. package/dist/utilities/initReq.spec.js +240 -0
  23. package/dist/utilities/initReq.spec.js.map +1 -0
  24. package/dist/utilities/isPublicAdminRoute.d.ts.map +1 -1
  25. package/dist/utilities/isPublicAdminRoute.js +11 -9
  26. package/dist/utilities/isPublicAdminRoute.js.map +1 -1
  27. package/dist/utilities/isPublicAdminRoute.spec.js +34 -0
  28. package/dist/utilities/isPublicAdminRoute.spec.js.map +1 -0
  29. package/dist/views/Account/index.d.ts +1 -1
  30. package/dist/views/Account/index.d.ts.map +1 -1
  31. package/dist/views/Account/index.js +10 -7
  32. package/dist/views/Account/index.js.map +1 -1
  33. package/dist/views/BrowseByFolder/buildView.js +4 -4
  34. package/dist/views/BrowseByFolder/buildView.js.map +1 -1
  35. package/dist/views/CollectionFolders/buildView.js +4 -4
  36. package/dist/views/CollectionFolders/buildView.js.map +1 -1
  37. package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
  38. package/dist/views/Dashboard/Default/ModularDashboard/index.js +1 -0
  39. package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
  40. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
  41. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +3 -1
  42. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
  43. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
  44. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +2 -0
  45. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
  46. package/dist/views/Dashboard/index.js +5 -3
  47. package/dist/views/Dashboard/index.js.map +1 -1
  48. package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
  49. package/dist/views/Document/handleServerFunction.js +2 -0
  50. package/dist/views/Document/handleServerFunction.js.map +1 -1
  51. package/dist/views/Document/index.d.ts +1 -1
  52. package/dist/views/Document/index.d.ts.map +1 -1
  53. package/dist/views/Document/index.js +9 -4
  54. package/dist/views/Document/index.js.map +1 -1
  55. package/dist/views/Document/renderDocumentSlots.d.ts +1 -0
  56. package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
  57. package/dist/views/Document/renderDocumentSlots.js +7 -4
  58. package/dist/views/Document/renderDocumentSlots.js.map +1 -1
  59. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts +1 -0
  60. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
  61. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +212 -159
  62. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
  63. package/dist/views/ForgotPassword/index.d.ts.map +1 -1
  64. package/dist/views/ForgotPassword/index.js +3 -11
  65. package/dist/views/ForgotPassword/index.js.map +1 -1
  66. package/dist/views/List/handleServerFunction.d.ts.map +1 -1
  67. package/dist/views/List/handleServerFunction.js +4 -2
  68. package/dist/views/List/handleServerFunction.js.map +1 -1
  69. package/dist/views/List/index.d.ts.map +1 -1
  70. package/dist/views/List/index.js +2 -1
  71. package/dist/views/List/index.js.map +1 -1
  72. package/dist/views/NotFound/index.d.ts.map +1 -1
  73. package/dist/views/NotFound/index.js +3 -2
  74. package/dist/views/NotFound/index.js.map +1 -1
  75. package/dist/views/Root/index.d.ts.map +1 -1
  76. package/dist/views/Root/index.js +6 -4
  77. package/dist/views/Root/index.js.map +1 -1
  78. package/dist/views/Verify/index.d.ts +1 -1
  79. package/dist/views/Verify/index.d.ts.map +1 -1
  80. package/dist/views/Verify/index.js +4 -4
  81. package/dist/views/Verify/index.js.map +1 -1
  82. package/package.json +8 -8
@@ -1,182 +1,235 @@
1
1
  'use client';
2
2
 
3
- import { c as _c } from "react/compiler-runtime";
4
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- import { EmailField, Form, FormSubmit, TextField, useConfig, useTranslation } from '@payloadcms/ui';
3
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
+ import { Button, EmailField, Form, FormSubmit, Link, TextField, useConfig, useTranslation } from '@payloadcms/ui';
6
5
  import { email, formatAdminURL, text } from 'payload/shared';
7
- import React, { useState } from 'react';
6
+ import React, { useEffect, useRef, useState } from 'react';
8
7
  import { FormHeader } from '../../../elements/FormHeader/index.js';
8
+ const baseClass = 'forgot-password__form';
9
+ const formatResendDelay = seconds => `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`;
10
+ const removeStoredRequest = sessionStorageKey => {
11
+ try {
12
+ window.sessionStorage.removeItem(sessionStorageKey);
13
+ } catch {
14
+ return;
15
+ }
16
+ };
17
+ const saveStoredRequest = ({
18
+ request,
19
+ sessionStorageKey
20
+ }) => {
21
+ try {
22
+ window.sessionStorage.setItem(sessionStorageKey, JSON.stringify(request));
23
+ } catch {
24
+ return;
25
+ }
26
+ };
9
27
  export const ForgotPasswordForm = () => {
10
- const $ = _c(17);
11
28
  const {
12
29
  config,
13
30
  getEntityConfig
14
31
  } = useConfig();
15
32
  const {
16
- admin: t0,
17
- routes: t1
33
+ admin: {
34
+ routes: {
35
+ login: loginRoute
36
+ },
37
+ user: userSlug
38
+ },
39
+ routes: {
40
+ admin: adminRoute,
41
+ api: apiRoute
42
+ }
18
43
  } = config;
19
- const {
20
- user: userSlug
21
- } = t0;
22
- const {
23
- api: apiRoute
24
- } = t1;
25
44
  const {
26
45
  t
27
46
  } = useTranslation();
28
47
  const [hasSubmitted, setHasSubmitted] = useState(false);
29
- let t2;
30
- if ($[0] !== getEntityConfig || $[1] !== userSlug) {
31
- t2 = getEntityConfig({
32
- collectionSlug: userSlug
33
- });
34
- $[0] = getEntityConfig;
35
- $[1] = userSlug;
36
- $[2] = t2;
37
- } else {
38
- t2 = $[2];
39
- }
40
- const collectionConfig = t2;
48
+ const [resendDelay, setResendDelay] = useState(0);
49
+ const [storedRequest, setStoredRequest] = useState(null);
50
+ const resendAvailableAt = useRef(0);
51
+ const submittedIdentifier = useRef(null);
52
+ const collectionConfig = getEntityConfig({
53
+ collectionSlug: userSlug
54
+ });
41
55
  const loginWithUsername = collectionConfig?.auth?.loginWithUsername;
42
- let t3;
43
- if ($[3] !== loginWithUsername || $[4] !== t) {
44
- t3 = (res, successToast, errorToast) => {
45
- res.json().then(() => {
46
- setHasSubmitted(true);
47
- successToast(t("general:submissionSuccessful"));
48
- }).catch(() => {
49
- errorToast(loginWithUsername ? t("authentication:usernameNotValid") : t("authentication:emailNotValid"));
50
- });
51
- };
52
- $[3] = loginWithUsername;
53
- $[4] = t;
54
- $[5] = t3;
55
- } else {
56
- t3 = $[5];
57
- }
58
- const handleResponse = t3;
59
- let t4;
60
- let t5;
61
- if ($[6] !== apiRoute || $[7] !== config || $[8] !== handleResponse || $[9] !== hasSubmitted || $[10] !== loginWithUsername || $[11] !== t || $[12] !== userSlug) {
62
- t5 = Symbol.for("react.early_return_sentinel");
63
- bb0: {
64
- const initialState = loginWithUsername ? {
65
- username: {
66
- initialValue: "",
67
- valid: true,
68
- value: undefined
69
- }
70
- } : {
71
- email: {
72
- initialValue: "",
73
- valid: true,
74
- value: undefined
75
- }
76
- };
77
- if (hasSubmitted) {
78
- let t6;
79
- if ($[15] !== t) {
80
- t6 = _jsx(FormHeader, {
81
- description: t("authentication:checkYourEmailForPasswordReset"),
82
- heading: t("authentication:emailSent")
83
- });
84
- $[15] = t;
85
- $[16] = t6;
86
- } else {
87
- t6 = $[16];
88
- }
89
- t5 = t6;
90
- break bb0;
56
+ const minRequestInterval = collectionConfig?.auth?.forgotPassword?.minRequestInterval ?? 15000;
57
+ const sessionStorageKey = `payload-forgot-password:${userSlug}`;
58
+ useEffect(() => {
59
+ try {
60
+ const storedValue = window.sessionStorage.getItem(sessionStorageKey);
61
+ if (!storedValue) {
62
+ return;
91
63
  }
92
- t4 = _jsxs(Form, {
93
- action: formatAdminURL({
94
- apiRoute,
95
- path: `/${userSlug}/forgot-password`
96
- }),
97
- handleResponse,
98
- initialState,
99
- method: "POST",
100
- children: [_jsx(FormHeader, {
101
- description: loginWithUsername ? t("authentication:forgotPasswordUsernameInstructions") : t("authentication:forgotPasswordEmailInstructions"),
102
- heading: t("authentication:forgotPassword")
103
- }), loginWithUsername ? _jsx(TextField, {
104
- field: {
105
- name: "username",
106
- label: t("authentication:username"),
107
- required: true
64
+ const parsedValue = JSON.parse(storedValue);
65
+ if (typeof parsedValue.identifier !== 'string' || typeof parsedValue.resendAvailableAt !== 'number' || parsedValue.resendAvailableAt <= Date.now()) {
66
+ removeStoredRequest(sessionStorageKey);
67
+ return;
68
+ }
69
+ submittedIdentifier.current = parsedValue.identifier;
70
+ resendAvailableAt.current = parsedValue.resendAvailableAt;
71
+ setStoredRequest(parsedValue);
72
+ setResendDelay(Math.max(0, Math.ceil((parsedValue.resendAvailableAt - Date.now()) / 1000)));
73
+ setHasSubmitted(true);
74
+ } catch {
75
+ removeStoredRequest(sessionStorageKey);
76
+ }
77
+ }, [sessionStorageKey]);
78
+ useEffect(() => {
79
+ if (resendDelay === 0) {
80
+ return;
81
+ }
82
+ const timeout = setTimeout(() => {
83
+ setResendDelay(Math.max(0, Math.ceil((resendAvailableAt.current - Date.now()) / 1000)));
84
+ }, 1050);
85
+ return () => clearTimeout(timeout);
86
+ }, [resendDelay]);
87
+ const handleResponse = (res, successToast, errorToast) => {
88
+ res.json().then(() => {
89
+ const nextResendAvailableAt = Date.now() + minRequestInterval;
90
+ const nextStoredRequest = submittedIdentifier.current ? {
91
+ identifier: submittedIdentifier.current,
92
+ resendAvailableAt: nextResendAvailableAt
93
+ } : null;
94
+ resendAvailableAt.current = nextResendAvailableAt;
95
+ setResendDelay(Math.ceil(minRequestInterval / 1000));
96
+ setStoredRequest(nextStoredRequest);
97
+ setHasSubmitted(true);
98
+ if (nextStoredRequest) {
99
+ saveStoredRequest({
100
+ request: nextStoredRequest,
101
+ sessionStorageKey
102
+ });
103
+ }
104
+ successToast(t('general:submissionSuccessful'));
105
+ }).catch(() => {
106
+ errorToast(loginWithUsername ? t('authentication:usernameNotValid') : t('authentication:emailNotValid'));
107
+ });
108
+ };
109
+ const initialState = loginWithUsername ? {
110
+ username: {
111
+ initialValue: storedRequest?.identifier ?? '',
112
+ valid: true,
113
+ value: storedRequest?.identifier
114
+ }
115
+ } : {
116
+ email: {
117
+ initialValue: storedRequest?.identifier ?? '',
118
+ valid: true,
119
+ value: storedRequest?.identifier
120
+ }
121
+ };
122
+ return /*#__PURE__*/_jsx(Form, {
123
+ action: formatAdminURL({
124
+ apiRoute,
125
+ path: `/${userSlug}/forgot-password`
126
+ }),
127
+ className: baseClass,
128
+ handleResponse: handleResponse,
129
+ initialState: initialState,
130
+ method: "POST",
131
+ onSubmit: (_, data) => {
132
+ const identifier = loginWithUsername ? data.username : data.email;
133
+ submittedIdentifier.current = typeof identifier === 'string' ? identifier : null;
134
+ },
135
+ children: hasSubmitted ? /*#__PURE__*/_jsxs(_Fragment, {
136
+ children: [/*#__PURE__*/_jsx(FormHeader, {
137
+ description: t('authentication:checkYourEmailForPasswordReset'),
138
+ heading: t('authentication:emailSent')
139
+ }), /*#__PURE__*/_jsxs("div", {
140
+ className: `${baseClass}__actions`,
141
+ children: [/*#__PURE__*/_jsx(Button, {
142
+ buttonStyle: "primary",
143
+ className: `${baseClass}__submit`,
144
+ disabled: resendDelay > 0,
145
+ extraButtonProps: {
146
+ style: {
147
+ marginBlockStart: 0
148
+ }
108
149
  },
109
- path: "username",
110
- validate: value => text(value, {
111
- name: "username",
112
- type: "text",
113
- blockData: {},
114
- data: {},
115
- event: "onChange",
116
- path: ["username"],
117
- preferences: {
118
- fields: {}
119
- },
120
- req: {
121
- payload: {
122
- config
123
- },
124
- t
125
- },
126
- required: true,
127
- siblingData: {}
128
- })
129
- }) : _jsx(EmailField, {
130
- field: {
131
- name: "email",
132
- admin: {
133
- autoComplete: "email"
134
- },
135
- label: t("general:email"),
136
- required: true
150
+ size: "large",
151
+ type: "submit",
152
+ children: resendDelay > 0 ? `${t('authentication:resend')} (${formatResendDelay(resendDelay)})` : t('authentication:resend')
153
+ }), /*#__PURE__*/_jsx(Link, {
154
+ href: formatAdminURL({
155
+ adminRoute,
156
+ path: loginRoute
157
+ }),
158
+ prefetch: false,
159
+ children: t('authentication:backToLogin')
160
+ })]
161
+ })]
162
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
163
+ children: [/*#__PURE__*/_jsx(FormHeader, {
164
+ description: loginWithUsername ? t('authentication:forgotPasswordUsernameInstructions') : t('authentication:forgotPasswordEmailInstructions'),
165
+ heading: t('authentication:forgotPassword')
166
+ }), loginWithUsername ? /*#__PURE__*/_jsx(TextField, {
167
+ field: {
168
+ name: 'username',
169
+ label: t('authentication:username'),
170
+ required: true
171
+ },
172
+ path: "username",
173
+ validate: value => text(value, {
174
+ name: 'username',
175
+ type: 'text',
176
+ blockData: {},
177
+ data: {},
178
+ event: 'onChange',
179
+ path: ['username'],
180
+ preferences: {
181
+ fields: {}
137
182
  },
138
- path: "email",
139
- validate: value_0 => email(value_0, {
140
- name: "email",
141
- type: "email",
142
- blockData: {},
143
- data: {},
144
- event: "onChange",
145
- path: ["email"],
146
- preferences: {
147
- fields: {}
183
+ req: {
184
+ payload: {
185
+ config
148
186
  },
149
- req: {
150
- payload: {
151
- config
152
- },
153
- t
187
+ t
188
+ },
189
+ required: true,
190
+ siblingData: {}
191
+ })
192
+ }) : /*#__PURE__*/_jsx(EmailField, {
193
+ field: {
194
+ name: 'email',
195
+ admin: {
196
+ autoComplete: 'email'
197
+ },
198
+ label: t('general:email'),
199
+ required: true
200
+ },
201
+ path: "email",
202
+ validate: value_0 => email(value_0, {
203
+ name: 'email',
204
+ type: 'email',
205
+ blockData: {},
206
+ data: {},
207
+ event: 'onChange',
208
+ path: ['email'],
209
+ preferences: {
210
+ fields: {}
211
+ },
212
+ req: {
213
+ payload: {
214
+ config
154
215
  },
155
- required: true,
156
- siblingData: {}
157
- })
158
- }), _jsx(FormSubmit, {
159
- size: "large",
160
- children: t("general:submit")
161
- })]
162
- });
163
- }
164
- $[6] = apiRoute;
165
- $[7] = config;
166
- $[8] = handleResponse;
167
- $[9] = hasSubmitted;
168
- $[10] = loginWithUsername;
169
- $[11] = t;
170
- $[12] = userSlug;
171
- $[13] = t4;
172
- $[14] = t5;
173
- } else {
174
- t4 = $[13];
175
- t5 = $[14];
176
- }
177
- if (t5 !== Symbol.for("react.early_return_sentinel")) {
178
- return t5;
179
- }
180
- return t4;
216
+ t
217
+ },
218
+ required: true,
219
+ siblingData: {}
220
+ })
221
+ }), /*#__PURE__*/_jsx(FormSubmit, {
222
+ size: "large",
223
+ children: t('general:submit')
224
+ }), /*#__PURE__*/_jsx(Link, {
225
+ href: formatAdminURL({
226
+ adminRoute,
227
+ path: loginRoute
228
+ }),
229
+ prefetch: false,
230
+ children: t('authentication:backToLogin')
231
+ })]
232
+ })
233
+ }, `${hasSubmitted ? 'submitted' : 'editing'}:${storedRequest?.identifier ?? ''}`);
181
234
  };
182
235
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","EmailField","Form","FormSubmit","TextField","useConfig","useTranslation","email","formatAdminURL","text","React","useState","FormHeader","ForgotPasswordForm","$","config","getEntityConfig","admin","t0","routes","t1","user","userSlug","api","apiRoute","t","hasSubmitted","setHasSubmitted","t2","collectionSlug","collectionConfig","loginWithUsername","auth","t3","res","successToast","errorToast","json","then","catch","handleResponse","t4","t5","Symbol","for","initialState","username","initialValue","valid","value","undefined","t6","_jsx","description","heading","_jsxs","action","path","method","children","field","name","label","required","validate","type","blockData","data","event","preferences","fields","req","payload","siblingData","autoComplete","value_0","size"],"sources":["../../../../src/views/ForgotPassword/ForgotPasswordForm/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\nimport type { FormState, PayloadRequest } from 'payload'\n\nimport { EmailField, Form, FormSubmit, TextField, useConfig, useTranslation } from '@payloadcms/ui'\nimport { email, formatAdminURL, text } from 'payload/shared'\nimport React, { useState } from 'react'\n\nimport { FormHeader } from '../../../elements/FormHeader/index.js'\n\nexport const ForgotPasswordForm: React.FC = () => {\n const { config, getEntityConfig } = useConfig()\n\n const {\n admin: { user: userSlug },\n routes: { api: apiRoute },\n } = config\n\n const { t } = useTranslation()\n const [hasSubmitted, setHasSubmitted] = useState(false)\n const collectionConfig = getEntityConfig({ collectionSlug: userSlug })\n const loginWithUsername = collectionConfig?.auth?.loginWithUsername\n\n const handleResponse: FormProps['handleResponse'] = (res, successToast, errorToast) => {\n res\n .json()\n .then(() => {\n setHasSubmitted(true)\n successToast(t('general:submissionSuccessful'))\n })\n .catch(() => {\n errorToast(\n loginWithUsername\n ? t('authentication:usernameNotValid')\n : t('authentication:emailNotValid'),\n )\n })\n }\n\n const initialState: FormState = loginWithUsername\n ? {\n username: {\n initialValue: '',\n valid: true,\n value: undefined,\n },\n }\n : {\n email: {\n initialValue: '',\n valid: true,\n value: undefined,\n },\n }\n\n if (hasSubmitted) {\n return (\n <FormHeader\n description={t('authentication:checkYourEmailForPasswordReset')}\n heading={t('authentication:emailSent')}\n />\n )\n }\n\n return (\n <Form\n action={formatAdminURL({\n apiRoute,\n path: `/${userSlug}/forgot-password`,\n })}\n handleResponse={handleResponse}\n initialState={initialState}\n method=\"POST\"\n >\n <FormHeader\n description={\n loginWithUsername\n ? t('authentication:forgotPasswordUsernameInstructions')\n : t('authentication:forgotPasswordEmailInstructions')\n }\n heading={t('authentication:forgotPassword')}\n />\n\n {loginWithUsername ? (\n <TextField\n field={{\n name: 'username',\n label: t('authentication:username'),\n required: true,\n }}\n path=\"username\"\n validate={(value) =>\n text(value, {\n name: 'username',\n type: 'text',\n blockData: {},\n data: {},\n event: 'onChange',\n path: ['username'],\n preferences: { fields: {} },\n req: {\n payload: {\n config,\n },\n t,\n } as unknown as PayloadRequest,\n required: true,\n siblingData: {},\n })\n }\n />\n ) : (\n <EmailField\n field={{\n name: 'email',\n admin: {\n autoComplete: 'email',\n },\n label: t('general:email'),\n required: true,\n }}\n path=\"email\"\n validate={(value) =>\n email(value, {\n name: 'email',\n type: 'email',\n blockData: {},\n data: {},\n event: 'onChange',\n path: ['email'],\n preferences: { fields: {} },\n req: { payload: { config }, t } as unknown as PayloadRequest,\n required: true,\n siblingData: {},\n })\n }\n />\n )}\n <FormSubmit size=\"large\">{t('general:submit')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,C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FA,CAAA,CAAE;UAAA6B,OAAA,EAEC7B,CAAA,CAAE;QAAA,C,GAGZM,iBAAA,GACCqB,IAAA,CAAAhD,SAAA;UAAAwD,KAAA;YAAAC,IAAA,EAEU;YAAAC,KAAA,EACCrC,CAAA,CAAE;YAAAsC,QAAA;UAAA;UAAAN,IAAA,EAGN;UAAAO,QAAA,EAAAf,KAAA,IAEHxC,IAAA,CAAKwC,KAAA;YAAAY,IAAA,EACG;YAAAI,IAAA,EACA;YAAAC,SAAA;YAAAC,IAAA;YAAAC,KAAA,EAGC;YAAAX,IAAA,GACA;YAAAY,WAAA;cAAAC,MAAA;YAAA;YAAAC,GAAA;cAAAC,OAAA;gBAAAzD;cAAA;cAAAU;YAAA;YAAAsC,QAAA;YAAAU,WAAA;UAAA,CAUT;QAAA,C,IAIJrB,IAAA,CAAAnD,UAAA;UAAA2D,KAAA;YAAAC,IAAA,EAEU;YAAA5C,KAAA;cAAAyD,YAAA,EAEU;YAAA;YAAAZ,KAAA,EAETrC,CAAA,CAAE;YAAAsC,QAAA;UAAA;UAAAN,IAAA,EAGN;UAAAO,QAAA,EAAAW,OAAA,IAEHpE,KAAA,CAAM0C,OAAA;YAAAY,IAAA,EACE;YAAAI,IAAA,EACA;YAAAC,SAAA;YAAAC,IAAA;YAAAC,KAAA,EAGC;YAAAX,IAAA,GACA;YAAAY,WAAA;cAAAC,MAAA;YAAA;YAAAC,GAAA;cAAAC,OAAA;gBAAAzD;cAAA;cAAAU;YAAA;YAAAsC,QAAA;YAAAU,WAAA;UAAA,CAKT;QAAA,C,GAINrB,IAAA,CAAAjD,UAAA;UAAAyE,IAAA,EAAiB;UAAAjB,QAAA,EAASlC,CAAA,CAAE;QAAA,C;;;;;;;;;;;;;;;;;;;SAzE9BgB,E;CA4EJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Button","EmailField","Form","FormSubmit","Link","TextField","useConfig","useTranslation","email","formatAdminURL","text","React","useEffect","useRef","useState","FormHeader","baseClass","formatResendDelay","seconds","Math","floor","String","padStart","removeStoredRequest","sessionStorageKey","window","sessionStorage","removeItem","saveStoredRequest","request","setItem","JSON","stringify","ForgotPasswordForm","config","getEntityConfig","admin","routes","login","loginRoute","user","userSlug","adminRoute","api","apiRoute","t","hasSubmitted","setHasSubmitted","resendDelay","setResendDelay","storedRequest","setStoredRequest","resendAvailableAt","submittedIdentifier","collectionConfig","collectionSlug","loginWithUsername","auth","minRequestInterval","forgotPassword","storedValue","getItem","parsedValue","parse","identifier","Date","now","current","max","ceil","timeout","setTimeout","clearTimeout","handleResponse","res","successToast","errorToast","json","then","nextResendAvailableAt","nextStoredRequest","catch","initialState","username","initialValue","valid","value","_jsx","action","path","className","method","onSubmit","_","data","_jsxs","_Fragment","description","heading","buttonStyle","disabled","extraButtonProps","style","marginBlockStart","size","type","href","prefetch","field","name","label","required","validate","blockData","event","preferences","fields","req","payload","siblingData","autoComplete"],"sources":["../../../../src/views/ForgotPassword/ForgotPasswordForm/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\nimport type { FormState, PayloadRequest } from 'payload'\n\nimport {\n Button,\n EmailField,\n Form,\n FormSubmit,\n Link,\n TextField,\n useConfig,\n useTranslation,\n} from '@payloadcms/ui'\nimport { email, formatAdminURL, text } from 'payload/shared'\nimport React, { useEffect, useRef, useState } from 'react'\n\nimport { FormHeader } from '../../../elements/FormHeader/index.js'\nimport './index.scss'\n\nconst baseClass = 'forgot-password__form'\n\ntype StoredForgotPasswordRequest = {\n identifier: string\n resendAvailableAt: number\n}\n\nconst formatResendDelay = (seconds: number): string =>\n `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`\n\nconst removeStoredRequest = (sessionStorageKey: string): void => {\n try {\n window.sessionStorage.removeItem(sessionStorageKey)\n } catch {\n return\n }\n}\n\nconst saveStoredRequest = ({\n request,\n sessionStorageKey,\n}: {\n request: StoredForgotPasswordRequest\n sessionStorageKey: string\n}): void => {\n try {\n window.sessionStorage.setItem(sessionStorageKey, JSON.stringify(request))\n } catch {\n return\n }\n}\n\nexport const ForgotPasswordForm: React.FC = () => {\n const { config, getEntityConfig } = useConfig()\n\n const {\n admin: {\n routes: { login: loginRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute, api: apiRoute },\n } = config\n\n const { t } = useTranslation()\n const [hasSubmitted, setHasSubmitted] = useState(false)\n const [resendDelay, setResendDelay] = useState(0)\n const [storedRequest, setStoredRequest] = useState<null | StoredForgotPasswordRequest>(null)\n const resendAvailableAt = useRef(0)\n const submittedIdentifier = useRef<null | string>(null)\n const collectionConfig = getEntityConfig({ collectionSlug: userSlug })\n const loginWithUsername = collectionConfig?.auth?.loginWithUsername\n const minRequestInterval = collectionConfig?.auth?.forgotPassword?.minRequestInterval ?? 15000\n const sessionStorageKey = `payload-forgot-password:${userSlug}`\n\n useEffect(() => {\n try {\n const storedValue = window.sessionStorage.getItem(sessionStorageKey)\n\n if (!storedValue) {\n return\n }\n\n const parsedValue = JSON.parse(storedValue) as StoredForgotPasswordRequest\n\n if (\n typeof parsedValue.identifier !== 'string' ||\n typeof parsedValue.resendAvailableAt !== 'number' ||\n parsedValue.resendAvailableAt <= Date.now()\n ) {\n removeStoredRequest(sessionStorageKey)\n return\n }\n\n submittedIdentifier.current = parsedValue.identifier\n resendAvailableAt.current = parsedValue.resendAvailableAt\n setStoredRequest(parsedValue)\n setResendDelay(Math.max(0, Math.ceil((parsedValue.resendAvailableAt - Date.now()) / 1000)))\n setHasSubmitted(true)\n } catch {\n removeStoredRequest(sessionStorageKey)\n }\n }, [sessionStorageKey])\n\n useEffect(() => {\n if (resendDelay === 0) {\n return\n }\n const timeout = setTimeout(() => {\n setResendDelay(Math.max(0, Math.ceil((resendAvailableAt.current - Date.now()) / 1000)))\n }, 1050)\n return () => clearTimeout(timeout)\n }, [resendDelay])\n\n const handleResponse: FormProps['handleResponse'] = (res, successToast, errorToast) => {\n res\n .json()\n .then(() => {\n const nextResendAvailableAt = Date.now() + minRequestInterval\n const nextStoredRequest = submittedIdentifier.current\n ? {\n identifier: submittedIdentifier.current,\n resendAvailableAt: nextResendAvailableAt,\n }\n : null\n\n resendAvailableAt.current = nextResendAvailableAt\n setResendDelay(Math.ceil(minRequestInterval / 1000))\n setStoredRequest(nextStoredRequest)\n setHasSubmitted(true)\n\n if (nextStoredRequest) {\n saveStoredRequest({ request: nextStoredRequest, sessionStorageKey })\n }\n\n successToast(t('general:submissionSuccessful'))\n })\n .catch(() => {\n errorToast(\n loginWithUsername\n ? t('authentication:usernameNotValid')\n : t('authentication:emailNotValid'),\n )\n })\n }\n\n const initialState: FormState = loginWithUsername\n ? {\n username: {\n initialValue: storedRequest?.identifier ?? '',\n valid: true,\n value: storedRequest?.identifier,\n },\n }\n : {\n email: {\n initialValue: storedRequest?.identifier ?? '',\n valid: true,\n value: storedRequest?.identifier,\n },\n }\n\n return (\n <Form\n action={formatAdminURL({\n apiRoute,\n path: `/${userSlug}/forgot-password`,\n })}\n className={baseClass}\n handleResponse={handleResponse}\n initialState={initialState}\n key={`${hasSubmitted ? 'submitted' : 'editing'}:${storedRequest?.identifier ?? ''}`}\n method=\"POST\"\n onSubmit={(_, data) => {\n const identifier = loginWithUsername ? data.username : data.email\n\n submittedIdentifier.current = typeof identifier === 'string' ? identifier : null\n }}\n >\n {hasSubmitted ? (\n <>\n <FormHeader\n description={t('authentication:checkYourEmailForPasswordReset')}\n heading={t('authentication:emailSent')}\n />\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"primary\"\n className={`${baseClass}__submit`}\n disabled={resendDelay > 0}\n extraButtonProps={{ style: { marginBlockStart: 0 } }}\n size=\"large\"\n type=\"submit\"\n >\n {resendDelay > 0\n ? `${t('authentication:resend')} (${formatResendDelay(resendDelay)})`\n : t('authentication:resend')}\n </Button>\n <Link href={formatAdminURL({ adminRoute, path: loginRoute })} prefetch={false}>\n {t('authentication:backToLogin')}\n </Link>\n </div>\n </>\n ) : (\n <>\n <FormHeader\n description={\n loginWithUsername\n ? t('authentication:forgotPasswordUsernameInstructions')\n : t('authentication:forgotPasswordEmailInstructions')\n }\n heading={t('authentication:forgotPassword')}\n />\n\n {loginWithUsername ? (\n <TextField\n field={{\n name: 'username',\n label: t('authentication:username'),\n required: true,\n }}\n path=\"username\"\n validate={(value) =>\n text(value, {\n name: 'username',\n type: 'text',\n blockData: {},\n data: {},\n event: 'onChange',\n path: ['username'],\n preferences: { fields: {} },\n req: {\n payload: {\n config,\n },\n t,\n } as unknown as PayloadRequest,\n required: true,\n siblingData: {},\n })\n }\n />\n ) : (\n <EmailField\n field={{\n name: 'email',\n admin: {\n autoComplete: 'email',\n },\n label: t('general:email'),\n required: true,\n }}\n path=\"email\"\n validate={(value) =>\n email(value, {\n name: 'email',\n type: 'email',\n blockData: {},\n data: {},\n event: 'onChange',\n path: ['email'],\n preferences: { fields: {} },\n req: { payload: { config }, t } as unknown as PayloadRequest,\n required: true,\n siblingData: {},\n })\n }\n />\n )}\n <FormSubmit size=\"large\">{t('general:submit')}</FormSubmit>\n <Link href={formatAdminURL({ adminRoute, path: loginRoute })} prefetch={false}>\n {t('authentication:backToLogin')}\n </Link>\n </>\n )}\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAKA,SACEA,MAAM,EACNC,UAAU,EACVC,IAAI,EACJC,UAAU,EACVC,IAAI,EACJC,SAAS,EACTC,SAAS,EACTC,cAAc,QACT;AACP,SAASC,KAAK,EAAEC,cAAc,EAAEC,IAAI,QAAQ;AAC5C,OAAOC,KAAA,IAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAEnD,SAASC,UAAU,QAAQ;AAG3B,MAAMC,SAAA,GAAY;AAOlB,MAAMC,iBAAA,GAAqBC,OAAA,IACzB,GAAGC,IAAA,CAAKC,KAAK,CAACF,OAAA,GAAU,OAAOG,MAAA,CAAOH,OAAA,GAAU,IAAII,QAAQ,CAAC,GAAG,MAAM;AAExE,MAAMC,mBAAA,GAAuBC,iBAAA;EAC3B,IAAI;IACFC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ZnB,IAAA,EAAM,CAAC;UACPoB,KAAA,EAAO;UACPzB,IAAA,EAAM,CAAC,WAAW;UAClB0B,WAAA,EAAa;YAAEC,MAAA,EAAQ,CAAC;UAAE;UAC1BC,GAAA,EAAK;YACHC,OAAA,EAAS;cACPpF;YACF;YACAW;UACF;UACAkE,QAAA,EAAU;UACVQ,WAAA,EAAa,CAAC;QAChB;wBAIJhC,IAAA,CAACtF,UAAA;QACC2G,KAAA,EAAO;UACLC,IAAA,EAAM;UACNzE,KAAA,EAAO;YACLoF,YAAA,EAAc;UAChB;UACAV,KAAA,EAAOjE,CAAA,CAAE;UACTkE,QAAA,EAAU;QACZ;QACAtB,IAAA,EAAK;QACLuB,QAAA,EAAW1B,OAAA,IACT9E,KAAA,CAAM8E,OAAA,EAAO;UACXuB,IAAA,EAAM;UACNJ,IAAA,EAAM;UACNQ,SAAA,EAAW,CAAC;UACZnB,IAAA,EAAM,CAAC;UACPoB,KAAA,EAAO;UACPzB,IAAA,EAAM,CAAC,QAAQ;UACf0B,WAAA,EAAa;YAAEC,MAAA,EAAQ,CAAC;UAAE;UAC1BC,GAAA,EAAK;YAAEC,OAAA,EAAS;cAAEpF;YAAO;YAAGW;UAAE;UAC9BkE,QAAA,EAAU;UACVQ,WAAA,EAAa,CAAC;QAChB;uBAINhC,IAAA,CAACpF,UAAA;QAAWqG,IAAA,EAAK;kBAAS3D,CAAA,CAAE;uBAC5B0C,IAAA,CAACnF,IAAA;QAAKsG,IAAA,EAAMjG,cAAA,CAAe;UAAEiC,UAAA;UAAY+C,IAAA,EAAMlD;QAAW;QAAIoE,QAAA,EAAU;kBACrE9D,CAAA,CAAE;;;KApGJ,GAAGC,YAAA,GAAe,cAAc,aAAaI,aAAA,EAAec,UAAA,IAAc,IAAI;AA0GzF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/ForgotPassword/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAKnD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,eAAO,MAAM,uBAAuB,oBAAoB,CAAA;AAExD,wBAAgB,kBAAkB,CAAC,EAAE,cAAc,EAAE,EAAE,oBAAoB,qBA8D1E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/ForgotPassword/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAKnD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,eAAO,MAAM,uBAAuB,oBAAoB,CAAA;AAExD,wBAAgB,kBAAkB,CAAC,EAAE,cAAc,EAAE,EAAE,oBAAoB,qBAqD1E"}
@@ -21,8 +21,7 @@ export function ForgotPasswordView({
21
21
  const {
22
22
  admin: {
23
23
  routes: {
24
- account: accountRoute,
25
- login: loginRoute
24
+ account: accountRoute
26
25
  }
27
26
  },
28
27
  routes: {
@@ -58,15 +57,8 @@ export function ForgotPasswordView({
58
57
  })]
59
58
  });
60
59
  }
61
- return /*#__PURE__*/_jsxs(Fragment, {
62
- children: [/*#__PURE__*/_jsx(ForgotPasswordForm, {}), /*#__PURE__*/_jsx(Link, {
63
- href: formatAdminURL({
64
- adminRoute,
65
- path: loginRoute
66
- }),
67
- prefetch: false,
68
- children: i18n.t('authentication:backToLogin')
69
- })]
60
+ return /*#__PURE__*/_jsx(Fragment, {
61
+ children: /*#__PURE__*/_jsx(ForgotPasswordForm, {})
70
62
  });
71
63
  }
72
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Button","Link","Translation","formatAdminURL","React","Fragment","FormHeader","ForgotPasswordForm","forgotPasswordBaseClass","ForgotPasswordView","initPageResult","req","i18n","payload","config","user","admin","routes","account","accountRoute","login","loginRoute","adminRoute","_jsxs","_jsx","description","elements","0","children","href","path","prefetch","i18nKey","t","heading","buttonStyle","el","size","to"],"sources":["../../../src/views/ForgotPassword/index.tsx"],"sourcesContent":["import type { AdminViewServerProps } from 'payload'\n\nimport { Button, Link } from '@payloadcms/ui'\nimport { Translation } from '@payloadcms/ui/shared'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { FormHeader } from '../../elements/FormHeader/index.js'\nimport { ForgotPasswordForm } from './ForgotPasswordForm/index.js'\n\nexport const forgotPasswordBaseClass = 'forgot-password'\n\nexport function ForgotPasswordView({ initPageResult }: AdminViewServerProps) {\n const {\n req: {\n i18n,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: {\n routes: { account: accountRoute, login: loginRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (user) {\n return (\n <Fragment>\n <FormHeader\n description={\n <Translation\n elements={{\n '0': ({ children }) => (\n <Link\n href={formatAdminURL({\n adminRoute,\n path: accountRoute,\n })}\n prefetch={false}\n >\n {children}\n </Link>\n ),\n }}\n i18nKey=\"authentication:loggedInChangePassword\"\n t={i18n.t}\n />\n }\n heading={i18n.t('authentication:alreadyLoggedIn')}\n />\n <Button buttonStyle=\"secondary\" el=\"link\" size=\"large\" to={adminRoute}>\n {i18n.t('general:backToDashboard')}\n </Button>\n </Fragment>\n )\n }\n\n return (\n <Fragment>\n <ForgotPasswordForm />\n <Link\n href={formatAdminURL({\n adminRoute,\n path: loginRoute,\n })}\n prefetch={false}\n >\n {i18n.t('authentication:backToLogin')}\n </Link>\n </Fragment>\n )\n}\n"],"mappings":";AAEA,SAASA,MAAM,EAAEC,IAAI,QAAQ;AAC7B,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,UAAU,QAAQ;AAC3B,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,uBAAA,GAA0B;AAEvC,OAAO,SAASC,mBAAmB;EAAEC;AAAc,CAAwB;EACzE,MAAM;IACJC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGL,cAAA;EAEJ,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,OAAA,EAASC,YAAY;QAAEC,KAAA,EAAOC;MAAU;IAAE,CACrD;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGR,MAAA;EAEJ,IAAIC,IAAA,EAAM;IACR,oBACEQ,KAAA,CAAClB,QAAA;8BACCmB,IAAA,CAAClB,UAAA;QACCmB,WAAA,eACED,IAAA,CAACtB,WAAA;UACCwB,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC;YAAQ,CAAE,kBAChBJ,IAAA,CAACvB,IAAA;cACC4B,IAAA,EAAM1B,cAAA,CAAe;gBACnBmB,UAAA;gBACAQ,IAAA,EAAMX;cACR;cACAY,QAAA,EAAU;wBAETH;;UAGP;UACAI,OAAA,EAAQ;UACRC,CAAA,EAAGrB,IAAA,CAAKqB;;QAGZC,OAAA,EAAStB,IAAA,CAAKqB,CAAC,CAAC;uBAElBT,IAAA,CAACxB,MAAA;QAAOmC,WAAA,EAAY;QAAYC,EAAA,EAAG;QAAOC,IAAA,EAAK;QAAQC,EAAA,EAAIhB,UAAA;kBACxDV,IAAA,CAAKqB,CAAC,CAAC;;;EAIhB;EAEA,oBACEV,KAAA,CAAClB,QAAA;4BACCmB,IAAA,CAACjB,kBAAA,O,aACDiB,IAAA,CAACvB,IAAA;MACC4B,IAAA,EAAM1B,cAAA,CAAe;QACnBmB,UAAA;QACAQ,IAAA,EAAMT;MACR;MACAU,QAAA,EAAU;gBAETnB,IAAA,CAAKqB,CAAC,CAAC;;;AAIhB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Button","Link","Translation","formatAdminURL","React","Fragment","FormHeader","ForgotPasswordForm","forgotPasswordBaseClass","ForgotPasswordView","initPageResult","req","i18n","payload","config","user","admin","routes","account","accountRoute","adminRoute","_jsxs","_jsx","description","elements","0","children","href","path","prefetch","i18nKey","t","heading","buttonStyle","el","size","to"],"sources":["../../../src/views/ForgotPassword/index.tsx"],"sourcesContent":["import type { AdminViewServerProps } from 'payload'\n\nimport { Button, Link } from '@payloadcms/ui'\nimport { Translation } from '@payloadcms/ui/shared'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport { FormHeader } from '../../elements/FormHeader/index.js'\nimport { ForgotPasswordForm } from './ForgotPasswordForm/index.js'\n\nexport const forgotPasswordBaseClass = 'forgot-password'\n\nexport function ForgotPasswordView({ initPageResult }: AdminViewServerProps) {\n const {\n req: {\n i18n,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: {\n routes: { account: accountRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (user) {\n return (\n <Fragment>\n <FormHeader\n description={\n <Translation\n elements={{\n '0': ({ children }) => (\n <Link\n href={formatAdminURL({\n adminRoute,\n path: accountRoute,\n })}\n prefetch={false}\n >\n {children}\n </Link>\n ),\n }}\n i18nKey=\"authentication:loggedInChangePassword\"\n t={i18n.t}\n />\n }\n heading={i18n.t('authentication:alreadyLoggedIn')}\n />\n <Button buttonStyle=\"secondary\" el=\"link\" size=\"large\" to={adminRoute}>\n {i18n.t('general:backToDashboard')}\n </Button>\n </Fragment>\n )\n }\n\n return (\n <Fragment>\n <ForgotPasswordForm />\n </Fragment>\n )\n}\n"],"mappings":";AAEA,SAASA,MAAM,EAAEC,IAAI,QAAQ;AAC7B,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,UAAU,QAAQ;AAC3B,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,uBAAA,GAA0B;AAEvC,OAAO,SAASC,mBAAmB;EAAEC;AAAc,CAAwB;EACzE,MAAM;IACJC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGL,cAAA;EAEJ,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,OAAA,EAASC;MAAY;IAAE,CAClC;IACDF,MAAA,EAAQ;MAAED,KAAA,EAAOI;IAAU;EAAE,CAC9B,GAAGN,MAAA;EAEJ,IAAIC,IAAA,EAAM;IACR,oBACEM,KAAA,CAAChB,QAAA;8BACCiB,IAAA,CAAChB,UAAA;QACCiB,WAAA,eACED,IAAA,CAACpB,WAAA;UACCsB,QAAA,EAAU;YACR,KAAKC,CAAC;cAAEC;YAAQ,CAAE,kBAChBJ,IAAA,CAACrB,IAAA;cACC0B,IAAA,EAAMxB,cAAA,CAAe;gBACnBiB,UAAA;gBACAQ,IAAA,EAAMT;cACR;cACAU,QAAA,EAAU;wBAETH;;UAGP;UACAI,OAAA,EAAQ;UACRC,CAAA,EAAGnB,IAAA,CAAKmB;;QAGZC,OAAA,EAASpB,IAAA,CAAKmB,CAAC,CAAC;uBAElBT,IAAA,CAACtB,MAAA;QAAOiC,WAAA,EAAY;QAAYC,EAAA,EAAG;QAAOC,IAAA,EAAK;QAAQC,EAAA,EAAIhB,UAAA;kBACxDR,IAAA,CAAKmB,CAAC,CAAC;;;EAIhB;EAEA,oBACET,IAAA,CAACjB,QAAA;cACC,aAAAiB,IAAA,CAACf,kBAAA;;AAGP","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC1F,OAAO,KAAK,EAAyB,cAAc,EAAmB,MAAM,SAAS,CAAA;AAQrF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,sBAAsB,EACtB,OAAO,CAAC,4BAA4B,CAAC,CAqHtC,CAAA"}
1
+ {"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC1F,OAAO,KAAK,EAAyB,cAAc,EAAmB,MAAM,SAAS,CAAA;AAQrF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,sBAAsB,EACtB,OAAO,CAAC,4BAA4B,CAAC,CAuHtC,CAAA"}
@@ -26,9 +26,10 @@ export const renderListHandler = async args => {
26
26
  config
27
27
  },
28
28
  user
29
- }
29
+ },
30
+ user: userWithReadAccess
30
31
  } = args;
31
- if (!req.user) {
32
+ if (!user) {
32
33
  throw new UnauthorizedError();
33
34
  }
34
35
  await canAccessAdmin({
@@ -120,6 +121,7 @@ export const renderListHandler = async args => {
120
121
  redirectAfterDelete,
121
122
  redirectAfterDuplicate,
122
123
  searchParams: {},
124
+ user: userWithReadAccess,
123
125
  viewType: 'list'
124
126
  });
125
127
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"handleServerFunction.js","names":["getClientConfig","canAccessAdmin","isEntityHidden","UnauthorizedError","applyLocaleFiltering","renderListView","renderListHandler","args","collectionSlug","cookies","disableActions","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","locale","overrideEntityVisibility","permissions","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","clientConfig","importMap","preferencesKey","preferences","find","collection","depth","limit","where","and","key","equals","id","then","res","docs","value","visibleEntities","collections","map","slug","admin","hidden","filter","Boolean","globals","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { RenderListServerFnArgs, RenderListServerFnReturnType } from '@payloadcms/ui'\nimport type { CollectionPreferences, ServerFunction, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { canAccessAdmin, isEntityHidden, UnauthorizedError } from 'payload'\nimport { applyLocaleFiltering } from 'payload/shared'\n\nimport { renderListView } from './index.js'\n\nexport const renderListHandler: ServerFunction<\n RenderListServerFnArgs,\n Promise<RenderListServerFnReturnType>\n> = async (args) => {\n const {\n collectionSlug,\n cookies,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n locale,\n overrideEntityVisibility,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = args\n\n if (!req.user) {\n throw new UnauthorizedError()\n }\n\n await canAccessAdmin({ req })\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const preferencesKey = `collection-${collectionSlug}`\n\n const preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as CollectionPreferences)\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n i18n,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n locale,\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n locale,\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n payload,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ;AAClE,SAASC,oBAAoB,QAAQ;AAErC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,iBAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IACJC,cAAc;IACdC,OAAO;IACPC,cAAc;IACdC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,UAAU;IACVC,mBAAmB;IACnBC,MAAM;IACNC,wBAAwB;IACxBC,WAAW;IACXC,KAAK;IACLC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI;EACL,CACF,GAAGnB,IAAA;EAEJ,IAAI,CAACe,GAAA,CAAII,IAAI,EAAE;IACb,MAAM,IAAIvB,iBAAA;EACZ;EAEA,MAAMF,cAAA,CAAe;IAAEqB;EAAI;EAE3B,MAAMK,YAAA,GAAe3B,eAAA,CAAgB;IACnCyB,MAAA;IACAF,IAAA;IACAK,SAAA,EAAWJ,OAAA,CAAQI,SAAS;IAC5BF;EACF;EACA,MAAMtB,oBAAA,CAAqB;IAAEuB,YAAA;IAAcF,MAAA;IAAQH;EAAI;EAEvD,MAAMO,cAAA,GAAiB,cAAcrB,cAAA,EAAgB;EAErD,MAAMsB,WAAA,GAAc,MAAMN,OAAA,CACvBO,IAAI,CAAC;IACJC,UAAA,EAAY;IACZC,KAAA,EAAO;IACPC,KAAA,EAAO;IACPC,KAAA,EAAO;MACLC,GAAA,EAAK,CACH;QACEC,GAAA,EAAK;UACHC,MAAA,EAAQT;QAC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AA;MACAsC,YAAA,EAAcD,SAAA;MACdf;IACF;IACA5B,MAAA;IACAC,wBAAA;IACA4C,MAAA,EAAQ;MACNC,QAAA,EAAU,CAAC,eAAetD,cAAA;IAC5B;IACAgB,OAAA;IACAN,WAAA;IACAC,KAAA;IACAC,mBAAA;IACAC,sBAAA;IACA0C,YAAA,EAAc,CAAC;IACfC,QAAA,EAAU;EACZ;EAEA,OAAO;IACLX,IAAA;IACAvB;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"handleServerFunction.js","names":["getClientConfig","canAccessAdmin","isEntityHidden","UnauthorizedError","applyLocaleFiltering","renderListView","renderListHandler","args","collectionSlug","cookies","disableActions","disableBulkDelete","disableBulkEdit","disableQueryPresets","drawerSlug","enableRowSelections","locale","overrideEntityVisibility","permissions","query","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","userWithReadAccess","clientConfig","importMap","preferencesKey","preferences","find","collection","depth","limit","where","and","key","equals","id","then","res","docs","value","visibleEntities","collections","map","slug","admin","hidden","filter","Boolean","globals","List","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","searchParams","viewType"],"sources":["../../../src/views/List/handleServerFunction.tsx"],"sourcesContent":["import type { RenderListServerFnArgs, RenderListServerFnReturnType } from '@payloadcms/ui'\nimport type { CollectionPreferences, ServerFunction, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { canAccessAdmin, isEntityHidden, UnauthorizedError } from 'payload'\nimport { applyLocaleFiltering } from 'payload/shared'\n\nimport { renderListView } from './index.js'\n\nexport const renderListHandler: ServerFunction<\n RenderListServerFnArgs,\n Promise<RenderListServerFnReturnType>\n> = async (args) => {\n const {\n collectionSlug,\n cookies,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n locale,\n overrideEntityVisibility,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n user: userWithReadAccess,\n } = args\n\n if (!user) {\n throw new UnauthorizedError()\n }\n\n await canAccessAdmin({ req })\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n user,\n })\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const preferencesKey = `collection-${collectionSlug}`\n\n const preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as CollectionPreferences)\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const { List } = await renderListView({\n clientConfig,\n disableActions,\n disableBulkDelete,\n disableBulkEdit,\n disableQueryPresets,\n drawerSlug,\n enableRowSelections,\n i18n,\n importMap: payload.importMap,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n locale,\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n locale,\n overrideEntityVisibility,\n params: {\n segments: ['collections', collectionSlug],\n },\n payload,\n permissions,\n query,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams: {},\n user: userWithReadAccess,\n viewType: 'list',\n })\n\n return {\n List,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,cAAc,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ;AAClE,SAASC,oBAAoB,QAAQ;AAErC,SAASC,cAAc,QAAQ;A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AvB;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAIpB,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EAEvB,gBAAgB,EAGjB,MAAM,SAAS,CAAA;AAehB,OAAO,KAAmB,MAAM,OAAO,CAAA;AASvC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EACd,gBAAgB,GAChB,KAAK,CAAC,aAAa,CAAC,mBAAmB,GAAG,CAAC,mBAAmB,GAAG,uBAAuB,CAAC,CAAC,CAAA;IAC9F,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,GAAG,oBAAoB,CAAA;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,SACnB,kBAAkB,KACvB,OAAO,CAAC;IACT,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB,CA+WA,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAYjD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAIpB,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EAEvB,gBAAgB,EAGjB,MAAM,SAAS,CAAA;AAehB,OAAO,KAAmB,MAAM,OAAO,CAAA;AASvC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EACd,gBAAgB,GAChB,KAAK,CAAC,aAAa,CAAC,mBAAmB,GAAG,CAAC,mBAAmB,GAAG,uBAAuB,CAAC,CAAC,CAAA;IAC9F,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,GAAG,oBAAoB,CAAA;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,SACnB,kBAAkB,KACvB,OAAO,CAAC;IACT,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB,CAgXA,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAYjD,CAAA"}
@@ -35,6 +35,7 @@ export const renderListView = async args => {
35
35
  query: queryFromArgs,
36
36
  searchParams,
37
37
  trash,
38
+ user: userWithReadAccess,
38
39
  viewType
39
40
  } = args;
40
41
  const {
@@ -282,7 +283,7 @@ export const renderListView = async args => {
282
283
  payload,
283
284
  permissions,
284
285
  searchParams,
285
- user
286
+ user: userWithReadAccess
286
287
  };
287
288
  const listViewSlots = renderListViewSlots({
288
289
  clientProps: {