Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c9df31507 | ||
|
|
d932d9af1c | ||
|
|
6d6d127126 | ||
|
|
da9fdc25c4 | ||
|
|
5b71752014 |
@@ -166,13 +166,13 @@ export default function BalancesPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="animate-in fade-in space-y-6 pb-12 duration-500">
|
<div className="animate-in fade-in space-y-6 pb-12 duration-500">
|
||||||
<div>
|
<div>
|
||||||
<span className="text-xs font-semibold text-slate-400">Keuangan / Saldo</span>
|
<span className="text-xs font-semibold text-slate-400">Keuangan / Kas</span>
|
||||||
<h2 className="flex items-center gap-2 text-xl font-black tracking-tight text-slate-900 dark:text-white">
|
<h2 className="flex items-center gap-2 text-xl font-black tracking-tight text-slate-900 dark:text-white">
|
||||||
<Wallet className="h-6 w-6 text-[#1B2CC1]" />
|
<Wallet className="h-6 w-6 text-[#1B2CC1]" />
|
||||||
Buku Saldo
|
Kas & Hutang
|
||||||
</h2>
|
</h2>
|
||||||
<p className="mt-1 text-sm text-slate-500">
|
<p className="mt-1 text-sm text-slate-500">
|
||||||
Pantau riwayat saldo lebih atau kurang dari transaksi pesanan.
|
Pantau riwayat uang deposit (lebih bayar) dan hutang (kurang bayar).
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ export default function BalancesPage() {
|
|||||||
: 'text-slate-500 hover:text-slate-700 dark:hover:text-slate-300'
|
: 'text-slate-500 hover:text-slate-700 dark:hover:text-slate-300'
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
Saldo Saya (Penitip)
|
Kas Anda
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setActiveTab('CREATOR')}
|
onClick={() => setActiveTab('CREATOR')}
|
||||||
@@ -197,7 +197,7 @@ export default function BalancesPage() {
|
|||||||
: 'text-slate-500 hover:text-slate-700 dark:hover:text-slate-300'
|
: 'text-slate-500 hover:text-slate-700 dark:hover:text-slate-300'
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
Saldo Orang (Kreator)
|
Kas Penitip
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -210,10 +210,10 @@ export default function BalancesPage() {
|
|||||||
<div className="space-y-5">
|
<div className="space-y-5">
|
||||||
<div className="rounded-xl border border-blue-100 bg-blue-50 p-4 dark:border-blue-900/50 dark:bg-blue-950/30">
|
<div className="rounded-xl border border-blue-100 bg-blue-50 p-4 dark:border-blue-900/50 dark:bg-blue-950/30">
|
||||||
<h3 className="mb-1 text-sm font-bold text-blue-900 dark:text-blue-100">
|
<h3 className="mb-1 text-sm font-bold text-blue-900 dark:text-blue-100">
|
||||||
Saldo Anda di Kreator Lain
|
Deposit & Hutang Anda
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs leading-relaxed text-blue-700 dark:text-blue-300">
|
<p className="text-xs leading-relaxed text-blue-700 dark:text-blue-300">
|
||||||
Jika saldo <strong>positif</strong> (hijau), Anda memiliki deposit yang bisa digunakan
|
Jika kas <strong>positif</strong> (hijau), Anda memiliki deposit yang bisa digunakan
|
||||||
untuk pesanan berikutnya. Jika <strong>negatif</strong> (merah), Anda berhutang.
|
untuk pesanan berikutnya. Jika <strong>negatif</strong> (merah), Anda berhutang.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -223,9 +223,9 @@ export default function BalancesPage() {
|
|||||||
<div className="mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-slate-100 dark:bg-slate-800">
|
<div className="mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-slate-100 dark:bg-slate-800">
|
||||||
<Wallet className="h-7 w-7 text-slate-300 dark:text-slate-600" />
|
<Wallet className="h-7 w-7 text-slate-300 dark:text-slate-600" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm font-semibold text-slate-500">Belum ada catatan saldo</p>
|
<p className="text-sm font-semibold text-slate-500">Belum ada catatan kas</p>
|
||||||
<p className="mt-1 text-xs text-slate-400">
|
<p className="mt-1 text-xs text-slate-400">
|
||||||
Saldo muncul saat ada sisa atau kekurangan bayar dari PO.
|
Kas muncul saat ada deposit atau hutang dari PO.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -295,7 +295,7 @@ export default function BalancesPage() {
|
|||||||
{/* Amount */}
|
{/* Amount */}
|
||||||
<div className="shrink-0 text-right">
|
<div className="shrink-0 text-right">
|
||||||
<p className="text-[10px] font-semibold tracking-wider text-slate-400 uppercase">
|
<p className="text-[10px] font-semibold tracking-wider text-slate-400 uppercase">
|
||||||
Total Saldo
|
{isPositive ? 'Total Deposit' : 'Total Hutang'}
|
||||||
</p>
|
</p>
|
||||||
<p
|
<p
|
||||||
className={cn(
|
className={cn(
|
||||||
@@ -354,12 +354,12 @@ export default function BalancesPage() {
|
|||||||
<div className="space-y-5">
|
<div className="space-y-5">
|
||||||
<div className="rounded-xl border border-amber-100 bg-amber-50 p-4 dark:border-amber-900/50 dark:bg-amber-950/30">
|
<div className="rounded-xl border border-amber-100 bg-amber-50 p-4 dark:border-amber-900/50 dark:bg-amber-950/30">
|
||||||
<h3 className="mb-1 text-sm font-bold text-amber-900 dark:text-amber-100">
|
<h3 className="mb-1 text-sm font-bold text-amber-900 dark:text-amber-100">
|
||||||
Saldo Orang Lain di Anda
|
Kas & Hutang Penitip di Anda
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs leading-relaxed text-amber-700 dark:text-amber-300">
|
<p className="text-xs leading-relaxed text-amber-700 dark:text-amber-300">
|
||||||
Saldo <strong>positif</strong> = Anda memegang uang lebih milik penitip. Klik{' '}
|
Kas <strong>positif</strong> = Anda memegang uang deposit milik penitip. Klik{' '}
|
||||||
<strong>Kembalikan</strong> untuk mencatatnya. Saldo <strong>negatif</strong> =
|
<strong>Kembalikan</strong> untuk mencatatnya. Kas <strong>negatif</strong> = penitip
|
||||||
penitip masih berhutang ke Anda.
|
masih berhutang ke Anda.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -368,9 +368,9 @@ export default function BalancesPage() {
|
|||||||
<div className="mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-slate-100 dark:bg-slate-800">
|
<div className="mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-slate-100 dark:bg-slate-800">
|
||||||
<Wallet className="h-7 w-7 text-slate-300 dark:text-slate-600" />
|
<Wallet className="h-7 w-7 text-slate-300 dark:text-slate-600" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm font-semibold text-slate-500">Tidak ada catatan saldo</p>
|
<p className="text-sm font-semibold text-slate-500">Tidak ada catatan kas</p>
|
||||||
<p className="mt-1 text-xs text-slate-400">
|
<p className="mt-1 text-xs text-slate-400">
|
||||||
Saldo muncul saat ada kelebihan atau kekurangan bayar.
|
Kas muncul saat ada deposit atau hutang dari PO.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -443,7 +443,7 @@ export default function BalancesPage() {
|
|||||||
{/* Amount */}
|
{/* Amount */}
|
||||||
<div className="shrink-0 text-right">
|
<div className="shrink-0 text-right">
|
||||||
<p className="text-[10px] font-semibold tracking-wider text-slate-400 uppercase">
|
<p className="text-[10px] font-semibold tracking-wider text-slate-400 uppercase">
|
||||||
{isPositive ? 'Anda Hutang' : 'Piutang Anda'}
|
{isPositive ? 'Total Deposit' : 'Total Piutang'}
|
||||||
</p>
|
</p>
|
||||||
<p
|
<p
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|||||||
@@ -506,11 +506,13 @@ function SubmissionRow({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentBalance !== undefined) {
|
if (currentBalance !== undefined) {
|
||||||
let balanceBeforeThisOrder = currentBalance
|
let balanceBeforeThisOrder = currentBalance
|
||||||
if (sub.payment_status === 'LUNAS') {
|
const shouldCountBill = sub.bill != null && (isClosed || sub.payment_status === 'LUNAS')
|
||||||
|
if (shouldCountBill) {
|
||||||
const diff = (sub.paid_amount || 0) - (sub.bill || 0)
|
const diff = (sub.paid_amount || 0) - (sub.bill || 0)
|
||||||
balanceBeforeThisOrder -= diff
|
balanceBeforeThisOrder -= diff
|
||||||
} else {
|
} else {
|
||||||
balanceBeforeThisOrder += sub.saldo_used || 0
|
const diff = (sub.paid_amount || 0) - (sub.saldo_used || 0)
|
||||||
|
balanceBeforeThisOrder -= diff
|
||||||
}
|
}
|
||||||
setAvailableBalance(Math.max(0, balanceBeforeThisOrder))
|
setAvailableBalance(Math.max(0, balanceBeforeThisOrder))
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-13
@@ -3,7 +3,8 @@
|
|||||||
import prisma from '@/lib/prisma'
|
import prisma from '@/lib/prisma'
|
||||||
import { revalidatePath } from 'next/cache'
|
import { revalidatePath } from 'next/cache'
|
||||||
|
|
||||||
import { hashPassword, verifyPassword, encrypt, decrypt } from '@/lib/auth'
|
import { encrypt, decrypt } from '@/lib/auth'
|
||||||
|
import { hashPassword, verifyPassword } from '@/lib/password'
|
||||||
import { cookies } from 'next/headers'
|
import { cookies } from 'next/headers'
|
||||||
import { sendMattermostNotification } from '@/lib/mattermost'
|
import { sendMattermostNotification } from '@/lib/mattermost'
|
||||||
|
|
||||||
@@ -438,6 +439,19 @@ export async function processBulkPayment(data: {
|
|||||||
// Sort by order date ascending (oldest first)
|
// Sort by order date ascending (oldest first)
|
||||||
submissions.sort((a, b) => new Date(a.order.date).getTime() - new Date(b.order.date).getTime())
|
submissions.sort((a, b) => new Date(a.order.date).getTime() - new Date(b.order.date).getTime())
|
||||||
|
|
||||||
|
// Reverse the effect of these submissions on currentBalance to get true available balance
|
||||||
|
if (data.use_balance) {
|
||||||
|
for (const sub of submissions) {
|
||||||
|
const shouldCountBill = sub.bill != null && (sub.order.status === 'CLOSE' || sub.payment_status === 'LUNAS')
|
||||||
|
if (shouldCountBill) {
|
||||||
|
currentBalance -= ((sub.paid_amount || 0) - (sub.bill || 0))
|
||||||
|
} else {
|
||||||
|
currentBalance -= ((sub.paid_amount || 0) - (sub.saldo_used || 0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentBalance = Math.max(0, currentBalance)
|
||||||
|
}
|
||||||
|
|
||||||
let remainingBalance = currentBalance
|
let remainingBalance = currentBalance
|
||||||
let remainingCash = data.cash_amount
|
let remainingCash = data.cash_amount
|
||||||
let totalAvailable = remainingBalance + remainingCash
|
let totalAvailable = remainingBalance + remainingCash
|
||||||
@@ -669,7 +683,10 @@ export async function getBalancesAsCreator(creator_id: string) {
|
|||||||
const [submissions, withdrawals] = await Promise.all([
|
const [submissions, withdrawals] = await Promise.all([
|
||||||
prisma.submission.findMany({
|
prisma.submission.findMany({
|
||||||
where: { order: { creator_id } },
|
where: { order: { creator_id } },
|
||||||
include: { user: { select: { id: true, name: true, photo: true } } },
|
include: {
|
||||||
|
user: { select: { id: true, name: true, photo: true } },
|
||||||
|
order: { select: { status: true } },
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
prisma.balanceWithdrawal.findMany({
|
prisma.balanceWithdrawal.findMany({
|
||||||
where: { creator_id },
|
where: { creator_id },
|
||||||
@@ -681,12 +698,12 @@ export async function getBalancesAsCreator(creator_id: string) {
|
|||||||
|
|
||||||
submissions.forEach((sub) => {
|
submissions.forEach((sub) => {
|
||||||
let diff = 0
|
let diff = 0
|
||||||
if (sub.payment_status === 'LUNAS') {
|
const shouldCountBill = sub.bill != null && (sub.order.status === 'CLOSE' || sub.payment_status === 'LUNAS')
|
||||||
if (sub.bill != null) {
|
|
||||||
diff = (sub.paid_amount || 0) - sub.bill
|
if (shouldCountBill) {
|
||||||
}
|
diff = (sub.paid_amount || 0) - sub.bill!
|
||||||
} else {
|
} else {
|
||||||
diff = -(sub.saldo_used || 0)
|
diff = (sub.paid_amount || 0) - (sub.saldo_used || 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff !== 0) {
|
if (diff !== 0) {
|
||||||
@@ -732,12 +749,12 @@ export async function getBalancesAsSubmittor(user_id: string) {
|
|||||||
|
|
||||||
submissions.forEach((sub) => {
|
submissions.forEach((sub) => {
|
||||||
let diff = 0
|
let diff = 0
|
||||||
if (sub.payment_status === 'LUNAS') {
|
const shouldCountBill = sub.bill != null && (sub.order.status === 'CLOSE' || sub.payment_status === 'LUNAS')
|
||||||
if (sub.bill != null) {
|
|
||||||
diff = (sub.paid_amount || 0) - sub.bill
|
if (shouldCountBill) {
|
||||||
}
|
diff = (sub.paid_amount || 0) - sub.bill!
|
||||||
} else {
|
} else {
|
||||||
diff = -(sub.saldo_used || 0)
|
diff = (sub.paid_amount || 0) - (sub.saldo_used || 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff !== 0) {
|
if (diff !== 0) {
|
||||||
@@ -945,7 +962,7 @@ export async function getPiutangSummary(creator_id: string) {
|
|||||||
select: { id: true, name: true, photo: true },
|
select: { id: true, name: true, photo: true },
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
select: { id: true, title: true, date: true },
|
select: { id: true, title: true, date: true, status: true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
|
|||||||
@@ -96,7 +96,21 @@ export default function PiutangManager({ creatorId }: { creatorId: string }) {
|
|||||||
u.user.name.toLowerCase().includes(searchQuery.toLowerCase())
|
u.user.name.toLowerCase().includes(searchQuery.toLowerCase())
|
||||||
)
|
)
|
||||||
|
|
||||||
const targetUserBalance = balancesData.find((b) => b.user.id === target.userId)?.amount || 0
|
let rawTargetUserBalance = balancesData.find((b) => b.user.id === target.userId)?.amount || 0
|
||||||
|
const userObj = data.find((u) => u.user.id === target.userId)
|
||||||
|
|
||||||
|
if (userObj) {
|
||||||
|
userObj.submissions.forEach((sub: any) => {
|
||||||
|
const shouldCountBill = sub.bill != null && (sub.order.status === 'CLOSE' || sub.payment_status === 'LUNAS')
|
||||||
|
if (shouldCountBill) {
|
||||||
|
rawTargetUserBalance -= ((sub.paid_amount || 0) - (sub.bill || 0))
|
||||||
|
} else {
|
||||||
|
rawTargetUserBalance -= ((sub.paid_amount || 0) - (sub.saldo_used || 0))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetUserBalance = Math.max(0, rawTargetUserBalance)
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export default function ReportByPersonGrid({
|
|||||||
const unpaid = Math.max(0, bill - paid)
|
const unpaid = Math.max(0, bill - paid)
|
||||||
obj.totalPiutang += unpaid
|
obj.totalPiutang += unpaid
|
||||||
obj.totalPaid += paid
|
obj.totalPaid += paid
|
||||||
obj.submissions.push({ ...sub, orderTitle: order.title, orderDate: order.date, paid, unpaid })
|
obj.submissions.push({ ...sub, orderTitle: order.title, orderDate: order.date, orderStatus: order.status, paid, unpaid })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -148,8 +148,24 @@ export default function ReportByPersonGrid({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetUserBalanceObj = balancesData.find((b) => b.user.id === target.userId)
|
let rawTargetUserBalance = balancesData.find((b) => b.user.id === target.userId)?.amount || 0
|
||||||
const targetUserBalance = targetUserBalanceObj ? targetUserBalanceObj.amount : 0
|
const userObj = userList.find((u) => u.user.id === target.userId)
|
||||||
|
|
||||||
|
if (userObj) {
|
||||||
|
userObj.submissions.forEach((sub: any) => {
|
||||||
|
// Only add back submissions that are part of the payment target
|
||||||
|
if (target.ids.includes(sub.id)) {
|
||||||
|
const shouldCountBill = sub.bill != null && (sub.orderStatus === 'CLOSE' || sub.payment_status === 'LUNAS')
|
||||||
|
if (shouldCountBill) {
|
||||||
|
rawTargetUserBalance -= ((sub.paid_amount || 0) - (sub.bill || 0))
|
||||||
|
} else {
|
||||||
|
rawTargetUserBalance -= ((sub.paid_amount || 0) - (sub.saldo_used || 0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetUserBalance = Math.max(0, rawTargetUserBalance)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const menuItems = [
|
|||||||
desc: 'Kelola PO buatan Anda',
|
desc: 'Kelola PO buatan Anda',
|
||||||
},
|
},
|
||||||
{ name: 'Pesanan Saya', href: '/my-purchases', icon: ShoppingBag, desc: 'Riwayat titipan Anda' },
|
{ name: 'Pesanan Saya', href: '/my-purchases', icon: ShoppingBag, desc: 'Riwayat titipan Anda' },
|
||||||
{ name: 'Buku Saldo', href: '/balances', icon: Wallet, desc: 'Pantau riwayat saldo' },
|
{ name: 'Kas & Hutang', href: '/balances', icon: Wallet, desc: 'Pantau kas dan hutang' },
|
||||||
{ name: 'Laporan', href: '/reports', icon: BarChart2, desc: 'Ringkasan transaksi' },
|
{ name: 'Laporan', href: '/reports', icon: BarChart2, desc: 'Ringkasan transaksi' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,9 @@
|
|||||||
import { SignJWT, jwtVerify } from 'jose'
|
import { SignJWT, jwtVerify } from 'jose'
|
||||||
import bcrypt from 'bcryptjs'
|
|
||||||
import { cookies } from 'next/headers'
|
import { cookies } from 'next/headers'
|
||||||
|
|
||||||
const secretKey = process.env.JWT_SECRET
|
const secretKey = process.env.JWT_SECRET
|
||||||
const key = new TextEncoder().encode(secretKey)
|
const key = new TextEncoder().encode(secretKey)
|
||||||
|
|
||||||
export async function hashPassword(password: string) {
|
|
||||||
return await bcrypt.hash(password, 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function verifyPassword(password: string, hash: string) {
|
|
||||||
return await bcrypt.compare(password, hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function encrypt(payload: any) {
|
export async function encrypt(payload: any) {
|
||||||
return await new SignJWT(payload).setProtectedHeader({ alg: 'HS256' }).setIssuedAt().sign(key) // No expiration as requested
|
return await new SignJWT(payload).setProtectedHeader({ alg: 'HS256' }).setIssuedAt().sign(key) // No expiration as requested
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import bcrypt from 'bcryptjs'
|
||||||
|
|
||||||
|
export async function hashPassword(password: string) {
|
||||||
|
return await bcrypt.hash(password, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function verifyPassword(password: string, hash: string) {
|
||||||
|
return await bcrypt.compare(password, hash)
|
||||||
|
}
|
||||||
+7
-4
@@ -2,14 +2,17 @@ import { NextResponse } from 'next/server'
|
|||||||
import type { NextRequest } from 'next/server'
|
import type { NextRequest } from 'next/server'
|
||||||
import { decrypt } from '@/lib/auth'
|
import { decrypt } from '@/lib/auth'
|
||||||
|
|
||||||
const protectedRoutes = ['/', '/my-orders', '/my-purchases', '/reports', '/profile', '/users']
|
const protectedRoutes = ['/', '/my-orders', '/my-purchases', '/reports', '/profile', '/users', '/balances']
|
||||||
|
const protectedPrefixes = ['/my-orders/', '/order/', '/settings/']
|
||||||
const publicRoutes = ['/login', '/register']
|
const publicRoutes = ['/login', '/register']
|
||||||
|
|
||||||
export async function middleware(request: NextRequest) {
|
export async function middleware(request: NextRequest) {
|
||||||
const path = request.nextUrl.pathname
|
const path = request.nextUrl.pathname
|
||||||
|
|
||||||
// Also protect dynamic routes like /my-orders/[id]
|
const isProtectedRoute =
|
||||||
const isProtectedRoute = protectedRoutes.includes(path) || path.startsWith('/my-orders/')
|
protectedRoutes.includes(path) ||
|
||||||
|
protectedPrefixes.some(prefix => path.startsWith(prefix))
|
||||||
|
|
||||||
const isPublicRoute = publicRoutes.includes(path)
|
const isPublicRoute = publicRoutes.includes(path)
|
||||||
|
|
||||||
const cookie = request.cookies.get('session')?.value
|
const cookie = request.cookies.get('session')?.value
|
||||||
@@ -23,7 +26,7 @@ export async function middleware(request: NextRequest) {
|
|||||||
return NextResponse.redirect(new URL('/', request.nextUrl))
|
return NextResponse.redirect(new URL('/', request.nextUrl))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.startsWith('/users') && session?.role !== 'superadmin') {
|
if (path.startsWith('/settings') && session?.role !== 'superadmin') {
|
||||||
return NextResponse.redirect(new URL('/', request.nextUrl))
|
return NextResponse.redirect(new URL('/', request.nextUrl))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user