Skip to content

Commit

Permalink
fix(client): redirect to results correctly on chapter bundle problem …
Browse files Browse the repository at this point in the history
…submission (#594)
  • Loading branch information
fushar authored Feb 10, 2024
1 parent eb0bbd8 commit 9dc4712
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Callout, Intent } from '@blueprintjs/core';
import { Button, Callout, Intent } from '@blueprintjs/core';
import { BanCircle } from '@blueprintjs/icons';

import { ButtonLink } from '../../../ButtonLink/ButtonLink';
import { ContentCard } from '../../../ContentCard/ContentCard';

export function ProblemSubmissionCard({ reasonNotAllowedToSubmit, resultsUrl }) {
const redirectToResultsUrl = () => {
window.location.href = resultsUrl;
};

const renderSubmissionForm = () => {
if (reasonNotAllowedToSubmit) {
return (
Expand All @@ -14,9 +17,9 @@ export function ProblemSubmissionCard({ reasonNotAllowedToSubmit, resultsUrl })
);
}
return (
<ButtonLink intent={Intent.PRIMARY} to={resultsUrl}>
<Button intent={Intent.PRIMARY} onClick={redirectToResultsUrl}>
Submit
</ButtonLink>
</Button>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ButtonLink } from '../../../../../../../../../../../components/ButtonLi
import { ContentCard } from '../../../../../../../../../../../components/ContentCard/ContentCard';
import ItemSubmissionUserFilter from '../../../../../../../../../../../components/ItemSubmissionUserFilter/ItemSubmissionUserFilter';
import { LoadingState } from '../../../../../../../../../../../components/LoadingState/LoadingState';
import { ScrollToTopOnMount } from '../../../../../../../../../../../components/ScrollToTopOnMount/ScrollToTopOnMount';
import { SubmissionDetails } from '../../../../../../../../../../../components/SubmissionDetails/Bundle/SubmissionDetails/SubmissionDetails';
import { selectMaybeUserJid } from '../../../../../../../../../../../modules/session/sessionSelectors';
import { selectStatementLanguage } from '../../../../../../../../../../../modules/webPrefs/webPrefsSelectors';
Expand Down Expand Up @@ -56,7 +55,6 @@ class ChapterProblemSubmissionsPage extends Component {

return (
<ContentCard className="chapter-bundle-problem-submissions-page">
<ScrollToTopOnMount />
<h3 className="heading-with-button-action">Results</h3>
<ButtonLink
small
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';

import { ContentCard } from '../../../../../../../../components/ContentCard/ContentCard';
import StatementLanguageWidget from '../../../../../../../../components/LanguageWidget/StatementLanguageWidget';
Expand Down Expand Up @@ -59,12 +60,14 @@ export class ProblemStatementPage extends Component {
if (!latestSubmissions) {
return <LoadingState />;
}
const resultsUrl = (this.props.location.pathname + '/results').replace('//', '/');

return (
<ProblemWorksheetCard
latestSubmissions={latestSubmissions}
onAnswerItem={this.createSubmission}
worksheet={worksheet}
resultsUrl={resultsUrl}
/>
);
};
Expand All @@ -82,4 +85,4 @@ const mapDispatchToProps = {
onCreateSubmission: problemSetSubmissionActions.createItemSubmission,
onGetLatestSubmissions: problemSetSubmissionActions.getLatestSubmissions,
};
export default connect(mapStateToProps, mapDispatchToProps)(ProblemStatementPage);
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(ProblemStatementPage));

0 comments on commit 9dc4712

Please sign in to comment.