Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update packages #293

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@ ARGON_SECRET=topsecret
NEXTAUTH_SECRET=topsecret
NEXTAUTH_URL=http://localhost:3000

KV_REST_API_URL=
KV_REST_API_TOKEN=

# NOTE: The DB/USER/PASSWORD need to be the same with docker-compose values
POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_URL_NON_POOLING="${POSTGRES_URL}"
POSTGRES_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?schema=public"
POSTGRES_PRISMA_URL="${POSTGRES_URL}?pgbouncer=true&connect_timeout=15"

NEXT_PUBLIC_API_KEY_TINYMCE=""
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?schema=public"

EMAIL_SERVER_USER= # your email
EMAIL_SERVER_PASSWORD= # your password
EMAIL_SERVER_HOST= #smtp.gmail.com
EMAIL_SERVER_PORT= #465
SENDGRID_API_KEY=
6 changes: 3 additions & 3 deletions .github/workflows/code-checking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
with:
version: 8

- name: Setup Node.js environment
Expand All @@ -33,7 +33,7 @@ jobs:
run: pnpm i --frozen-lockfile

- name: Linting
run: pnpm run lint
run: pnpm lint

- name: Checking TypeScript
run: pnpm run typecheck
run: pnpm typecheck
5 changes: 2 additions & 3 deletions .github/workflows/prisma-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
run: pnpm i --frozen-lockfile

- name: Deploy Migrations
run: pnpm run migrate:deploy
run: pnpm migrate deploy
env:
POSTGRES_PRISMA_URL: ${{ secrets.POSTGRES_PRISMA_URL_PREVIEW }}
POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING_PREVIEW }}
DATABASE_URL: ${{ secrets.DATABASE_URL_PREVIEW }}
5 changes: 2 additions & 3 deletions .github/workflows/prisma-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
run: pnpm i --frozen-lockfile

- name: Deploy Migrations
run: pnpm run migrate:deploy
run: pnpm prisma migrate deploy
env:
POSTGRES_PRISMA_URL: ${{ secrets.POSTGRES_PRISMA_URL }}
POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Ninjutsu Stack
<h1 align="center">Ninjutsu Stack</h1>

The stack that use Chakra
<p align="center">Made by ⚡Sieutoc</p>

<p align="center" width="100%">
<img src="https://i.imgflip.com/88o6pz.jpg" />
</p>

## Features

Expand All @@ -20,7 +24,7 @@ This template includes the following:

## Demo

https://ninjutsu-demo.vercel.app
https://ninjutsu.sieutoc.website


## Getting Started
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { redirect } from 'next/navigation';
import { Stack } from '@/components/chakra';
import { verifyResetPassword } from '@/services/users';
import { HOUR_MAX_CONFIRM } from '@/utils/constants';
import { Container } from '@/components/chakra';
import { Locale } from '@/types';
import { differenceInHours } from 'date-fns';
import { Stack } from '@/components/chakra';
import { redirect } from 'next/navigation';
import { Status } from './Status';
import { verifyResetPassword } from '@/services/users';
import { HOUR_MAX_CONFIRM } from '@/utils/constants';

type ConfirmResetPassFromEmailType = {
params: { locale: Locale };
searchParams: { code: string };
};
export default async function ConfirmResetPassFromEmail(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import { Box, Container, Heading } from '@/components/chakra';
import { HTMLParser } from '@/components/client';
import { getPage } from '@/services/pages';
import { redirect } from 'next/navigation';

export default async function DynamicPage({
params: { slug, locale },
params: { slug },
}: {
params: { slug: string; locale: string };
params: { slug: string };
}) {
const page = await getPage({ where: { slug } });

const foundTranslation = page?.translatedPages.find(
(p) => p.locale === locale
);

if (foundTranslation?.locale === locale) {
redirect(`/${locale}/${foundTranslation.slug}`);
} else if (page?.originalPage?.locale === locale) {
redirect(`/${locale}/${page?.originalPage.slug}`);
}

if (!page) {
// TODO: Make 404 display
return 'not found';
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default function BlogEditForm({ data }: BlogEditFormProps) {
content,
slug: slugify(title),
publishedAt,
locale: 'VI',
authorId: userID,
}),
});
Expand Down Expand Up @@ -100,7 +99,6 @@ export default function BlogEditForm({ data }: BlogEditFormProps) {
content,
slug: slugify(title),
publishedAt,
locale: 'VI',
authorId: userID,
}),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { Box, Heading, SimpleGrid, Spinner } from '@/components/chakra';
import { PostCard } from '@/components/client';
import { prisma } from '@/configs/prisma';
import { Locale, Metadata } from '@/types';
import { Metadata } from '@/types';

export const metadata: Metadata = {
title: 'Blog',
};

