export const getReport = query({
args: { reportId: v.id("reports") },
handler: async (ctx, { reportId }) => {
const user = await currentUser(ctx, {})
const fullReport = await ctx.db.get(reportId)
if (!fullReport) return null
const { cost, recordingUrl, ...report } = fullReport
if (user?.admin) {
if (fullReport.userId) {
const reportUser = await ctx.db.get(fullReport.userId)
const fullReportWithUser = { ...fullReport, reportUser }
return fullReportWithUser
} else {
return fullReport
}
} else {
return report
}
},
})
export const getReport = query({
args: { reportId: v.id("reports") },
handler: async (ctx, { reportId }) => {
const user = await currentUser(ctx, {})
const fullReport = await ctx.db.get(reportId)
if (!fullReport) return null
const { cost, recordingUrl, ...report } = fullReport
if (user?.admin) {
if (fullReport.userId) {
const reportUser = await ctx.db.get(fullReport.userId)
const fullReportWithUser = { ...fullReport, reportUser }
return fullReportWithUser
} else {
return fullReport
}
} else {
return report
}
},
})