minor fixes

This commit is contained in:
rngsurrounded
2025-03-04 01:33:33 +09:00
parent a0d2892fe0
commit 8e95da1e01
2 changed files with 18 additions and 3 deletions
@@ -1,19 +1,21 @@
import React from 'react'; import React from 'react';
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Loader2 } from "lucide-react"; import { Loader2, CheckCircle } from "lucide-react";
interface ActionButtonsProps { interface ActionButtonsProps {
onSubmit: () => void; onSubmit: () => void;
onHistoryClick: () => void; onHistoryClick: () => void;
isSubmitting?: boolean; isSubmitting?: boolean;
hasSubmissionsLeft?: boolean; hasSubmissionsLeft?: boolean;
isCleared: boolean;
} }
const ActionButtons: React.FC<ActionButtonsProps> = ({ const ActionButtons: React.FC<ActionButtonsProps> = ({
onSubmit, onSubmit,
onHistoryClick, onHistoryClick,
isSubmitting = false, isSubmitting = false,
hasSubmissionsLeft = true hasSubmissionsLeft = true,
isCleared
}) => { }) => {
return ( return (
<div className="flex gap-8"> <div className="flex gap-8">
@@ -26,7 +28,15 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
История История
</Button> </Button>
{hasSubmissionsLeft ? ( {isCleared ? (
<Button
className="font-hse-sans flex-grow bg-green-600 hover:bg-green-700"
disabled={true}
>
<CheckCircle className="mr-2 h-4 w-4" />
Задача сдана!
</Button>
) : hasSubmissionsLeft ? (
<Button <Button
onClick={onSubmit} onClick={onSubmit}
className="font-hse-sans flex-grow" className="font-hse-sans flex-grow"
@@ -44,6 +44,10 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
const solutionHistory = solutionsQuery.data || []; const solutionHistory = solutionsQuery.data || [];
let lastSolutionPoints = 0;
if (solutionHistory.length > 0) {
lastSolutionPoints = solutionHistory[solutionHistory.length - 1].earned_points
}
const maxAttempts = task.max_attempts || -1; const maxAttempts = task.max_attempts || -1;
const submissionsUsed = solutionHistory.length; const submissionsUsed = solutionHistory.length;
const submissionsLeft = Math.max(0, maxAttempts - submissionsUsed); const submissionsLeft = Math.max(0, maxAttempts - submissionsUsed);
@@ -174,6 +178,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
onHistoryClick={handleOpenHistory} onHistoryClick={handleOpenHistory}
isSubmitting={isSubmitting} isSubmitting={isSubmitting}
hasSubmissionsLeft={hasSubmissionsLeft} hasSubmissionsLeft={hasSubmissionsLeft}
isCleared={task.points === lastSolutionPoints}
/> />
<SolutionHistorySheet <SolutionHistorySheet