├── public ├── banner.png ├── vercel.svg ├── window.svg ├── file.svg ├── globe.svg └── next.svg ├── src ├── app │ ├── guest │ │ ├── layout.tsx │ │ ├── menu │ │ │ ├── page.tsx │ │ │ ├── quantity.tsx │ │ │ └── menu-order.tsx │ │ └── orders │ │ │ ├── page.tsx │ │ │ └── orders-cart.tsx │ ├── favicon.ico │ ├── (public) │ │ ├── tables │ │ │ └── [number] │ │ │ │ ├── page.tsx │ │ │ │ └── guest-login-form.tsx │ │ ├── (auth) │ │ │ ├── login │ │ │ │ ├── page.tsx │ │ │ │ └── login-form.tsx │ │ │ ├── refresh-token │ │ │ │ └── page.tsx │ │ │ └── logout │ │ │ │ └── page.tsx │ │ ├── nav-items.tsx │ │ ├── layout.tsx │ │ └── page.tsx │ ├── api │ │ ├── revalidate │ │ │ └── route.ts │ │ ├── auth │ │ │ ├── logout │ │ │ │ └── route.ts │ │ │ ├── login │ │ │ │ └── route.ts │ │ │ └── refresh-token │ │ │ │ └── route.ts │ │ └── guest │ │ │ └── auth │ │ │ ├── logout │ │ │ └── route.ts │ │ │ ├── login │ │ │ └── route.ts │ │ │ └── refresh-token │ │ │ └── route.ts │ ├── manage │ │ ├── dashboard │ │ │ └── page.tsx │ │ ├── menuItems.ts │ │ ├── dishes │ │ │ └── page.tsx │ │ ├── tables │ │ │ ├── page.tsx │ │ │ └── add-table.tsx │ │ ├── accounts │ │ │ └── page.tsx │ │ ├── orders │ │ │ ├── page.tsx │ │ │ ├── table-skeleton.tsx │ │ │ ├── order.service.tsx │ │ │ └── order-guest-detail.tsx │ │ ├── setting │ │ │ ├── page.tsx │ │ │ ├── change-password-form.tsx │ │ │ └── update-profile-form.tsx │ │ ├── layout.tsx │ │ ├── mobile-nav-links.tsx │ │ ├── dropdown-avatar.tsx │ │ └── nav-links.tsx │ ├── layout.tsx │ └── globals.css ├── apis │ ├── revalidate.ts │ ├── media.ts │ ├── order.ts │ ├── table.ts │ ├── dish.ts │ ├── auth.ts │ ├── guest.ts │ └── account.ts ├── schemas │ ├── media.schema.ts │ ├── dish.schema.ts │ ├── auth.schema.ts │ ├── table.schema.ts │ ├── guest.schema.ts │ ├── order.schema.ts │ └── account.schema.ts ├── queries │ ├── useMedia.tsx │ ├── useAuth.tsx │ ├── useGuest.tsx │ ├── useOrder.tsx │ ├── useDish.tsx │ ├── useTable.tsx │ └── useAccount.tsx ├── lib │ ├── socket.ts │ ├── http.ts │ └── utils.ts ├── components │ ├── ui │ │ ├── skeleton.tsx │ │ ├── textarea.tsx │ │ ├── label.tsx │ │ ├── input.tsx │ │ ├── separator.tsx │ │ ├── sonner.tsx │ │ ├── switch.tsx │ │ ├── badge.tsx │ │ ├── tooltip.tsx │ │ ├── popover.tsx │ │ ├── avatar.tsx │ │ ├── button.tsx │ │ ├── card.tsx │ │ ├── pagination.tsx │ │ ├── table.tsx │ │ ├── dialog.tsx │ │ ├── form.tsx │ │ ├── alert-dialog.tsx │ │ ├── sheet.tsx │ │ ├── command.tsx │ │ └── select.tsx │ ├── theme-provider.tsx │ ├── refresh-token.tsx │ ├── dark-mode-toggle.tsx │ ├── generateQR.tsx │ ├── app-provider.tsx │ └── auto-pagination.tsx ├── types │ └── jwt.types.ts ├── config.ts ├── constants │ └── type.ts └── middleware.ts ├── postcss.config.mjs ├── next.config.ts ├── components.json ├── config.ts ├── eslint.config.mjs ├── .gitignore ├── tsconfig.json ├── LICENSE ├── tailwind.config.ts └── package.json /public/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ductaip/Restaurant-Management-System/HEAD/public/banner.png -------------------------------------------------------------------------------- /src/app/guest/layout.tsx: -------------------------------------------------------------------------------- 1 | import Layout from "@/app/(public)/layout"; 2 | 3 | export default Layout; 4 | -------------------------------------------------------------------------------- /src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ductaip/Restaurant-Management-System/HEAD/src/app/favicon.ico -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /postcss.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('postcss-load-config').Config} */ 2 | const config = { 3 | plugins: { 4 | tailwindcss: {}, 5 | }, 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /src/app/(public)/tables/[number]/page.tsx: -------------------------------------------------------------------------------- 1 | import GuestLoginForm from '@/app/(public)/tables/[number]/guest-login-form' 2 | 3 | export default function TableNumberPage() { 4 | return 5 | } 6 | -------------------------------------------------------------------------------- /src/apis/revalidate.ts: -------------------------------------------------------------------------------- 1 | import http from "@/lib/http"; 2 | 3 | const revalidateApi = (tag: string) => 4 | http.get(`/api/revalidate?tag=${tag}`, { 5 | baseUrl: "", 6 | }); 7 | 8 | export default revalidateApi; 9 | -------------------------------------------------------------------------------- /src/schemas/media.schema.ts: -------------------------------------------------------------------------------- 1 | import z from 'zod' 2 | 3 | export const UploadImageRes = z.object({ 4 | data: z.string(), 5 | message: z.string() 6 | }) 7 | 8 | export type UploadImageResType = z.TypeOf 9 | -------------------------------------------------------------------------------- /src/queries/useMedia.tsx: -------------------------------------------------------------------------------- 1 | import mediaApi from "@/apis/media" 2 | import { useMutation } from "@tanstack/react-query" 3 | 4 | export const useUploadMediaMutation = () => { 5 | return useMutation({ 6 | mutationFn: mediaApi.upload 7 | }) 8 | } -------------------------------------------------------------------------------- /src/apis/media.ts: -------------------------------------------------------------------------------- 1 | import http from "@/lib/http"; 2 | import { UploadImageResType } from "@/schemas/media.schema"; 3 | 4 | const mediaApi = { 5 | upload: (formData: FormData) => http.post('/media/upload', formData) 6 | } 7 | 8 | export default mediaApi -------------------------------------------------------------------------------- /src/app/guest/menu/page.tsx: -------------------------------------------------------------------------------- 1 | import MenuOrder from "./menu-order"; 2 | 3 | export default async function MenuPage() { 4 | return ( 5 |
6 |

🍕 Menu quán

7 | 8 |
9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /src/app/guest/orders/page.tsx: -------------------------------------------------------------------------------- 1 | import OrdersCart from "@/app/guest/orders/orders-cart"; 2 | 3 | export default function OrdersPage() { 4 | return ( 5 |
6 |

Đơn hàng

7 | 8 |
9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /src/app/api/revalidate/route.ts: -------------------------------------------------------------------------------- 1 | import type { NextRequest } from "next/server"; 2 | import { revalidateTag } from "next/cache"; 3 | 4 | export async function GET(request: NextRequest) { 5 | const tag = request.nextUrl.searchParams.get("tag"); 6 | revalidateTag(tag!); 7 | return Response.json({ revalidated: true, now: Date.now() }); 8 | } 9 | -------------------------------------------------------------------------------- /src/lib/socket.ts: -------------------------------------------------------------------------------- 1 | import envConfig from '@/config' 2 | import { getAccessTokenFromLocalStorage } from '@/lib/utils' 3 | import { io } from 'socket.io-client' 4 | 5 | const socket = io(envConfig.NEXT_PUBLIC_API_ENDPOINT, { 6 | auth: { 7 | Authorization: `Bearer ${getAccessTokenFromLocalStorage()}` 8 | } 9 | }) 10 | 11 | export default socket 12 | -------------------------------------------------------------------------------- /src/components/ui/skeleton.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from "@/lib/utils" 2 | 3 | function Skeleton({ 4 | className, 5 | ...props 6 | }: React.HTMLAttributes) { 7 | return ( 8 |
12 | ) 13 | } 14 | 15 | export { Skeleton } 16 | -------------------------------------------------------------------------------- /src/app/(public)/(auth)/login/page.tsx: -------------------------------------------------------------------------------- 1 | import LoginForm from '@/app/(public)/(auth)/login/login-form' 2 | import { Suspense } from 'react' 3 | 4 | export default function Login() { 5 | return ( 6 |
7 | 8 | 9 | 10 |
11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /src/components/theme-provider.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | import * as React from 'react' 4 | import { ThemeProvider as NextThemesProvider } from 'next-themes' 5 | import { ThemeProviderProps } from 'next-themes' 6 | 7 | export function ThemeProvider({ children, ...props }: ThemeProviderProps) { 8 | return {children} 9 | } 10 | -------------------------------------------------------------------------------- /src/queries/useAuth.tsx: -------------------------------------------------------------------------------- 1 | import authApi from "@/apis/auth" 2 | import { useMutation } from "@tanstack/react-query" 3 | 4 | export const useLoginMutation = () => { 5 | return useMutation({ 6 | mutationFn: authApi.login 7 | }) 8 | } 9 | 10 | export const useLogoutMutation = () => { 11 | return useMutation({ 12 | mutationFn: authApi.logout 13 | }) 14 | } -------------------------------------------------------------------------------- /public/window.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/file.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/types/jwt.types.ts: -------------------------------------------------------------------------------- 1 | import { Role, TokenType } from "@/constants/type"; 2 | 3 | export type TokenTypeValue = (typeof TokenType)[keyof typeof TokenType]; 4 | export type RoleType = (typeof Role)[keyof typeof Role]; 5 | export interface TokenPayload { 6 | userId: number; 7 | role: RoleType; 8 | tokenType: TokenTypeValue; 9 | exp: number; 10 | iat: number; 11 | } 12 | 13 | export interface TableTokenPayload { 14 | iat: number; 15 | number: number; 16 | tokenType: (typeof TokenType)["TableToken"]; 17 | } 18 | -------------------------------------------------------------------------------- /next.config.ts: -------------------------------------------------------------------------------- 1 | import type { NextConfig } from "next"; 2 | import envConfig from "./config"; 3 | 4 | const nextConfig: NextConfig = { 5 | /* config options here */ 6 | images: { 7 | remotePatterns: [ 8 | { 9 | protocol: "http", 10 | hostname: "localhost", 11 | port: "4000", 12 | pathname: "/**", 13 | search: "", 14 | }, 15 | { 16 | hostname: "via.placeholder.com", 17 | pathname: "/**", 18 | }, 19 | ], 20 | }, 21 | }; 22 | 23 | export default nextConfig; 24 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.ts", 8 | "css": "src/app/globals.css", 9 | "baseColor": "neutral", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils", 16 | "ui": "@/components/ui", 17 | "lib": "@/lib", 18 | "hooks": "@/hooks" 19 | }, 20 | "iconLibrary": "lucide" 21 | } 22 | -------------------------------------------------------------------------------- /config.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | 3 | const configSchema = z.object({ 4 | NEXT_PUBLIC_API_ENDPOINT: z.string(), 5 | NEXT_PUBLIC_URL: z.string() 6 | }) 7 | 8 | const configProject = configSchema.safeParse({ 9 | NEXT_PUBLIC_API_ENDPOINT: process.env.NEXT_PUBLIC_API_ENDPOINT, 10 | NEXT_PUBLIC_URL: process.env.NEXT_PUBLIC_URL 11 | }) 12 | 13 | if(!configProject.success) { 14 | console.error(configProject.error.errors) 15 | throw new Error('It is a error with check schema') 16 | } 17 | 18 | const envConfig = configProject.data 19 | 20 | export default envConfig -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | import { z } from 'zod' 2 | 3 | const configSchema = z.object({ 4 | NEXT_PUBLIC_API_ENDPOINT: z.string(), 5 | NEXT_PUBLIC_URL: z.string() 6 | }) 7 | 8 | const configProject = configSchema.safeParse({ 9 | NEXT_PUBLIC_API_ENDPOINT: process.env.NEXT_PUBLIC_API_ENDPOINT, 10 | NEXT_PUBLIC_URL: process.env.NEXT_PUBLIC_URL 11 | }) 12 | 13 | if(!configProject.success) { 14 | console.error(configProject.error.issues) 15 | throw new Error('Declared values in .env file is invalid') 16 | } 17 | 18 | const envConfig = configProject.data 19 | 20 | export default envConfig -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { dirname } from "path"; 2 | import { fileURLToPath } from "url"; 3 | import { FlatCompat } from "@eslint/eslintrc"; 4 | 5 | const __filename = fileURLToPath(import.meta.url); 6 | const __dirname = dirname(__filename); 7 | 8 | const compat = new FlatCompat({ 9 | baseDirectory: __dirname, 10 | }); 11 | 12 | const eslintConfig = [ 13 | ...compat.extends("next/core-web-vitals", "next/typescript"), 14 | { 15 | rules: { 16 | "no-unused-vars": "off", // Disable the rule 17 | }, 18 | extends: ["next/core-web-vitals", , "plugin:@tanstack/query/recommended"], 19 | }, 20 | ]; 21 | 22 | export default eslintConfig; 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | 17 | # next.js 18 | /.next/ 19 | /out/ 20 | 21 | # production 22 | /build 23 | 24 | # misc 25 | .DS_Store 26 | *.pem 27 | 28 | # debug 29 | npm-debug.log* 30 | yarn-debug.log* 31 | yarn-error.log* 32 | .pnpm-debug.log* 33 | 34 | # env files (can opt-in for committing if needed) 35 | .env* 36 | 37 | # vercel 38 | .vercel 39 | 40 | # typescript 41 | *.tsbuildinfo 42 | next-env.d.ts 43 | -------------------------------------------------------------------------------- /src/app/manage/dashboard/page.tsx: -------------------------------------------------------------------------------- 1 | import accountApi from '@/apis/account' 2 | import { cookies } from 'next/headers' 3 | import React from 'react' 4 | 5 | export default async function Dashboard() { 6 | const cookieStore = await cookies() 7 | const accessToken = cookieStore.get('accessToken')?.value! 8 | let name = '' 9 | try { 10 | const result = await accountApi.sGetPersonalAccount(accessToken) 11 | console.log(result) 12 | name = result.payload.data.name 13 | console.log('name', name) 14 | } catch (error: any) { 15 | console.log(error) 16 | if(error?.digest?.includes('NEXT_REDIRECT')) 17 | throw error 18 | } 19 | return
Hi guy {name}
20 | } 21 | -------------------------------------------------------------------------------- /src/queries/useGuest.tsx: -------------------------------------------------------------------------------- 1 | import guestApi from "@/apis/guest"; 2 | import { useMutation, useQuery } from "@tanstack/react-query"; 3 | 4 | export const useGuestLoginMutation = () => { 5 | return useMutation({ 6 | mutationFn: guestApi.login, 7 | }); 8 | }; 9 | 10 | export const useGuestLogoutMutation = () => { 11 | return useMutation({ 12 | mutationFn: guestApi.logout, 13 | }); 14 | }; 15 | 16 | export const useGuestOrderMutation = () => { 17 | return useMutation({ 18 | mutationFn: guestApi.order, 19 | }); 20 | }; 21 | 22 | export const useGuestGetOrderListMutation = () => { 23 | return useQuery({ 24 | queryKey: ["orders"], 25 | queryFn: guestApi.getOrderList, 26 | }); 27 | }; 28 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./src/*"] 23 | } 24 | }, 25 | "exclude": ["node_modules"], 26 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"] 27 | } 28 | -------------------------------------------------------------------------------- /src/components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { cn } from "@/lib/utils" 4 | 5 | const Textarea = React.forwardRef< 6 | HTMLTextAreaElement, 7 | React.ComponentProps<"textarea"> 8 | >(({ className, ...props }, ref) => { 9 | return ( 10 |