Skip to content

Commit

Permalink
Merge branch 'beta' into fix/init-page
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsfletch committed May 3, 2024
2 parents 561195b + 7ab156e commit 892dd6b
Show file tree
Hide file tree
Showing 133 changed files with 1,300 additions and 1,142 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "payload-monorepo",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"private": true,
"type": "module",
"scripts": {
Expand Down Expand Up @@ -154,7 +154,7 @@
"tempy": "^1.0.1",
"ts-node": "10.9.1",
"tsx": "^4.7.1",
"turbo": "^1.13.2",
"turbo": "^1.13.3",
"typescript": "5.4.5",
"uuid": "^9.0.1",
"yocto-queue": "^1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-payload-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-payload-app",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"homepage": "https://payloadcms.com",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/db-mongodb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-mongodb",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "The officially supported MongoDB database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/db-postgres/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-postgres",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "The officially supported Postgres database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/email-nodemailer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/email-nodemailer",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "Payload Nodemailer Email Adapter",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/email-resend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/email-resend",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "Payload Resend Email Adapter",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions packages/graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/graphql",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"homepage": "https://payloadcms.com",
"repository": {
"type": "git",
Expand Down Expand Up @@ -29,14 +29,14 @@
},
"dependencies": {
"graphql-scalars": "1.22.2",
"pluralize": "8.0.0"
"pluralize": "8.0.0",
"ts-essentials": "7.0.3"
},
"devDependencies": {
"@payloadcms/eslint-config": "workspace:*",
"@types/pluralize": "^0.0.33",
"graphql-http": "^1.22.0",
"payload": "workspace:*",
"ts-essentials": "7.0.3"
"payload": "workspace:*"
},
"peerDependencies": {
"graphql": "^16.8.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/next",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"homepage": "https://payloadcms.com",
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/routes/rest/buildFormState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ export const buildFormState = async ({ req }: { req: PayloadRequestWithData }) =
!req.payload.collections[collectionSlug].config.auth.disableLocalStrategy
) {
if (formState.password) result.password = formState.password
if (formState['confirm-password'])
result['confirm-password'] = formState['confirm-password']
if (formState.email) result.email = formState.email
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/utilities/initPage/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export const isAdminRoute = (route: string, adminRoute: string) => {
}

export const isAdminAuthRoute = (route: string, adminRoute: string) => {
return authRoutes.some((r) => r === route.replace(adminRoute, ''))
return authRoutes.some((r) => route.replace(adminRoute, '').startsWith(r))
}
103 changes: 103 additions & 0 deletions packages/next/src/views/ResetPassword/index.client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
'use client'
import type { FormState } from 'payload/types'

import { ConfirmPassword } from '@payloadcms/ui/fields/ConfirmPassword'
import { HiddenInput } from '@payloadcms/ui/fields/HiddenInput'
import { Password } from '@payloadcms/ui/fields/Password'
import { Form, useFormFields } from '@payloadcms/ui/forms/Form'
import { FormSubmit } from '@payloadcms/ui/forms/Submit'
import { useAuth } from '@payloadcms/ui/providers/Auth'
import { useConfig } from '@payloadcms/ui/providers/Config'
import { useTranslation } from '@payloadcms/ui/providers/Translation'
import { useRouter } from 'next/navigation.js'
import React from 'react'
import { toast } from 'react-toastify'

type Args = {
token: string
}

const initialState: FormState = {
'confirm-password': {
initialValue: '',
valid: false,
value: '',
},
password: {
initialValue: '',
valid: false,
value: '',
},
}

export const ResetPasswordClient: React.FC<Args> = ({ token }) => {
const i18n = useTranslation()
const {
admin: { user: userSlug },
routes: { admin, api },
serverURL,
} = useConfig()

const history = useRouter()

const { fetchFullUser } = useAuth()

const onSuccess = React.useCallback(
async (data) => {
if (data.token) {
await fetchFullUser()
history.push(`${admin}`)
} else {
history.push(`${admin}/login`)
toast.success(i18n.t('general:updatedSuccessfully'), { autoClose: 3000 })
}
},
[fetchFullUser, history, admin, i18n],
)

return (
<Form
action={`${serverURL}${api}/${userSlug}/reset-password`}
initialState={initialState}
method="POST"
onSuccess={onSuccess}
>
<PasswordToConfirm />
<ConfirmPassword />
<HiddenInput forceUsePathFromProps name="token" value={token} />
<FormSubmit>{i18n.t('authentication:resetPassword')}</FormSubmit>
</Form>
)
}

const PasswordToConfirm = () => {
const { t } = useTranslation()
const { value: confirmValue } = useFormFields(([fields]) => {
return fields['confirm-password']
})

const validate = React.useCallback(
(value: string) => {
if (!value) {
return t('validation:required')
}

if (value === confirmValue) {
return true
}

return t('fields:passwordsDoNotMatch')
},
[confirmValue, t],
)

return (
<Password
autoComplete="off"
label={t('authentication:newPassword')}
name="password"
required
validate={validate}
/>
)
}
14 changes: 2 additions & 12 deletions packages/next/src/views/ResetPassword/index.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
.reset-password {
display: flex;
align-items: center;
flex-wrap: wrap;
min-height: 100vh;

&__wrap {
margin: 0 auto var(--base);
width: 100%;

svg {
width: 100%;
}
form > .field-type {
margin-bottom: var(--base);
}
}
41 changes: 6 additions & 35 deletions packages/next/src/views/ResetPassword/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ import type { AdminViewProps } from 'payload/types'

import { Button } from '@payloadcms/ui/elements/Button'
import { Translation } from '@payloadcms/ui/elements/Translation'
import { ConfirmPassword } from '@payloadcms/ui/fields/ConfirmPassword'
import { HiddenInput } from '@payloadcms/ui/fields/HiddenInput'
import { Password } from '@payloadcms/ui/fields/Password'
import { Form } from '@payloadcms/ui/forms/Form'
import { FormSubmit } from '@payloadcms/ui/forms/Submit'
import { MinimalTemplate } from '@payloadcms/ui/templates/Minimal'
import LinkImport from 'next/link.js'
import React from 'react'

import { ResetPasswordClient } from './index.client.js'
import './index.scss'

export const resetPasswordBaseClass = 'reset-password'
Expand All @@ -22,7 +18,9 @@ export { generateResetPasswordMetadata } from './meta.js'
export const ResetPassword: React.FC<AdminViewProps> = ({ initPageResult, params }) => {
const { req } = initPageResult

const { token } = params
const {
segments: [_, token],
} = params

const {
i18n,
Expand All @@ -31,21 +29,9 @@ export const ResetPassword: React.FC<AdminViewProps> = ({ initPageResult, params
} = req

const {
admin: { user: userSlug },
routes: { admin, api },
serverURL,
routes: { admin },
} = config

// const onSuccess = async (data) => {
// if (data.token) {
// await fetchFullUser()
// history.push(`${admin}`)
// } else {
// history.push(`${admin}/login`)
// toast.success(i18n.t('general:updatedSuccessfully'), { autoClose: 3000 })
// }
// }

if (user) {
return (
<MinimalTemplate className={resetPasswordBaseClass}>
Expand Down Expand Up @@ -73,22 +59,7 @@ export const ResetPassword: React.FC<AdminViewProps> = ({ initPageResult, params
<MinimalTemplate className={resetPasswordBaseClass}>
<div className={`${resetPasswordBaseClass}__wrap`}>
<h1>{i18n.t('authentication:resetPassword')}</h1>
<Form
action={`${serverURL}${api}/${userSlug}/reset-password`}
method="POST"
// onSuccess={onSuccess}
redirect={admin}
>
<Password
autoComplete="off"
label={i18n.t('authentication:newPassword')}
name="password"
required
/>
<ConfirmPassword />
<HiddenInput forceUsePathFromProps name="token" value={token} />
<FormSubmit>{i18n.t('authentication:resetPassword')}</FormSubmit>
</Form>
<ResetPasswordClient token={token} />
</div>
</MinimalTemplate>
)
Expand Down
6 changes: 3 additions & 3 deletions packages/payload/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "payload",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
"keywords": [
"admin panel",
Expand Down Expand Up @@ -115,6 +115,7 @@
"sanitize-filename": "1.6.3",
"scheduler": "0.23.0",
"scmp": "2.1.0",
"ts-essentials": "7.0.3",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand Down Expand Up @@ -158,8 +159,7 @@
"passport-strategy": "1.0.0",
"rimraf": "3.0.2",
"serve-static": "1.15.0",
"sharp": "0.32.6",
"ts-essentials": "7.0.3"
"sharp": "0.32.6"
},
"peerDependencies": {
"@swc/core": "^1.4.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-cloud-storage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-cloud-storage",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "The official cloud storage plugin for Payload CMS",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-cloud/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-cloud",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "The official Payload Cloud plugin",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-form-builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-form-builder",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "Form builder plugin for Payload CMS",
"keywords": [
"payload",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-nested-docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-nested-docs",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "The official Nested Docs plugin for Payload",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-redirects/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-redirects",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "Redirects plugin for Payload",
"keywords": [
"payload",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-search",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "Search plugin for Payload",
"keywords": [
"payload",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-seo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/plugin-seo",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"description": "SEO plugin for Payload",
"keywords": [
"payload",
Expand Down
Loading

0 comments on commit 892dd6b

Please sign in to comment.