import { pikkuPermission } from "#pikku/pikku-types.gen.js";

export const isBackOffice = pikkuPermission(async (_services, _data, { session }) => {
    return session?.type === 'backoffice'
})
export const isCompany = pikkuPermission(async (_services, _data, { session }) => {
    return session?.type === 'company'
})
export const isCandidate = pikkuPermission<{ candidateId?: string } | void>(async (_services, data, { session }) => {
    if (session?.type !== 'candidate') {
        return false
    }
    if (data?.candidateId && data.candidateId !== session.userId) {
        return false
    }

    return true
})
