Skip to content

Commit b7c54ad

Browse files
committed
feat(admin): support marking paid
1 parent 352b55d commit b7c54ad

File tree

7 files changed

+37
-19
lines changed

7 files changed

+37
-19
lines changed

app/components/LeaderBoard/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ export default function LeaderBoard({
2222
{leaders.map((leader) => (
2323
<tr key={leader.submissionId}>
2424
<th>{leader.ranking}</th>
25+
<td>{leader.username}</td>
2526
<td>
2627
<Link
28+
className="underline"
2729
to={`/sheets/${sheet.id}/submissions/${leader.submissionId}`}
2830
>
29-
{leader.username}
31+
{leader.correct}
3032
</Link>
3133
</td>
32-
<td>{leader.correct}</td>
3334
</tr>
3435
))}
3536
</tbody>

app/components/SubmissionTable/index.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import {
44
} from "~/models/submission.server";
55

66
function Mark({ selection }: { selection: SelectionWithPropositionOption }) {
7-
if (!selection.option.proposition.answerId) return null;
8-
if (selection.option.proposition.answerId === selection.optionId) return "✅";
9-
return "❌";
7+
let color = "text-base";
8+
if (!selection.option.proposition.answerId) color = "text-base";
9+
else if (selection.option.proposition.answerId === selection.optionId)
10+
color = "text-success";
11+
else color = "text-error";
12+
13+
return <span className={color}>{selection.option.shortTitle}</span>;
1014
}
1115

1216
export default function SubmissionTable({
@@ -29,7 +33,6 @@ export default function SubmissionTable({
2933
<tr>
3034
<td>{selection.option.proposition.shortTitle}</td>
3135
<td>
32-
{selection.option.shortTitle}
3336
<Mark selection={selection} />
3437
</td>
3538
</tr>

app/routes/sheets.$sheetId._index.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => {
2828
export default function Sheet() {
2929
const { sheet, leaders } = useLoaderData<typeof loader>();
3030
if (sheet.status === "DRAFT") return <p>Sheets not ready</p>;
31-
return <LeaderBoard sheet={sheet} leaders={leaders} />;
31+
32+
return (
33+
<>
34+
<LeaderBoard sheet={sheet} leaders={leaders} />
35+
</>
36+
);
3237
}

app/routes/sheets.$sheetId.admin/route.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import StatusSelector from "./components/StatusSelector";
77
import EditSheet from "./components/EditSheet";
88
import MarkSheet from "./components/MarkSheet";
99
import { readSailor } from "~/models/sailor.server";
10-
import SheetStats from "./components/SheetStats";
10+
import Submissions from "./components/Submissions";
1111
import { readSheetSubmissions } from "~/models/submission.server";
1212

1313
export const loader = async ({ params, request }: LoaderFunctionArgs) => {
@@ -29,8 +29,13 @@ export default function SheetEdit() {
2929
<>
3030
<StatusSelector sheet={sheet} />
3131
{sheet.status === "DRAFT" && <EditSheet sheet={sheet} />}
32-
{sheet.status === "OPEN" && <SheetStats submissions={submissions} />}
33-
{sheet.status === "CLOSED" && <MarkSheet sheet={sheet} />}
32+
{sheet.status === "OPEN" && <Submissions submissions={submissions} />}
33+
{sheet.status === "CLOSED" && (
34+
<>
35+
<MarkSheet sheet={sheet} />
36+
<Submissions submissions={submissions} />
37+
</>
38+
)}
3439
</>
3540
);
3641
}

app/routes/sheets.$sheetId.submissions.$submissionId.tsx

+13-9
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,30 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => {
1818
invariant(!!submissionId, `params.submissionId is required`);
1919

2020
const submission = await readSubmission(submissionId);
21-
return json({ submission });
21+
return json({ sailorId, submission });
2222
};
2323

2424
export default function Submission() {
25-
const { submission } = useLoaderData<typeof loader>();
25+
const { sailorId, submission } = useLoaderData<typeof loader>();
26+
const showPaymentRequired =
27+
submission?.sailorId === sailorId && !submission?.isPaid;
2628
return (
2729
<>
2830
<h1 className="text-center font-bold pb-2">
2931
{submission?.sailor.username}
3032
</h1>
31-
<div role="alert" className="alert alert-info">
32-
<span>
33-
Please e-transfer $10 to [email protected] or your submission will
34-
not be counted!
35-
</span>
36-
</div>
33+
{showPaymentRequired && (
34+
<div role="alert" className="alert alert-info">
35+
<span>
36+
Please e-transfer $10 to [email protected] or your submission
37+
will not be counted!
38+
</span>
39+
</div>
40+
)}
41+
<SubmissionTable submission={submission} />
3742
<h2 className="text-center font-bold pt-3">
3843
Tie Breaker: {submission?.tieBreaker}
3944
</h2>
40-
<SubmissionTable submission={submission} />
4145
</>
4246
);
4347
}

0 commit comments

Comments
 (0)