Skip to content

Commit

Permalink
feat(api): restrict category creation based on entitlement
Browse files Browse the repository at this point in the history
  • Loading branch information
duongdev committed Sep 22, 2024
1 parent c001d2d commit edd723f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/api/v1/services/category.service.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { getPlanConfig } from '@6pm/utilities'
import type { CreateCategory, UpdateCategory } from '@6pm/validation'
import { type Category, CategoryType, type User } from '@prisma/client'
import prisma from '../../lib/prisma'
import {
DEFAULT_EXPENSE_CATEGORIES,
DEFAULT_INCOME_CATEGORIES,
} from '../constants/category.const'
import { getUserPlan } from './user.service'

export async function canUserCreateCategory({
// biome-ignore lint/correctness/noUnusedVariables: <explanation>
user,
}: { user: User }): Promise<boolean> {
return true
const userPlan = getUserPlan(user)
const canCreateCategories = getPlanConfig(userPlan, 'canCreateCategories')

return canCreateCategories === true
}

// biome-ignore lint/correctness/noEmptyPattern: <explanation>
Expand Down

0 comments on commit edd723f

Please sign in to comment.