web: review buttons are no longer hard-coded for submission id 1
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
rhpidfyre 2024-12-17 18:31:59 -05:00
parent 9a7270d2f9
commit ffadaa44be
2 changed files with 26 additions and 14 deletions

View File

@ -5,11 +5,16 @@ type Action = "completed" | "submit" | "reject" | "revoke" | "trigger-validate"
interface ReviewButton { interface ReviewButton {
name: Review, name: Review,
action: Action, action: Action,
submissionId: string,
color: ButtonOwnProps["color"] color: ButtonOwnProps["color"]
} }
function ReviewButtonClicked(action: Action) { interface ReviewId {
fetch(`http://localhost:3000/v1/submissions/1/status/${action}`, { submissionId: string
}
function ReviewButtonClicked(action: Action, submissionId: string) {
fetch(`http://localhost:3000/v1/submissions/${submissionId}/status/${action}`, {
method: "POST", method: "POST",
headers: { headers: {
"Content-type": "application/json", "Content-type": "application/json",
@ -18,19 +23,22 @@ function ReviewButtonClicked(action: Action) {
} }
function ReviewButton(props: ReviewButton) { 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 ( return (
<section className="review-set"> <section className="review-set">
<ReviewButton color="info" name="Submit" action="submit"/> <ReviewButton color="info" name="Submit" action="submit" submissionId={props.submissionId}/>
<ReviewButton color="info" name="Revoke" action="revoke"/> <ReviewButton color="info" name="Revoke" action="revoke" submissionId={props.submissionId}/>
<ReviewButton color="info" name="Accept" action="trigger-validate"/> <ReviewButton color="info" name="Accept" action="trigger-validate" submissionId={props.submissionId}/>
<ReviewButton color="info" name="Validate" action="trigger-validate"/> <ReviewButton color="info" name="Validate" action="trigger-validate" submissionId={props.submissionId}/>
<ReviewButton color="error" name="Reject" action="reject"/> <ReviewButton color="error" name="Reject" action="reject" submissionId={props.submissionId}/>
<ReviewButton color="info" name="Upload" action="trigger-upload"/> <ReviewButton color="info" name="Upload" action="trigger-upload" submissionId={props.submissionId}/>
<ReviewButton color="info" name="Completed" action="completed"/> <ReviewButton color="info" name="Completed" action="completed" submissionId={props.submissionId}/>
</section> </section>
) )
} }

View File

@ -13,6 +13,10 @@ import Link from "next/link";
import "./(styles)/page.scss"; import "./(styles)/page.scss";
interface ReviewId {
submissionId: string
}
function Ratings() { function Ratings() {
return ( return (
<Window className="rating-window" title="Rating"> <Window className="rating-window" title="Rating">
@ -34,14 +38,14 @@ function Ratings() {
) )
} }
function RatingArea() { function RatingArea(submission: ReviewId) {
return ( return (
<aside className="review-area"> <aside className="review-area">
<section className="map-image-area"> <section className="map-image-area">
<MapImage/> <MapImage/>
</section> </section>
<Ratings/> <Ratings/>
<ReviewButtons/> <ReviewButtons submissionId={submission.submissionId}/>
</aside> </aside>
) )
} }
@ -71,7 +75,7 @@ export default function SubmissionInfoPage() {
<Webpage> <Webpage>
<main className="map-page-main"> <main className="map-page-main">
<section className="review-section"> <section className="review-section">
<RatingArea/> <RatingArea submissionId={dynamicId.submissionId}/>
<TitleAndComments name={dynamicId.submissionId} creator="Quaternions" review={SubmissionStatus.Accepted} comments={[]}/> <TitleAndComments name={dynamicId.submissionId} creator="Quaternions" review={SubmissionStatus.Accepted} comments={[]}/>
</section> </section>
</main> </main>