Skip to content

Commit

Permalink
chore: upgrade something
Browse files Browse the repository at this point in the history
  • Loading branch information
sobird committed Nov 18, 2024
1 parent 2737c8b commit f736fc7
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 48 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ module.exports = {
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
'react/prop-types': ['off', {
ignore: [],
customValidators: [],
skipUndeclared: false,
}],
},
};
6 changes: 3 additions & 3 deletions app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ interface PaginationSearchParams {

type DeepPartial<T> = Partial<{ [P in keyof T]: DeepPartial<T[P]> }>;

declare type IAppPage<SearchParams = {}, Params = {}> = import('next').NextPage<{
params: Params;
searchParams: SearchParams;
declare type AppPage<Params = {}, SearchParams = {}> = import('next').NextPage<{
params: Promise<Params>;
searchParams: Promise<SearchParams>;
}>;

/**
Expand Down
16 changes: 11 additions & 5 deletions app/(authentication)/signin/verify/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
*
* sobird<i@sobird.me> at 2023/11/29 22:38:08 created.
*/
import Image from 'next/image';
import { Metadata } from 'next';
import { Result, Button } from 'antd';
import mix from '@/assets/mix.svg';
import { Metadata } from 'next';

import { getEmailLoginUrl } from '@/utils/emailLogin';

import styles from './page.module.scss';

export const metadata: Metadata = {
title: '登录电子邮箱',
};

export default function Home({ searchParams }: any) {
const emailLoginUrl = getEmailLoginUrl(decodeURIComponent(searchParams.email));
interface SearchParams {
email: string;
}

export default async function Home({ searchParams }: { searchParams: Promise<SearchParams> }) {
const { email } = await searchParams;

const emailLoginUrl = getEmailLoginUrl(decodeURIComponent(email));
return (
<div>
<Result
Expand Down
15 changes: 7 additions & 8 deletions app/dashboard/role/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
* sobird<i@sobird.me> at 2023/12/08 22:40:59 created.
*/

import { NextPage } from 'next';
import React from 'react';
import RoleForm from '../../components/role-form';

import { updateRoleAction } from '@/actions/role';
import { RoleModel } from '@/models';

interface RoleEditPageProps {
params: {
id: string;
};
import RoleForm from '../../components/role-form';

interface Params {
id: string;
}

const Page: NextPage<RoleEditPageProps> = async ({ params }) => {
const { id } = params;
const Page: AppPage<Params> = async ({ params }) => {
const { id } = await params;

const role = await RoleModel.findOne({
where: {
Expand Down
11 changes: 7 additions & 4 deletions app/dashboard/role/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ export const metadata: Metadata = {
title: '角色管理',
};

type IRoleAppPage = IAppPage<PaginationSearchParams>;

const RoleFormModal = withActionFormModal(RoleForm, { title: '创建角色' });

const RolePage: IRoleAppPage = async ({ searchParams }) => {
const rolesWithPage = await RoleModel.findManyByPage(searchParams);
interface SearchParams extends PaginationSearchParams {
//
}

const RolePage: AppPage<{}, SearchParams> = async ({ searchParams }) => {
const { pn, ps } = await searchParams;
const rolesWithPage = await RoleModel.findManyByPage({ pn, ps });

return (
<div>
Expand Down
7 changes: 4 additions & 3 deletions app/dashboard/role/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

'use client';

import { FC } from 'react';
import { Button, Table, Modal } from 'antd';
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
import Link from 'next/link';
import { RoleModel, RoleAttributes } from '@/models';
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
import { FC } from 'react';

import { deleteRoleAction } from '@/actions/role';
import { RoleModel, RoleAttributes } from '@/models';

type RoleTableData = Awaited<ReturnType<typeof RoleModel.findManyByPage<RoleModel>>>;

Expand Down
14 changes: 6 additions & 8 deletions app/dashboard/user/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
* sobird<i@sobird.me> at 2023/12/08 22:40:59 created.
*/

import { NextPage } from 'next';
import { notFound } from 'next/navigation';
import React from 'react';
import UserForm from '@/app/dashboard/user/components/user-form';

import { updateUserAction } from '@/actions/user';
import UserForm from '@/app/dashboard/user/components/user-form';
import { UserModel, RoleModel } from '@/models';

interface UserEditPageProps {
params: {
id: string;
};
interface UserEditPageParams {
id: string;
}

const UserEditPage: NextPage<UserEditPageProps> = async ({ params }) => {
const { id } = params;
const UserEditPage: AppPage<UserEditPageParams> = async ({ params }) => {
const { id } = await params;

const user = await UserModel.findOne({
where: {
Expand Down
14 changes: 9 additions & 5 deletions app/dashboard/user/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@
* sobird<i@sobird.me> at 2023/12/05 15:10:21 created.
*/

import React from 'react';
import { Button } from 'antd';
import { Metadata } from 'next';
import Link from 'next/link';
import { Button } from 'antd';
import React from 'react';

import { UserModel } from '@/models';

import UserTable from './table';

export const metadata: Metadata = {
title: '用户管理',
};

type IUserAppPage = IAppPage<PaginationSearchParams>;
interface SearchParams extends PaginationSearchParams {
//
}

const UserPage: IUserAppPage = async ({ searchParams }) => {
const userWithPage = await UserModel.findManyByPage(searchParams);
const UserPage: AppPage<{}, SearchParams> = async ({ searchParams }) => {
const userWithPage = await UserModel.findManyByPage(await searchParams);

return (
<div>
Expand Down
7 changes: 4 additions & 3 deletions app/dashboard/user/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

'use client';

import { FC } from 'react';
import {
Button, Table, Modal, Switch,
} from 'antd';
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
import Link from 'next/link';
import { UserModel, UserAttributes } from '@/models';
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
import { FC } from 'react';

import { deleteUserAction } from '@/actions/user';
import { UserModel, UserAttributes } from '@/models';

type UserTableData = Awaited<ReturnType<typeof UserModel.findManyByPage<UserModel>>>;

Expand Down
2 changes: 1 addition & 1 deletion components/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* sobird<i@sobird.me> at 2023/10/05 23:50:18 created.
*/

import React, { ComponentProps } from 'react';
import { Table } from 'antd';
import { useSearchParams } from 'next/navigation';
import React, { ComponentProps } from 'react';

const MTable: React.FC<ComponentProps<typeof Table>> = ({ children, pagination, ...props }) => {
const [searchParamPn, setSearchParamPn] = useSearchParamsState('pn', '1');
Expand Down
2 changes: 1 addition & 1 deletion hooks/useSearchParamsState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* sobird<i@sobird.me> at 2023/10/05 10:13:44 created.
*/

import { useEffect } from 'react';
import { useSearchParams } from 'next/navigation';
import { useEffect } from 'react';

let singletonSearchParams = null;

Expand Down
16 changes: 9 additions & 7 deletions lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@
*/

/* eslint-disable no-param-reassign */
import { GetServerSidePropsContext, NextApiRequest, NextApiResponse } from 'next';
import { cookies } from 'next/headers';
import {
getServerSession, type AuthOptions,
} from 'next-auth';
import { encode, getToken } from 'next-auth/jwt';
import { v4 as uuidv4 } from 'uuid';
import CredentialsProvider from 'next-auth/providers/credentials';
import EmailProvider from 'next-auth/providers/email';
import { GetServerSidePropsContext, NextApiRequest, NextApiResponse } from 'next';
import { cookies } from 'next/headers';
import { sendVerificationRequest } from './mailer';
import AuthAdapter from './authSequelizeAdapter';
import { v4 as uuidv4 } from 'uuid';

import User from '@/models/user';

import AuthAdapter from './authSequelizeAdapter';
import { sendVerificationRequest } from './mailer';

// const cookiesOptions: Partial<CookiesOptions> = {
// sessionToken: {
// name: 'next-auth.session-token',
Expand Down Expand Up @@ -203,10 +205,10 @@ export function getServerAuthSession(...args: [GetServerSidePropsContext['req'],
return getServerSession(...args, authOptions);
}

export function getServerAuthToken() {
export async function getServerAuthToken() {
return getToken({
req: {
cookies: cookies(),
cookies: await cookies(),
} as any,
});
}

0 comments on commit f736fc7

Please sign in to comment.