Skip to content

Commit

Permalink
fix: add fap review template preview (#819)
Browse files Browse the repository at this point in the history
Co-authored-by: Gergely Nyiri <gergely.nyiri@eli-alps.hu>
  • Loading branch information
gnyiri and Gergely Nyiri authored Oct 18, 2024
1 parent facad60 commit c9575e1
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 1 deletion.
79 changes: 78 additions & 1 deletion apps/frontend/src/components/review/ReviewQuestionary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import {
QuestionaryContext,
QuestionaryContextType,
} from 'components/questionary/QuestionaryContext';
import { TemplateGroupId } from 'generated/sdk';
import {
BasicUserDetails,
ProposalEndStatus,
ProposalPublicStatus,
QuestionaryStep,
ReviewStatus,
TemplateGroupId,
} from 'generated/sdk';
import createCustomEventHandlers from 'models/questionary/createCustomEventHandlers';
import { FapReviewSubmissionState } from 'models/questionary/fapReview/FapReviewSubmissionState';
import { FapReviewWithQuestionary } from 'models/questionary/fapReview/FapReviewWithQuestionary';
Expand All @@ -22,6 +29,76 @@ export interface ReviewContextType extends QuestionaryContextType {
state: FapReviewSubmissionState | null;
}

export function createFapReviewStub(
templateId: number,
questionarySteps: QuestionaryStep[],
reviewer: BasicUserDetails
): FapReviewWithQuestionary {
return {
id: 0,
grade: 0,
comment: '',
fapID: 0,
reviewer: reviewer,
status: ReviewStatus.DRAFT,
questionary: {
questionaryId: 0,
isCompleted: false,
templateId: templateId,
created: new Date(),
steps: questionarySteps,
},
questionaryID: 0,
proposal: {
primaryKey: 0,
title: '',
abstract: '',
callId: 0,
proposer: reviewer,
questionary: {
questionaryId: 0,
isCompleted: false,
templateId: templateId,
created: new Date(),
steps: questionarySteps,
},
questionaryId: 0,
proposalId: '',
status: {
id: 0,
shortCode: 'DRAFT',
description: '',
name: '',
isDefault: true,
},
submitted: false,
users: [],
samples: [],
genericTemplates: [],
commentForManagement: '',
commentForUser: '',
created: new Date(),
fapMeetingDecisions: [],
faps: [],
finalStatus: ProposalEndStatus.ACCEPTED,
instruments: [],
managementDecisionSubmitted: false,
call: null,
notified: false,
proposalBookingsCore: null,
publicStatus: ProposalPublicStatus.ACCEPTED,
reviews: [],
proposerId: 0,
technicalReviews: [],
statusId: 0,
visits: [],
updated: new Date(),
submittedDate: new Date(),
techniques: [],
},
};
}

interface ReviewQuestionaryProps {
review?: FapReviewWithQuestionary;
reviewUpdated?: (review: FapReviewWithQuestionary) => void;
Expand Down
14 changes: 14 additions & 0 deletions apps/frontend/src/components/template/PreviewTemplateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { GenericTemplateContainer } from 'components/questionary/questionaryComp
import { createGenericTemplateStub } from 'components/questionary/questionaryComponents/GenericTemplate/QuestionaryComponentGenericTemplate';
import { createSampleStub } from 'components/questionary/questionaryComponents/SampleDeclaration/QuestionaryComponentSampleDeclaration';
import { SampleDeclarationContainer } from 'components/questionary/questionaryComponents/SampleDeclaration/SampleDeclarationContainer';
import ReviewQuestionary, {
createFapReviewStub,
} from 'components/review/ReviewQuestionary';
import ShipmentContainer from 'components/shipments/ShipmentContainer';
import { UserContext } from 'context/UserContextProvider';
import { BasicUserDetails } from 'generated/sdk';
Expand Down Expand Up @@ -96,6 +99,17 @@ const PreviewTemplateModal = ({
previewMode={true}
/>
);
case TemplateGroupId.FAP_REVIEW:
return (
<ReviewQuestionary
review={createFapReviewStub(
templateId,
questionarySteps,
user as unknown as BasicUserDetails
)}
previewMode={true}
/>
);
}
};

Expand Down

0 comments on commit c9575e1

Please sign in to comment.