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 { Button } from "@/components/ui/button";
import { Loader2 } from "lucide-react";
import { Loader2, CheckCircle } from "lucide-react";
interface ActionButtonsProps {
onSubmit: () => void;
onHistoryClick: () => void;
isSubmitting?: boolean;
hasSubmissionsLeft?: boolean;
isCleared: boolean;
}
const ActionButtons: React.FC<ActionButtonsProps> = ({
onSubmit,
onHistoryClick,
isSubmitting = false,
hasSubmissionsLeft = true
hasSubmissionsLeft = true,
isCleared
}) => {
return (
<div className="flex gap-8">
@@ -26,7 +28,15 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
История
</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
onClick={onSubmit}
className="font-hse-sans flex-grow"
@@ -44,6 +44,10 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
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 submissionsUsed = solutionHistory.length;
const submissionsLeft = Math.max(0, maxAttempts - submissionsUsed);
@@ -174,6 +178,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
onHistoryClick={handleOpenHistory}
isSubmitting={isSubmitting}
hasSubmissionsLeft={hasSubmissionsLeft}
isCleared={task.points === lastSolutionPoints}
/>
<SolutionHistorySheet