Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show rubric score in My Work - Review #5176

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ export function ProposalsTable({
{proposals.map((proposal) => {
const result = proposal.currentEvaluation?.result;
const statusLabel = result ? (result === 'pass' ? 'Passed' : 'Declined') : 'In progress';
const rubricAnswers = proposal.currentEvaluation?.rubricAnswers || [];
const averageAnswer = rubricAnswers.length
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter answers by the user, and only show when they left reviews

Copy link
Contributor Author

@valentinludu valentinludu Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

Now I check if the user has reviewed a score. (in the BE)

? rubricAnswers.reduce((acc, answer) => acc + answer.response.score, 0) / rubricAnswers.length
: 0;

return (
<StyledTableRow
key={proposal.id}
Expand Down Expand Up @@ -189,7 +194,9 @@ export function ProposalsTable({
justifyContent: 'center'
}}
>
{proposal.userReviewResult === 'pass' ? (
{proposal.currentEvaluation?.type === 'rubric' && averageAnswer > 0 ? (
<Typography>{averageAnswer.toFixed(2)}</Typography>
) : proposal.userReviewResult === 'pass' ? (
<ApprovedIcon fontSize='small' color='success' />
) : proposal.userReviewResult === 'fail' ? (
<RejectedIcon fontSize='small' color='error' />
Expand Down
9 changes: 7 additions & 2 deletions lib/proposals/getUserProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import { getCurrentEvaluation, privateEvaluationSteps } from '@charmverse/core/p

import { permissionsApiClient } from '../permissions/api/client';

import type { ProposalRubricCriteriaAnswerWithTypedResponse, RubricRangeAnswer } from './rubric/interfaces';

type CurrentEvaluation = {
id: string;
type: ProposalEvaluationType;
dueDate: Date | null;
title: string;
result: ProposalEvaluationResult | null;
rubricAnswers: Pick<ProposalRubricCriteriaAnswerWithTypedResponse, 'userId' | 'response'>[];
};

export type UserProposal = {
Expand Down Expand Up @@ -296,7 +299,8 @@ export async function getUserProposals({
},
rubricAnswers: {
select: {
userId: true
userId: true,
response: true
}
},
appealReviewers: {
Expand Down Expand Up @@ -423,7 +427,8 @@ export async function getUserProposals({
type: currentEvaluation.type,
dueDate: currentEvaluation.dueDate || null,
title: currentEvaluation.title,
result: currentEvaluation.result || null
result: currentEvaluation.result || null,
rubricAnswers: currentEvaluation.rubricAnswers as { userId: string; response: RubricRangeAnswer }[]
}
: undefined,
updatedAt: proposal.page.updatedAt,
Expand Down
Loading