export default async function BlogsPage({
params: { locale },
}: {
params: { locale: Locale };
}) {
export default async function BlogsPage() {
const data = await prisma?.post.findMany({
where: { locale },
take: 25,
orderBy: { createdAt: 'desc' },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
} from '@/components/chakra';
import slugify from 'slugify';
import { useRouter, useSearchParams } from 'next/navigation';
import { useSWR, useAuth, useToast } from '@/hooks';
import { ChevronDownIcon, ChevronUpIcon } from '@/icons';
import { PostList, TextEditor } from '@/components/client';
import type { Post } from '@/types';
import { ChevronDownIcon, ChevronUpIcon } from '@/icons';
import { useSWR, useAuth, useToast } from '@/hooks';
import { Post } from '@/types';

type RequireInputType = {
[key: string]: string;
Expand Down Expand Up @@ -63,7 +63,6 @@ export default function BlogEditor() {
content,
slug: slugify(title),
publishedAt,
locale: 'VI',
authorId: userID,
}),
});
Expand Down Expand Up @@ -103,7 +102,6 @@ export default function BlogEditor() {
content,
slug: slugify(title),
publishedAt,
locale: 'VI',
authorId: userID,
}),
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 3 additions & 7 deletions app/[locale]/(custom)/layout.tsx → app/(custom)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import { LocaleSwitcher, Navbar } from '@/components/client';
import { Box, Container, Flex } from '@/components/chakra';
import { ProfileMenu } from '@/components/server';
import type { ReactNode, Locale } from '@/types';
import { Navbar } from '@/components/client';
import { ReactNode } from '@/types';

export default async function CustomLayout({
children,
}: {
children: ReactNode;
params: { locale: Locale };
}) {
return (
<Flex direction="column">
<Navbar>
<Flex gap={2} align="center">
<LocaleSwitcher />
<ProfileMenu />
</Flex>
<ProfileMenu />
</Navbar>

<Container
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions app/(custom)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default async function HomePage() {
return (
<section>
<div>
<h1>Ninjustsu Stack</h1>
<p>The stack that uses Chakra</p>
</div>
</section>
);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Box, Flex, Skeleton } from '@/components/chakra';
import { getPage } from '@/services/pages';

import { Box, Flex, Skeleton } from '@/components/chakra';
import { DeleteSection } from '../../components/PageForm/DeleteSection';
import { BasicSEO } from '../../components/BasicSEO';
import { BasicSEO, DeleteSection } from '../../components';

type AdvancedSettingsProps = {
params: { id: string };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
import { GoBackButton, SettingNav } from '@/components/client';
import { Box, Flex } from '@/components/chakra';
import type { ReactNode, Locale } from '@/types';

import { Translations } from '../components';
import { getPage } from '@/services/pages';
import { ReactNode } from '@/types';

export default async function EditPageLayout({
children,
params,
}: {
children: ReactNode;
params: { locale: Locale; id: string };
params: { id: string };
}) {
const page = await getPage({ where: { id: params.id } });

return (
<Flex direction="column" gap={2}>
<Flex direction="row" align="center" justify="space-between">
<GoBackButton path="/dashboard/pages">Back to Pages</GoBackButton>

{page && <Translations data={page} />}
</Flex>

<SettingNav
baseUrl={`/${params.locale}/dashboard/pages`}
baseUrl="/dashboard/pages"
nav={[
{
name: 'General',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getSession } from '@/configs/auth';
import { getPage } from '@/services/pages';
import { redirect } from 'next/navigation';
import { getPage } from '@/services/pages';

import { PageForm } from '../components';

Expand All @@ -27,7 +27,6 @@ export default async function EditPage({ params }: EditPageProps) {
backPath="/dashboard/pages"
title="Edit Page"
data={originalPage}
translatedPages={originalPage.translatedPages}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,33 @@ import {
Stack,
} from '@/components/chakra';
import { CustomEditable, FormWrapper, TextEditor } from '@/components/client';
import {
useAuth,
useEffect,
useLocale,
useRouter,
useState,
useToast,
} from '@/hooks';
import { useAuth, useEffect, useRouter, useState, useToast } from '@/hooks';
import { ArrowUpIcon, RepeatIcon } from '@/icons';
import { Page, PageWithPayload, Locale, HttpMethod } from '@/types';
import { Page, PageWithPayload, HttpMethod } from '@/types';
import { isEqual } from '@/utils/compare';
import { fetcher } from '@/utils/fetcher';
import slugify from 'slugify';

export * from './DeleteSection';

export type PageFormProps = {
title?: string;
backPath?: string;
data?: PageWithPayload;
translatedPages?: Page[];
originalId?: string;
translateTo?: Locale;
};

export const PageForm = ({
backPath,
title,
data: propsData,
translatedPages,
originalId,
translateTo,
}: PageFormProps) => {
export const PageForm = ({ data: propsData }: PageFormProps) => {
const toast = useToast();
const router = useRouter();
const { session } = useAuth();

const { currentLocale, defaultLocale } = useLocale();

const [isLoading, setIsLoading] = useState(false);

const initialData = {
id: propsData?.id ?? '',
title: propsData?.title ?? '',
slug: propsData?.slug ?? '',
content: propsData?.content ?? '',
locale: propsData?.locale ?? translateTo ?? currentLocale,
originalId: propsData?.originalId ?? originalId,
meta: propsData?.meta ?? {},
tags: propsData?.tags ?? [],
};
Expand Down Expand Up @@ -111,8 +92,6 @@ export const PageForm = ({
title,
slug,
content,
originalId,
locale: translateTo ?? defaultLocale,
authorId: session.user.id,
}),
});
Expand All @@ -134,8 +113,6 @@ export const PageForm = ({
<Stack direction="row" align="center"></Stack>
</Flex>

<Input type="hidden" name="locale" value={inputData.locale} />

<FormControl isDisabled={isLoading}>
<FormLabel>Title</FormLabel>
<Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

export * from './PageForm';
export * from './PagesTable';
export * from './Translations';
export * from './BasicSEO';
Loading