web: review buttons are no longer hard-coded for submission id 1
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9a7270d2f9
commit
ffadaa44be
@ -5,11 +5,16 @@ type Action = "completed" | "submit" | "reject" | "revoke" | "trigger-validate"
|
||||
interface ReviewButton {
|
||||
name: Review,
|
||||
action: Action,
|
||||
submissionId: string,
|
||||
color: ButtonOwnProps["color"]
|
||||
}
|
||||
|
||||
function ReviewButtonClicked(action: Action) {
|
||||
fetch(`http://localhost:3000/v1/submissions/1/status/${action}`, {
|
||||
interface ReviewId {
|
||||
submissionId: string
|
||||
}
|
||||
|
||||
function ReviewButtonClicked(action: Action, submissionId: string) {
|
||||
fetch(`http://localhost:3000/v1/submissions/${submissionId}/status/${action}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-type": "application/json",
|
||||
@ -18,19 +23,22 @@ function ReviewButtonClicked(action: Action) {
|
||||
}
|
||||
|
||||
function ReviewButton(props: ReviewButton) {
|
||||
return <Button color={props.color} variant="contained" onClick={() => { ReviewButtonClicked(props.action) }}>{props.name}</Button>
|
||||
return <Button
|
||||
color={props.color}
|
||||
variant="contained"
|
||||
onClick={() => { ReviewButtonClicked(props.action, props.submissionId) }}>{props.name}</Button>
|
||||
}
|
||||
|
||||
export default function ReviewButtons() {
|
||||
export default function ReviewButtons(props: ReviewId) {
|
||||
return (
|
||||
<section className="review-set">
|
||||
<ReviewButton color="info" name="Submit" action="submit"/>
|
||||
<ReviewButton color="info" name="Revoke" action="revoke"/>
|
||||
<ReviewButton color="info" name="Accept" action="trigger-validate"/>
|
||||
<ReviewButton color="info" name="Validate" action="trigger-validate"/>
|
||||
<ReviewButton color="error" name="Reject" action="reject"/>
|
||||
<ReviewButton color="info" name="Upload" action="trigger-upload"/>
|
||||
<ReviewButton color="info" name="Completed" action="completed"/>
|
||||
<ReviewButton color="info" name="Submit" action="submit" submissionId={props.submissionId}/>
|
||||
<ReviewButton color="info" name="Revoke" action="revoke" submissionId={props.submissionId}/>
|
||||
<ReviewButton color="info" name="Accept" action="trigger-validate" submissionId={props.submissionId}/>
|
||||
<ReviewButton color="info" name="Validate" action="trigger-validate" submissionId={props.submissionId}/>
|
||||
<ReviewButton color="error" name="Reject" action="reject" submissionId={props.submissionId}/>
|
||||
<ReviewButton color="info" name="Upload" action="trigger-upload" submissionId={props.submissionId}/>
|
||||
<ReviewButton color="info" name="Completed" action="completed" submissionId={props.submissionId}/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ import Link from "next/link";
|
||||
|
||||
import "./(styles)/page.scss";
|
||||
|
||||
interface ReviewId {
|
||||
submissionId: string
|
||||
}
|
||||
|
||||
function Ratings() {
|
||||
return (
|
||||
<Window className="rating-window" title="Rating">
|
||||
@ -34,14 +38,14 @@ function Ratings() {
|
||||
)
|
||||
}
|
||||
|
||||
function RatingArea() {
|
||||
function RatingArea(submission: ReviewId) {
|
||||
return (
|
||||
<aside className="review-area">
|
||||
<section className="map-image-area">
|
||||
<MapImage/>
|
||||
</section>
|
||||
<Ratings/>
|
||||
<ReviewButtons/>
|
||||
<ReviewButtons submissionId={submission.submissionId}/>
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
@ -71,7 +75,7 @@ export default function SubmissionInfoPage() {
|
||||
<Webpage>
|
||||
<main className="map-page-main">
|
||||
<section className="review-section">
|
||||
<RatingArea/>
|
||||
<RatingArea submissionId={dynamicId.submissionId}/>
|
||||
<TitleAndComments name={dynamicId.submissionId} creator="Quaternions" review={SubmissionStatus.Accepted} comments={[]}/>
|
||||
</section>
|
||||
</main>
|
||||
|
Loading…
Reference in New Issue
Block a user