Skip to content

Commit

Permalink
Change function to openCloseFeedbackForm()
Browse files Browse the repository at this point in the history
  • Loading branch information
victoria34 committed Nov 19, 2019
1 parent bacf415 commit c05d1e1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
38 changes: 21 additions & 17 deletions src/pages/patientView/trialMatch/TrialMatchFeedback.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
import * as React from "react";
import * as _ from 'lodash';
import {Modal} from "react-bootstrap";
import { ISelectedTrialFeedbackFormData } from "./TrialMatchTable";

interface ITrialMatchFeedbackProps {
show: boolean;
data?: ISelectedTrialFeedbackFormData;
isTrialFeedback?: boolean;
title: string;
userEmailAddress: string;
nctId?: string;
protocolNo?: string;
onHide: () => void;
}

export default class TrialMatchFeedback extends React.Component<ITrialMatchFeedbackProps, {}> {
public render()
{
public render() {
let src = '';
if (!_.isUndefined(this.props.isTrialFeedback) && this.props.isTrialFeedback) {
const url = "https://docs.google.com/forms/d/e/1FAIpQLSfcoLRG0iWO_qUb4hfzWFQ1toP575EKCTwqPcXE9DmMzuS34w/viewform";
const nctIdParam = `entry.1070287537=${this.props.nctId || ''}`;
const protocolNoParam = `entry.699867040=${this.props.protocolNo || ''}`;
const userParam = `entry.1655318994=${this.props.userEmailAddress || ''}`;
const uriParam = `entry.1782078941=${encodeURIComponent(window.location.href)}`;
src = `${url}?${userParam}&${uriParam}&${nctIdParam}&${protocolNoParam}&embedded=true`;
} else {
const url = "https://docs.google.com/forms/d/e/1FAIpQLSes1WuMattmo_aT8-34LaPRTC47vVzvdWMgYZ5tSuw8EHoLZw/viewform";
const userParam = `entry.251841421=${this.props.userEmailAddress || ''}`;
const uriParam = `entry.1295500928=${encodeURIComponent(window.location.href)}`;
src = `${url}?${userParam}&${uriParam}&embedded=true`;
if (this.props.show) {
if (!_.isUndefined(this.props.isTrialFeedback) && this.props.isTrialFeedback) {
const url = "https://docs.google.com/forms/d/e/1FAIpQLSfcoLRG0iWO_qUb4hfzWFQ1toP575EKCTwqPcXE9DmMzuS34w/viewform";
const userParam = `entry.1655318994=${this.props.userEmailAddress || ''}`;
const uriParam = `entry.1782078941=${encodeURIComponent(window.location.href)}`;
src = `${url}?${userParam}&${uriParam}&embedded=true`;
if (!_.isUndefined(this.props.data)) {
const nctIdParam = `entry.1070287537=${this.props.data.nctId || ''}`;
const protocolNoParam = `entry.699867040=${this.props.data.protocolNo || ''}`;
src = `${url}?${userParam}&${uriParam}&${nctIdParam}&${protocolNoParam}&embedded=true`;
}
} else {
const url = "https://docs.google.com/forms/d/e/1FAIpQLSes1WuMattmo_aT8-34LaPRTC47vVzvdWMgYZ5tSuw8EHoLZw/viewform";
const userParam = `entry.251841421=${this.props.userEmailAddress || ''}`;
const uriParam = `entry.1295500928=${encodeURIComponent(window.location.href)}`;
src = `${url}?${userParam}&${uriParam}&embedded=true`;
}
}

return (
Expand All @@ -48,4 +52,4 @@ export default class TrialMatchFeedback extends React.Component<ITrialMatchFeedb
</Modal>
);
}
}
}
32 changes: 15 additions & 17 deletions src/pages/patientView/trialMatch/TrialMatchTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type ITrialMatchProps = {
containerWidth: number;
}

type ISelectedTrialFeedbackFormData = {
export type ISelectedTrialFeedbackFormData = {
nctId: string;
protocolNo: string;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ export default class TrialMatchTable extends React.Component<ITrialMatchProps> {
<span className={styles.statusBackground}>{trial.status}</span>
</a>
<span className={styles.feedback}>
<Button type="button" className={"btn btn-default btn-sm btn-xs " + styles.feedbackButton} onClick={() => this.openFeedbackForm(trial.nctId, trial.protocolNo)}>Feedback</Button>
<Button type="button" className={"btn btn-default btn-sm btn-xs " + styles.feedbackButton} onClick={() => this.openCloseFeedbackForm({nctId: trial.nctId, protocolNo: trial.protocolNo})}>Feedback</Button>
</span>
</div>
),
Expand Down Expand Up @@ -193,11 +193,8 @@ export default class TrialMatchTable extends React.Component<ITrialMatchProps> {
}

@action
public openFeedbackForm(nctId: string, protocolNo: string) {
this.selectedTrialFeedbackFormData = {
nctId: nctId,
protocolNo: protocolNo
};
public openCloseFeedbackForm(data?: ISelectedTrialFeedbackFormData) {
this.selectedTrialFeedbackFormData = data;
}

public getGenomicMatch(matches: IGenomicMatchType) {
Expand Down Expand Up @@ -333,21 +330,22 @@ export default class TrialMatchTable extends React.Component<ITrialMatchProps> {
return (
<div>
<p style={{marginBottom: '0'}}>Curated genomic and clinical criteria from open clinical trials at Memorial Sloan Kettering. Please <a href="mailto:team@oncokb.org">contact us</a> or submit <a onClick={() => this.showGeneralFeedback=true}>feedback form</a> if you have any questions.</p>
<TrialMatchFeedback
show={this.showGeneralFeedback}
onHide={() => this.showGeneralFeedback = false}
title="OncoKB Matched Trials General Feedback"
userEmailAddress={AppConfig.serverConfig.user_email_address}
/>
{ this.selectedTrialFeedbackFormData &&
{!_.isUndefined(this.showGeneralFeedback) &&
<TrialMatchFeedback
show={this.showGeneralFeedback}
onHide={() => this.showGeneralFeedback = false}
title="OncoKB Matched Trials General Feedback"
userEmailAddress={AppConfig.serverConfig.user_email_address}
/>
}
{this.selectedTrialFeedbackFormData &&
<TrialMatchFeedback
show={!!this.selectedTrialFeedbackFormData}
onHide={() => !!(this.selectedTrialFeedbackFormData=undefined)}
data={this.selectedTrialFeedbackFormData}
onHide={() => this.openCloseFeedbackForm()}
isTrialFeedback={true}
title="OncoKB Matched Trial Feedback"
userEmailAddress={AppConfig.serverConfig.user_email_address}
nctId={this.selectedTrialFeedbackFormData!.nctId}
protocolNo={this.selectedTrialFeedbackFormData!.protocolNo}
/>
}
<TrialMatchTableComponent
Expand Down

0 comments on commit c05d1e1

Please sign in to comment.