@payloadcms/next 3.13.0 → 3.14.1-canary.549a973
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/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/handler.js +5 -1
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/rest/collections/delete.js +2 -2
- package/dist/routes/rest/collections/delete.js.map +1 -1
- package/dist/routes/rest/collections/update.js +2 -2
- package/dist/routes/rest/collections/update.js.map +1 -1
- package/dist/routes/rest/routeError.d.ts.map +1 -1
- package/dist/routes/rest/routeError.js +6 -11
- package/dist/routes/rest/routeError.js.map +1 -1
- package/dist/views/Account/ResetPreferences/ConfirmResetModal/index.d.ts +6 -0
- package/dist/views/Account/ResetPreferences/ConfirmResetModal/index.d.ts.map +1 -0
- package/dist/views/Account/ResetPreferences/ConfirmResetModal/index.js +83 -0
- package/dist/views/Account/ResetPreferences/ConfirmResetModal/index.js.map +1 -0
- package/dist/views/Account/ResetPreferences/ConfirmResetModal/index.scss +40 -0
- package/dist/views/Account/ResetPreferences/index.d.ts +6 -0
- package/dist/views/Account/ResetPreferences/index.d.ts.map +1 -0
- package/dist/views/Account/ResetPreferences/index.js +73 -0
- package/dist/views/Account/ResetPreferences/index.js.map +1 -0
- package/dist/views/Account/Settings/index.d.ts +3 -1
- package/dist/views/Account/Settings/index.d.ts.map +1 -1
- package/dist/views/Account/Settings/index.js +9 -2
- package/dist/views/Account/Settings/index.js.map +1 -1
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +4 -1
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +1 -1
- 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 +1 -0
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Document/getDocumentData.d.ts +3 -2
- package/dist/views/Document/getDocumentData.d.ts.map +1 -1
- package/dist/views/Document/getDocumentData.js +17 -2
- package/dist/views/Document/getDocumentData.js.map +1 -1
- package/dist/views/Document/getDocumentPermissions.js +11 -5
- package/dist/views/Document/getDocumentPermissions.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +6 -1
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +4 -3
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Versions/getLatestVersion.d.ts.map +1 -1
- package/dist/views/Versions/getLatestVersion.js +6 -2
- package/dist/views/Versions/getLatestVersion.js.map +1 -1
- package/dist/views/Versions/index.d.ts +1 -1
- package/dist/views/Versions/index.d.ts.map +1 -1
- package/dist/views/Versions/index.js +11 -4
- package/dist/views/Versions/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,SAAS,CAAA;AAoEjF,eAAO,MAAM,UAAU,WAAkB,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAsD9E,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { configToSchema } from '@payloadcms/graphql';
|
|
2
2
|
import { createHandler } from 'graphql-http/lib/use/fetch';
|
|
3
3
|
import httpStatus from 'http-status';
|
|
4
|
+
import { logError } from 'payload';
|
|
4
5
|
import { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js';
|
|
5
6
|
import { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js';
|
|
6
7
|
import { createPayloadRequest } from '../../utilities/createPayloadRequest.js';
|
|
@@ -13,7 +14,10 @@ const handleError = async ({
|
|
|
13
14
|
}) => {
|
|
14
15
|
const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR;
|
|
15
16
|
let errorMessage = err.message;
|
|
16
|
-
|
|
17
|
+
logError({
|
|
18
|
+
err,
|
|
19
|
+
payload
|
|
20
|
+
});
|
|
17
21
|
// Internal server errors can contain anything, including potentially sensitive data.
|
|
18
22
|
// Therefore, error details will be hidden from the response unless `config.debug` is `true`
|
|
19
23
|
if (!payload.config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","names":["configToSchema","createHandler","httpStatus","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","mergeHeaders","handleError","err","payload","req","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","
|
|
1
|
+
{"version":3,"file":"handler.js","names":["configToSchema","createHandler","httpStatus","logError","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","mergeHeaders","handleError","err","payload","req","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","config","debug","response","extensions","name","undefined","data","stack","statusCode","locations","path","hooks","afterError","reduce","promise","hook","result","context","error","graphqlResult","Promise","resolve","cached","global","_payload_graphql","graphql","getGraphql","process","env","NODE_ENV","resolvedConfig","schema","e","POST","request","originalRequest","clone","validationRules","headers","apiResponse","onOperation","args","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","append","Response","body","responseHeaders"],"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLError, GraphQLFormattedError } from 'graphql'\nimport type { APIError, Payload, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\nimport { logError } from 'payload'\n\nimport { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js'\nimport { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js'\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { mergeHeaders } from '../../utilities/mergeHeaders.js'\n\nconst handleError = async ({\n err,\n payload,\n req,\n}: {\n err: GraphQLError\n payload: Payload\n req: PayloadRequest\n}): Promise<GraphQLFormattedError> => {\n const status = (err.originalError as APIError).status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n logError({ err, payload })\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!payload.config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && (err.originalError as APIError).data) || undefined,\n stack: payload.config.debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n await payload.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n context: req.context,\n error: err,\n graphqlResult: response,\n req,\n })\n\n if (result) {\n response = result.graphqlResult || response\n }\n }, Promise.resolve())\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const req = await createPayloadRequest({\n config,\n request,\n })\n\n await addDataAndFileToRequest(req)\n addLocalesToRequestFromData(req)\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError({ err: error, payload, req })\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (_, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,\n status: apiResponse.status,\n })\n }\n"],"mappings":"AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAC9B,OAAOC,UAAA,MAAgB;AACvB,SAASC,QAAQ,QAAQ;AAEzB,SAASC,uBAAuB,QAAQ;AACxC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAE7B,MAAMC,WAAA,GAAc,MAAAA,CAAO;EACzBC,GAAG;EACHC,OAAO;EACPC;A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,UAAA;IAC/ErD,MAAA,EAAQ4C,WAAA,CAAY5C;EACtB;AACF","ignoreList":[]}
|
|
@@ -30,7 +30,7 @@ export const deleteDoc = async ({
|
|
|
30
30
|
if (result.errors.length === 0) {
|
|
31
31
|
const message = req.t('general:deletedCountSuccessfully', {
|
|
32
32
|
count: result.docs.length,
|
|
33
|
-
label: getTranslation(collection.config.labels[result.docs.length
|
|
33
|
+
label: getTranslation(collection.config.labels[result.docs.length === 1 ? 'singular' : 'plural'], req.i18n)
|
|
34
34
|
});
|
|
35
35
|
return Response.json({
|
|
36
36
|
...result,
|
|
@@ -43,7 +43,7 @@ export const deleteDoc = async ({
|
|
|
43
43
|
const total = result.docs.length + result.errors.length;
|
|
44
44
|
const message = req.t('error:unableToDeleteCount', {
|
|
45
45
|
count: result.errors.length,
|
|
46
|
-
label: getTranslation(collection.config.labels[total
|
|
46
|
+
label: getTranslation(collection.config.labels[total === 1 ? 'singular' : 'plural'], req.i18n),
|
|
47
47
|
total
|
|
48
48
|
});
|
|
49
49
|
return Response.json({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","names":["getTranslation","httpStatus","deleteOperation","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","deleteDoc","collection","req","depth","overrideLock","populate","select","where","query","result","Number","undefined","Boolean","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, overrideLock, populate, select, where } = req.query as {\n depth?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length
|
|
1
|
+
{"version":3,"file":"delete.js","names":["getTranslation","httpStatus","deleteOperation","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","deleteDoc","collection","req","depth","overrideLock","populate","select","where","query","result","Number","undefined","Boolean","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, overrideLock, populate, select, where } = req.query as {\n depth?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length === 1 ? 'singular' : 'plural'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total === 1 ? 'singular' : 'plural'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,eAAe,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ;AAC5E,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,SAAA,GAAoC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACzE,MAAM;IAAEC,KAAK;IAAEC,YAAY;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAAK,CAAE,GAAGL,GAAA,CAAIM,KAAK;EAQlE,MAAMC,MAAA,GAAS,MAAMd,eAAA,CAAgB;IACnCM,UAAA;IACAE,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCP,YAAA,EAAcQ,OAAA,CAAQR,YAAA,KAAiB;IACvCC,QAAA,EAAUT,qBAAA,CAAsBS,QAAA;IAChCH,GAAA;IACAI,MAAA,EAAQT,mBAAA,CAAoBS,MAAA;IAC5BC;EACF;EAEA,MAAMM,OAAA,GAAUd,eAAA,CAAgB;IAC9Bc,OAAA,EAAS,IAAIC,OAAA;IACbZ;EACF;EAEA,IAAIO,MAAA,CAAOM,MAAM,CAACC,MAAM,KAAK,GAAG;IAC9B,MAAMC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC,oCAAoC;MACxDC,KAAA,EAAOV,MAAA,CAAOW,IAAI,CAACJ,MAAM;MACzBK,KAAA,EAAO5B,cAAA,CACLQ,UAAA,CAAWqB,MAAM,CAACC,MAAM,CAACd,MAAA,CAAOW,IAAI,CAACJ,MAAM,KAAK,IAAI,aAAa,SAAS,EAC1Ed,GAAA,CAAIsB,IAAI;IAEZ;IAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;MACE,GAAGjB,MAAM;MACTQ;IACF,GACA;MACEJ,OAAA;MACAc,MAAA,EAAQjC,UAAA,CAAWkC;IACrB;EAEJ;EAEA,MAAMC,KAAA,GAAQpB,MAAA,CAAOW,IAAI,CAACJ,MAAM,GAAGP,MAAA,CAAOM,MAAM,CAACC,MAAM;EAEvD,MAAMC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC,6BAA6B;IACjDC,KAAA,EAAOV,MAAA,CAAOM,MAAM,CAACC,MAAM;IAC3BK,KAAA,EAAO5B,cAAA,CAAeQ,UAAA,CAAWqB,MAAM,CAACC,MAAM,CAACM,KAAA,KAAU,IAAI,aAAa,SAAS,EAAE3B,GAAA,CAAIsB,IAAI;IAC7FK;EACF;EAEA,OAAOJ,QAAA,CAASC,IAAI,CAClB;IACE,GAAGjB,MAAM;IACTQ;EACF,GACA;IACEJ,OAAA;IACAc,MAAA,EAAQjC,UAAA,CAAWoC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -35,7 +35,7 @@ export const update = async ({
|
|
|
35
35
|
if (result.errors.length === 0) {
|
|
36
36
|
const message = req.t('general:updatedCountSuccessfully', {
|
|
37
37
|
count: result.docs.length,
|
|
38
|
-
label: getTranslation(collection.config.labels[result.docs.length
|
|
38
|
+
label: getTranslation(collection.config.labels[result.docs.length === 1 ? 'singular' : 'plural'], req.i18n)
|
|
39
39
|
});
|
|
40
40
|
return Response.json({
|
|
41
41
|
...result,
|
|
@@ -48,7 +48,7 @@ export const update = async ({
|
|
|
48
48
|
const total = result.docs.length + result.errors.length;
|
|
49
49
|
const message = req.t('error:unableToUpdateCount', {
|
|
50
50
|
count: result.errors.length,
|
|
51
|
-
label: getTranslation(collection.config.labels[total
|
|
51
|
+
label: getTranslation(collection.config.labels[total === 1 ? 'singular' : 'plural'], req.i18n),
|
|
52
52
|
total
|
|
53
53
|
});
|
|
54
54
|
return Response.json({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","names":["getTranslation","httpStatus","sanitizePopulateParam","sanitizeSelectParam","updateOperation","isNumber","headersWithCors","update","collection","req","depth","draft","limit","overrideLock","populate","select","where","query","result","data","Number","undefined","Boolean","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/update.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { sanitizePopulateParam, sanitizeSelectParam, updateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const update: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, overrideLock, populate, select, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n where?: Where\n }\n\n const result = await updateOperation({\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n limit: isNumber(limit) ? Number(limit) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:updatedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length
|
|
1
|
+
{"version":3,"file":"update.js","names":["getTranslation","httpStatus","sanitizePopulateParam","sanitizeSelectParam","updateOperation","isNumber","headersWithCors","update","collection","req","depth","draft","limit","overrideLock","populate","select","where","query","result","data","Number","undefined","Boolean","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/update.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { sanitizePopulateParam, sanitizeSelectParam, updateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const update: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, overrideLock, populate, select, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n where?: Where\n }\n\n const result = await updateOperation({\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n limit: isNumber(limit) ? Number(limit) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:updatedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length === 1 ? 'singular' : 'plural'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n const message = req.t('error:unableToUpdateCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total === 1 ? 'singular' : 'plural'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,mBAAmB,EAAEC,eAAe,QAA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Ac,MAAA,EAAQpC,UAAA,CAAWqC;IACrB;EAEJ;EAEA,MAAMC,KAAA,GAAQrB,MAAA,CAAOY,IAAI,CAACJ,MAAM,GAAGR,MAAA,CAAOO,MAAM,CAACC,MAAM;EACvD,MAAMC,OAAA,GAAUlB,GAAA,CAAImB,CAAC,CAAC,6BAA6B;IACjDC,KAAA,EAAOX,MAAA,CAAOO,MAAM,CAACC,MAAM;IAC3BK,KAAA,EAAO/B,cAAA,CAAeQ,UAAA,CAAWwB,MAAM,CAACC,MAAM,CAACM,KAAA,KAAU,IAAI,aAAa,SAAS,EAAE9B,GAAA,CAAIyB,IAAI;IAC7FK;EACF;EAEA,OAAOJ,QAAA,CAASC,IAAI,CAClB;IACE,GAAGlB,MAAM;IACTS;EACF,GACA;IACEJ,OAAA;IACAc,MAAA,EAAQpC,UAAA,CAAWuC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeError.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/routeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGvF,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"routeError.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/routeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGvF,OAAO,EAAE,QAAQ,EAAsC,MAAM,SAAS,CAAA;AAKtE,eAAO,MAAM,UAAU,8DAKpB;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,GAAG,EAAE,QAAQ,CAAA;IACb,GAAG,EAAE,cAAc,GAAG,OAAO,CAAA;CAC9B,sBAkFA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
|
-
import { APIError, formatErrors, getPayload } from 'payload';
|
|
2
|
+
import { APIError, formatErrors, getPayload, logError } from 'payload';
|
|
3
3
|
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
4
|
import { mergeHeaders } from '../../utilities/mergeHeaders.js';
|
|
5
5
|
export const routeError = async ({
|
|
@@ -29,19 +29,14 @@ export const routeError = async ({
|
|
|
29
29
|
req
|
|
30
30
|
});
|
|
31
31
|
const {
|
|
32
|
-
config
|
|
33
|
-
logger
|
|
32
|
+
config
|
|
34
33
|
} = payload;
|
|
35
34
|
let response = formatErrors(err);
|
|
36
35
|
let status = err.status || httpStatus.INTERNAL_SERVER_ERROR;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} : {
|
|
42
|
-
err
|
|
43
|
-
});
|
|
44
|
-
}
|
|
36
|
+
logError({
|
|
37
|
+
err,
|
|
38
|
+
payload
|
|
39
|
+
});
|
|
45
40
|
// Internal server errors can contain anything, including potentially sensitive data.
|
|
46
41
|
// Therefore, error details will be hidden from the response unless `config.debug` is `true`
|
|
47
42
|
if (!config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeError.js","names":["httpStatus","APIError","formatErrors","getPayload","headersWithCors","mergeHeaders","routeError","collection","config","configArg","err","req","incomingReq","payload","e","Response","json","message","status","INTERNAL_SERVER_ERROR","headers","Headers","
|
|
1
|
+
{"version":3,"file":"routeError.js","names":["httpStatus","APIError","formatErrors","getPayload","logError","headersWithCors","mergeHeaders","routeError","collection","config","configArg","err","req","incomingReq","payload","e","Response","json","message","status","INTERNAL_SERVER_ERROR","headers","Headers","response","debug","stack","hooks","afterError","reduce","promise","hook","result","context","error","Promise","resolve","responseHeaders"],"sources":["../../../src/routes/rest/routeError.ts"],"sourcesContent":["import type { Collection, ErrorResult, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { APIError, formatErrors, getPayload, logError } from 'payload'\n\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { mergeHeaders } from '../../utilities/mergeHeaders.js'\n\nexport const routeError = async ({\n collection,\n config: configArg,\n err,\n req: incomingReq,\n}: {\n collection?: Collection\n config: Promise<SanitizedConfig> | SanitizedConfig\n err: APIError\n req: PayloadRequest | Request\n}) => {\n let payload = 'payload' in incomingReq && incomingReq?.payload\n\n if (!payload) {\n try {\n payload = await getPayload({ config: configArg })\n } catch (e) {\n return Response.json(\n {\n message: 'There was an error initializing Payload',\n },\n { status: httpStatus.INTERNAL_SERVER_ERROR },\n )\n }\n }\n\n const req = incomingReq as PayloadRequest\n\n req.payload = payload\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const { config } = payload\n\n let response = formatErrors(err)\n\n let status = err.status || httpStatus.INTERNAL_SERVER_ERROR\n\n logError({ err, payload })\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n response = formatErrors(new APIError('Something went wrong.'))\n }\n\n if (config.debug && config.debug === true) {\n response.stack = err.stack\n }\n\n if (collection) {\n await collection.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n collection: collection.config,\n context: req.context,\n error: err,\n req,\n result: response,\n })\n\n if (result) {\n response = (result.response as ErrorResult) || response\n status = result.status || status\n }\n }, Promise.resolve())\n }\n\n await config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n collection: collection?.config,\n context: req.context,\n error: err,\n req,\n result: response,\n })\n\n if (result) {\n response = (result.response as ErrorResult) || response\n status = result.status || status\n }\n }, Promise.resolve())\n\n return Response.json(response, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, headers) : headers,\n status,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;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{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Account/ResetPreferences/ConfirmResetModal/index.tsx"],"names":[],"mappings":"AAGA,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,IAAI,CAAA;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB,CA+BA,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Button, Modal, useModal, useTranslation } from '@payloadcms/ui';
|
|
6
|
+
const baseClass = 'reset-preferences-modal';
|
|
7
|
+
export const ConfirmResetModal = t0 => {
|
|
8
|
+
const $ = _c(11);
|
|
9
|
+
const {
|
|
10
|
+
slug,
|
|
11
|
+
onConfirm
|
|
12
|
+
} = t0;
|
|
13
|
+
const {
|
|
14
|
+
closeModal
|
|
15
|
+
} = useModal();
|
|
16
|
+
const {
|
|
17
|
+
t
|
|
18
|
+
} = useTranslation();
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[0] !== closeModal || $[1] !== slug) {
|
|
21
|
+
t1 = () => closeModal(slug);
|
|
22
|
+
$[0] = closeModal;
|
|
23
|
+
$[1] = slug;
|
|
24
|
+
$[2] = t1;
|
|
25
|
+
} else {
|
|
26
|
+
t1 = $[2];
|
|
27
|
+
}
|
|
28
|
+
const handleClose = t1;
|
|
29
|
+
let t2;
|
|
30
|
+
if ($[3] !== handleClose || $[4] !== onConfirm) {
|
|
31
|
+
t2 = () => {
|
|
32
|
+
handleClose();
|
|
33
|
+
if (typeof onConfirm === "function") {
|
|
34
|
+
onConfirm();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
$[3] = handleClose;
|
|
38
|
+
$[4] = onConfirm;
|
|
39
|
+
$[5] = t2;
|
|
40
|
+
} else {
|
|
41
|
+
t2 = $[5];
|
|
42
|
+
}
|
|
43
|
+
const handleConfirm = t2;
|
|
44
|
+
let t3;
|
|
45
|
+
if ($[6] !== handleClose || $[7] !== handleConfirm || $[8] !== slug || $[9] !== t) {
|
|
46
|
+
t3 = _jsx(Modal, {
|
|
47
|
+
className: baseClass,
|
|
48
|
+
slug,
|
|
49
|
+
children: _jsxs("div", {
|
|
50
|
+
className: `${baseClass}__wrapper`,
|
|
51
|
+
children: [_jsxs("div", {
|
|
52
|
+
className: `${baseClass}__content`,
|
|
53
|
+
children: [_jsxs("h1", {
|
|
54
|
+
children: [t("general:resetPreferences"), "?"]
|
|
55
|
+
}), _jsx("p", {
|
|
56
|
+
children: t("general:resetPreferencesDescription")
|
|
57
|
+
})]
|
|
58
|
+
}), _jsxs("div", {
|
|
59
|
+
className: `${baseClass}__controls`,
|
|
60
|
+
children: [_jsx(Button, {
|
|
61
|
+
buttonStyle: "secondary",
|
|
62
|
+
onClick: handleClose,
|
|
63
|
+
size: "large",
|
|
64
|
+
children: t("general:cancel")
|
|
65
|
+
}), _jsx(Button, {
|
|
66
|
+
onClick: handleConfirm,
|
|
67
|
+
size: "large",
|
|
68
|
+
children: t("general:confirm")
|
|
69
|
+
})]
|
|
70
|
+
})]
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
$[6] = handleClose;
|
|
74
|
+
$[7] = handleConfirm;
|
|
75
|
+
$[8] = slug;
|
|
76
|
+
$[9] = t;
|
|
77
|
+
$[10] = t3;
|
|
78
|
+
} else {
|
|
79
|
+
t3 = $[10];
|
|
80
|
+
}
|
|
81
|
+
return t3;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","Button","Modal","useModal","useTranslation","baseClass","ConfirmResetModal","t0","$","slug","onConfirm","closeModal","t","t1","handleClose","t2","handleConfirm","t3","_jsx","className","children","_jsxs","buttonStyle","onClick","size"],"sources":["../../../../../src/views/Account/ResetPreferences/ConfirmResetModal/index.tsx"],"sourcesContent":["'use client'\nimport { Button, Modal, useModal, useTranslation } from '@payloadcms/ui'\n\nimport './index.scss'\n\nconst baseClass = 'reset-preferences-modal'\n\nexport const ConfirmResetModal: React.FC<{\n readonly onConfirm: () => void\n readonly slug: string\n}> = ({ slug, onConfirm }) => {\n const { closeModal } = useModal()\n const { t } = useTranslation()\n\n const handleClose = () => closeModal(slug)\n\n const handleConfirm = () => {\n handleClose()\n if (typeof onConfirm === 'function') {\n onConfirm()\n }\n }\n\n return (\n <Modal className={baseClass} slug={slug}>\n <div className={`${baseClass}__wrapper`}>\n <div className={`${baseClass}__content`}>\n <h1>{t('general:resetPreferences')}?</h1>\n <p>{t('general:resetPreferencesDescription')}</p>\n </div>\n <div className={`${baseClass}__controls`}>\n <Button buttonStyle=\"secondary\" onClick={handleClose} size=\"large\">\n {t('general:cancel')}\n </Button>\n <Button onClick={handleConfirm} size=\"large\">\n {t('general:confirm')}\n </Button>\n </div>\n </div>\n </Modal>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,cAAc,QAAQ;AAIxD,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,iBAAA,GAGRC,EAAA;EAAA,MAAAC,CAAA,GAAAR,EAAA;EAAC;IAAAS,IAAA;IAAAC;EAAA,IAAAH,EAAmB;EACvB;IAAAI;EAAA,IAAuBR,QAAA;EACvB;IAAAS;EAAA,IAAcR,cAAA;EAAA,IAAAS,EAAA;EAAA,IAAAL,CAAA,QAAAG,UAAA,IAAAH,CAAA,QAAAC,IAAA;IAEMI,EAAA,GAAAA,CAAA,KAAMF,UAAA,CAAWF,IAAA;IAAAD,CAAA,MAAAG,UAAA;IAAAH,CAAA,MAAAC,IAAA;IAAAD,CAAA,MAA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AAA,C;;;;;;;;;;;;SAXXK,E;CAiBJ","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import '../../../../scss/styles.scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.reset-preferences-modal {
|
|
5
|
+
@include blur-bg;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
height: 100%;
|
|
10
|
+
|
|
11
|
+
&__wrapper {
|
|
12
|
+
z-index: 1;
|
|
13
|
+
position: relative;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: base(2);
|
|
17
|
+
padding: base(2);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__content {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: base(1);
|
|
24
|
+
|
|
25
|
+
> * {
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&__controls {
|
|
31
|
+
display: flex;
|
|
32
|
+
gap: base(0.4);
|
|
33
|
+
|
|
34
|
+
.btn {
|
|
35
|
+
margin: 0;
|
|
36
|
+
margin-block: 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/ResetPreferences/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAUnC,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CACrB,CA6DA,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Button, LoadingOverlay, toast, useModal, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import * as qs from 'qs-esm';
|
|
6
|
+
import { Fragment, useCallback, useState } from 'react';
|
|
7
|
+
import { ConfirmResetModal } from './ConfirmResetModal/index.js';
|
|
8
|
+
const confirmResetModalSlug = 'confirm-reset-modal';
|
|
9
|
+
export const ResetPreferences = ({
|
|
10
|
+
apiRoute,
|
|
11
|
+
user
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
openModal
|
|
15
|
+
} = useModal();
|
|
16
|
+
const {
|
|
17
|
+
t
|
|
18
|
+
} = useTranslation();
|
|
19
|
+
const [loading, setLoading] = useState(false);
|
|
20
|
+
const handleResetPreferences = useCallback(async () => {
|
|
21
|
+
if (!user || loading) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
setLoading(true);
|
|
25
|
+
const stringifiedQuery = qs.stringify({
|
|
26
|
+
depth: 0,
|
|
27
|
+
where: {
|
|
28
|
+
user: {
|
|
29
|
+
id: {
|
|
30
|
+
equals: user.id
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
addQueryPrefix: true
|
|
36
|
+
});
|
|
37
|
+
try {
|
|
38
|
+
const res = await fetch(`${apiRoute}/payload-preferences${stringifiedQuery}`, {
|
|
39
|
+
credentials: 'include',
|
|
40
|
+
headers: {
|
|
41
|
+
'Content-Type': 'application/json'
|
|
42
|
+
},
|
|
43
|
+
method: 'DELETE'
|
|
44
|
+
});
|
|
45
|
+
const json = await res.json();
|
|
46
|
+
const message = json.message;
|
|
47
|
+
if (res.ok) {
|
|
48
|
+
toast.success(message);
|
|
49
|
+
} else {
|
|
50
|
+
toast.error(message);
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
// swallow error
|
|
54
|
+
} finally {
|
|
55
|
+
setLoading(false);
|
|
56
|
+
}
|
|
57
|
+
}, [apiRoute, loading, user]);
|
|
58
|
+
return /*#__PURE__*/_jsxs(Fragment, {
|
|
59
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
60
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
61
|
+
buttonStyle: "secondary",
|
|
62
|
+
onClick: () => openModal(confirmResetModalSlug),
|
|
63
|
+
children: t('general:resetPreferences')
|
|
64
|
+
})
|
|
65
|
+
}), /*#__PURE__*/_jsx(ConfirmResetModal, {
|
|
66
|
+
onConfirm: handleResetPreferences,
|
|
67
|
+
slug: confirmResetModalSlug
|
|
68
|
+
}), loading && /*#__PURE__*/_jsx(LoadingOverlay, {
|
|
69
|
+
loadingText: t('general:resettingPreferences')
|
|
70
|
+
})]
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Button","LoadingOverlay","toast","useModal","useTranslation","qs","Fragment","useCallback","useState","ConfirmResetModal","confirmResetModalSlug","ResetPreferences","apiRoute","user","openModal","t","loading","setLoading","handleResetPreferences","stringifiedQuery","stringify","depth","where","id","equals","addQueryPrefix","res","fetch","credentials","headers","method","json","message","ok","success","error","e","_jsxs","_jsx","buttonStyle","onClick","onConfirm","slug","loadingText"],"sources":["../../../../src/views/Account/ResetPreferences/index.tsx"],"sourcesContent":["'use client'\nimport type { User } from 'payload'\n\nimport { Button, LoadingOverlay, toast, useModal, useTranslation } from '@payloadcms/ui'\nimport * as qs from 'qs-esm'\nimport { Fragment, useCallback, useState } from 'react'\n\nimport { ConfirmResetModal } from './ConfirmResetModal/index.js'\n\nconst confirmResetModalSlug = 'confirm-reset-modal'\n\nexport const ResetPreferences: React.FC<{\n readonly apiRoute: string\n readonly user?: User\n}> = ({ apiRoute, user }) => {\n const { openModal } = useModal()\n const { t } = useTranslation()\n\n const [loading, setLoading] = useState(false)\n\n const handleResetPreferences = useCallback(async () => {\n if (!user || loading) {\n return\n }\n setLoading(true)\n\n const stringifiedQuery = qs.stringify(\n {\n depth: 0,\n where: {\n user: {\n id: {\n equals: user.id,\n },\n },\n },\n },\n { addQueryPrefix: true },\n )\n\n try {\n const res = await fetch(`${apiRoute}/payload-preferences${stringifiedQuery}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'DELETE',\n })\n\n const json = await res.json()\n const message = json.message\n\n if (res.ok) {\n toast.success(message)\n } else {\n toast.error(message)\n }\n } catch (e) {\n // swallow error\n } finally {\n setLoading(false)\n }\n }, [apiRoute, loading, user])\n\n return (\n <Fragment>\n <div>\n <Button buttonStyle=\"secondary\" onClick={() => openModal(confirmResetModalSlug)}>\n {t('general:resetPreferences')}\n </Button>\n </div>\n <ConfirmResetModal onConfirm={handleResetPreferences} slug={confirmResetModalSlug} />\n {loading && <LoadingOverlay loadingText={t('general:resettingPreferences')} />}\n </Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,cAAc,QAAQ;AACxE,YAAYC,EAAA,MAAQ;AACpB,SAASC,QAAQ,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAEhD,SAASC,iBAAiB,QAAQ;AAElC,MAAMC,qBAAA,GAAwB;AAE9B,OAAO,MAAMC,gBAAA,GAGRA,CAAC;EAAEC,QAAQ;EAAEC;AAAI,CAAE;EACtB,MAAM;IAAEC;EAAS,CAAE,GAAGX,QAAA;EACtB,MAAM;IAAEY;EAAC,CAAE,GAAGX,cAAA;EAEd,MAAM,CAACY,OAAA,EAASC,UAAA,CAAW,GAAGT,QAAA,CAAS;EAEvC,MAAMU,sBAAA,GAAyBX,WAAA,CAAY;IACzC,IAAI,CAACM,IAAA,IAAQG,OAAA,EAAS;MACpB;IACF;IACAC,UAAA,CAAW;IAEX,MAAME,gBAAA,GAAmBd,EAAA,CAAGe,SAAS,CACnC;MACEC,KAAA,EAAO;MACPC,KAAA,EAAO;QACLT,IAAA,EAAM;UACJU,EAAA,EAAI;YACFC,MAAA,EAAQX,IAAA,CAAKU;UACf;QACF;MACF;IACF,GACA;MAAEE,cAAA,EAAgB;IAAK;IAGzB,IAAI;MACF,MAAMC,GAAA,GAAM,MAAMC,KAAA,CAAM,GAAGf,QAAA,uBAA+BO,gBAAA,EAAkB,EAAE;QAC5ES,WAAA,EAAa;QACbC,OAAA,EAAS;UACP,gBAAgB;QAClB;QACAC,MAAA,EAAQ;MACV;MAEA,MAAMC,IAAA,GAAO,MAAML,GAAA,CAAIK,IAAI;MAC3B,MAAMC,OAAA,GAAUD,IAAA,CAAKC,OAAO;MAE5B,IAAIN,GAAA,CAAIO,EAAE,EAAE;QACV/B,KAAA,CAAMgC,OAAO,CAACF,OAAA;MAChB,OAAO;QACL9B,KAAA,CAAMiC,KAAK,CAACH,OAAA;MACd;IACF,EAAE,OAAOI,CAAA,EAAG;MACV;IAAA,CACF,SAAU;MACRnB,UAAA,CAAW;IACb;EACF,GAAG,CAACL,QAAA,EAAUI,OAAA,EAASH,IAAA,CAAK;EAE5B,oBACEwB,KAAA,CAAC/B,QAAA;4BACCgC,IAAA,CAAC;gBACC,aAAAA,IAAA,CAACtC,MAAA;QAAOuC,WAAA,EAAY;QAAYC,OAAA,EAASA,CAAA,KAAM1B,SAAA,CAAUJ,qBAAA;kBACtDK,CAAA,CAAE;;qBAGPuB,IAAA,CAAC7B,iBAAA;MAAkBgC,SAAA,EAAWvB,sBAAA;MAAwBwB,IAAA,EAAMhC;QAC3DM,OAAA,iBAAWsB,IAAA,CAACrC,cAAA;MAAe0C,WAAA,EAAa5B,CAAA,CAAE;;;AAGjD","ignoreList":[]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { I18n } from '@payloadcms/translations';
|
|
2
|
-
import type { Config, LanguageOptions } from 'payload';
|
|
2
|
+
import type { BasePayload, Config, LanguageOptions, User } from 'payload';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import './index.scss';
|
|
5
5
|
export declare const Settings: React.FC<{
|
|
6
6
|
readonly className?: string;
|
|
7
7
|
readonly i18n: I18n;
|
|
8
8
|
readonly languageOptions: LanguageOptions;
|
|
9
|
+
readonly payload: BasePayload;
|
|
9
10
|
readonly theme: Config['admin']['theme'];
|
|
11
|
+
readonly user?: User;
|
|
10
12
|
}>;
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/Settings/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Account/Settings/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAGzE,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAMrB,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAA;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CACrB,CAgBA,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { FieldLabel } from '@payloadcms/ui';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { ResetPreferences } from '../ResetPreferences/index.js';
|
|
4
5
|
import { ToggleTheme } from '../ToggleTheme/index.js';
|
|
5
6
|
import { LanguageSelector } from './LanguageSelector.js';
|
|
6
7
|
const baseClass = 'payload-settings';
|
|
@@ -9,8 +10,11 @@ export const Settings = props => {
|
|
|
9
10
|
className,
|
|
10
11
|
i18n,
|
|
11
12
|
languageOptions,
|
|
12
|
-
|
|
13
|
+
payload,
|
|
14
|
+
theme,
|
|
15
|
+
user
|
|
13
16
|
} = props;
|
|
17
|
+
const apiRoute = payload.config.routes.api;
|
|
14
18
|
return /*#__PURE__*/_jsxs("div", {
|
|
15
19
|
className: [baseClass, className].filter(Boolean).join(' '),
|
|
16
20
|
children: [/*#__PURE__*/_jsx("h3", {
|
|
@@ -23,7 +27,10 @@ export const Settings = props => {
|
|
|
23
27
|
}), /*#__PURE__*/_jsx(LanguageSelector, {
|
|
24
28
|
languageOptions: languageOptions
|
|
25
29
|
})]
|
|
26
|
-
}), theme === 'all' && /*#__PURE__*/_jsx(ToggleTheme, {})
|
|
30
|
+
}), theme === 'all' && /*#__PURE__*/_jsx(ToggleTheme, {}), /*#__PURE__*/_jsx(ResetPreferences, {
|
|
31
|
+
apiRoute: apiRoute,
|
|
32
|
+
user: user
|
|
33
|
+
})]
|
|
27
34
|
});
|
|
28
35
|
};
|
|
29
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["FieldLabel","React","ToggleTheme","LanguageSelector","baseClass","Settings","props","className","i18n","languageOptions","theme","_jsxs","filter","Boolean","join","_jsx","t","htmlFor","label"],"sources":["../../../../src/views/Account/Settings/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Config, LanguageOptions } from 'payload'\n\nimport { FieldLabel } from '@payloadcms/ui'\nimport React from 'react'\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["FieldLabel","React","ResetPreferences","ToggleTheme","LanguageSelector","baseClass","Settings","props","className","i18n","languageOptions","payload","theme","user","apiRoute","config","routes","api","_jsxs","filter","Boolean","join","_jsx","t","htmlFor","label"],"sources":["../../../../src/views/Account/Settings/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { BasePayload, Config, LanguageOptions, User } from 'payload'\n\nimport { FieldLabel } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { ResetPreferences } from '../ResetPreferences/index.js'\nimport './index.scss'\nimport { ToggleTheme } from '../ToggleTheme/index.js'\nimport { LanguageSelector } from './LanguageSelector.js'\n\nconst baseClass = 'payload-settings'\n\nexport const Settings: React.FC<{\n readonly className?: string\n readonly i18n: I18n\n readonly languageOptions: LanguageOptions\n readonly payload: BasePayload\n readonly theme: Config['admin']['theme']\n readonly user?: User\n}> = (props) => {\n const { className, i18n, languageOptions, payload, theme, user } = props\n\n const apiRoute = payload.config.routes.api\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <h3>{i18n.t('general:payloadSettings')}</h3>\n <div className={`${baseClass}__language`}>\n <FieldLabel htmlFor=\"language-select\" label={i18n.t('general:language')} />\n <LanguageSelector languageOptions={languageOptions} />\n </div>\n {theme === 'all' && <ToggleTheme />}\n <ResetPreferences apiRoute={apiRoute} user={user} />\n </div>\n )\n}\n"],"mappings":";AAGA,SAASA,UAAU,QAAQ;AAC3B,OAAOC,KAAA,MAAW;AAElB,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,gBAAgB,QAAQ;AAEjC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,QAAA,GAOPC,KAAA;EACJ,MAAM;IAAEC,SAAS;IAAEC,IAAI;IAAEC,eAAe;IAAEC,OAAO;IAAEC,KAAK;IAAEC;EAAI,CAAE,GAAGN,KAAA;EAEnE,MAAMO,QAAA,GAAWH,OAAA,CAAQI,MAAM,CAACC,MAAM,CAACC,GAAG;EAE1C,oBACEC,KAAA,CAAC;IAAIV,SAAA,EAAW,CAACH,SAAA,EAAWG,SAAA,CAAU,CAACW,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;4BAC1DC,IAAA,CAAC;gBAAIb,IAAA,CAAKc,CAAC,CAAC;qBACZL,KAAA,CAAC;MAAIV,SAAA,EAAW,GAAGH,SAAA,YAAqB;8BACtCiB,IAAA,CAACtB,UAAA;QAAWwB,OAAA,EAAQ;QAAkBC,KAAA,EAAOhB,IAAA,CAAKc,CAAC,CAAC;uBACpDD,IAAA,CAAClB,gBAAA;QAAiBM,eAAA,EAAiBA;;QAEpCE,KAAA,KAAU,sBAASU,IAAA,CAACnB,WAAA,O,aACrBmB,IAAA,CAACpB,gBAAA;MAAiBY,QAAA,EAAUA,QAAA;MAAUD,IAAA,EAAMA;;;AAGlD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEnD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEnD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAwJ5C,CAAA"}
|
|
@@ -51,6 +51,7 @@ export const Account = async ({
|
|
|
51
51
|
collectionSlug: collectionConfig.slug,
|
|
52
52
|
locale,
|
|
53
53
|
payload,
|
|
54
|
+
req,
|
|
54
55
|
user
|
|
55
56
|
});
|
|
56
57
|
if (!data) {
|
|
@@ -119,7 +120,9 @@ export const Account = async ({
|
|
|
119
120
|
AfterFields: /*#__PURE__*/_jsx(Settings, {
|
|
120
121
|
i18n: i18n,
|
|
121
122
|
languageOptions: languageOptions,
|
|
122
|
-
|
|
123
|
+
payload: payload,
|
|
124
|
+
theme: theme,
|
|
125
|
+
user: user
|
|
123
126
|
}),
|
|
124
127
|
apiURL: `${serverURL}${api}/${userSlug}${user?.id ? `/${user.id}` : ''}`,
|
|
125
128
|
collectionSlug: userSlug,
|