Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,69 @@ body {
background-color: #f0f0f0;
color: var(--color-text-muted);
text-decoration: line-through;
}

.file-upload-wrapper {
position: relative;
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}

.file-upload-button {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 10px 18px;
background: var(--color-bg-secondary);
border: 1px dashed var(--color-border);
border-radius: 12px;
color: var(--color-text);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
}

.file-upload-button:hover {
border-color: var(--color-primary);
background: rgba(99, 102, 241, 0.08);
transform: translateY(-1px);
}

.file-upload-button .icon {
font-size: 18px;
}

.file-upload-input {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}

.file-selected-name {
font-size: 13px;
color: var(--color-text-muted);
max-width: 220px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 4px 0;
}

.course-card-wrapper {
position: relative;
height: 100%;
}

.course-card-wrapper .course-card {
width: 100%;
height: 100%;
}

.course-card-wrapper button:hover {
background: rgba(99, 102, 241, 0.15) !important;
transform: scale(1.05);
}
32 changes: 22 additions & 10 deletions frontend/src/pages/CourseDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function CourseDetails() {
.from('tasks')
.select('*')
.eq('course_id', id)
.order('created_at', { ascending: false });
.order('deadline', { ascending: true, nullsFirst: false });

if (error) {
console.error('Ошибка загрузки задач:', error);
Expand Down Expand Up @@ -528,15 +528,27 @@ export default function CourseDetails() {
}}
/>

<input
ref={attachmentFileInputRef}
type="file"
onChange={(e) => {
const file = e.target.files?.[0] || null;
setSelectedAttachmentFile(file);
}}
disabled={isAddingAttachment}
/>
<div className="file-upload-wrapper">
<label className="file-upload-button">
<span className="icon">📎</span>
{selectedAttachmentFile ? 'Файл выбран' : 'Выбрать файл'}
<input
ref={attachmentFileInputRef}
type="file"
className="file-upload-input"
onChange={(e) => {
const file = e.target.files?.[0] || null;
setSelectedAttachmentFile(file);
}}
disabled={isAddingAttachment}
/>
</label>
{selectedAttachmentFile && (
<span className="file-selected-name" title={selectedAttachmentFile.name}>
{selectedAttachmentFile.name}
</span>
)}
</div>

{selectedAttachmentFile && (
<div style={{ color: 'var(--color-text-muted)', fontSize: '14px' }}>
Expand Down
131 changes: 98 additions & 33 deletions frontend/src/pages/CoursesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface Course {
name: string;
description: string | null;
user_id: string;
is_complited: boolean;
}

export default function CoursesPage() {
Expand Down Expand Up @@ -231,6 +232,23 @@ export default function CoursesPage() {
setIsCreatingCourse(false);
};

const toggleCourseCompletion = async (courseId: string, currentStatus: boolean) => {
const { error } = await supabase
.from('courses')
.update({ is_complited: !currentStatus })
.eq('id', courseId);

if (error) {
setErrorMessage('Ошибка обновления курса: ' + error.message);
} else {
setCourses(courses.map(course =>
course.id === courseId
? { ...course, is_complited: !currentStatus }
: course
));
}
};

if (loading) {
return (
<div className="container">
Expand Down Expand Up @@ -337,15 +355,27 @@ export default function CoursesPage() {
/>

<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
<input
ref={fileInputRef}
type="file"
onChange={(e) => {
const file = e.target.files?.[0] || null;
setSelectedFile(file);
}}
disabled={isCreatingCourse}
/>
<div className="file-upload-wrapper">
<label className="file-upload-button">
<span className="icon">📎</span>
{selectedFile ? 'Файл выбран' : 'Прикрепить файл'}
<input
ref={fileInputRef}
type="file"
className="file-upload-input"
onChange={(e) => {
const file = e.target.files?.[0] || null;
setSelectedFile(file);
}}
disabled={isCreatingCourse}
/>
</label>
{selectedFile && (
<span className="file-selected-name" title={selectedFile.name}>
{selectedFile.name}
</span>
)}
</div>

{selectedFile && (
<div style={{ color: 'var(--color-text-muted)', fontSize: '14px' }}>
Expand Down Expand Up @@ -393,36 +423,71 @@ export default function CoursesPage() {
</div>
) : (
courses.map((course) => (
<Link key={course.id} to={`/courses/${course.id}`} className="course-card">
<div style={{ flexGrow: 1 }}>
<h3 style={{ marginBottom: '10px', fontSize: '20px' }}>
{course.name}
</h3>

<p
<div key={course.id} className="course-card-wrapper" style={{ position: 'relative' }}>
<Link
to={`/courses/${course.id}`}
className="course-card"
style={{
opacity: course.is_complited ? 0.7 : 1,
background: course.is_complited ? 'var(--color-bg-secondary)' : 'var(--color-bg-card)',
}}
>
<div style={{ flexGrow: 1 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: '8px', marginBottom: '10px' }}>
<h3 style={{ margin: 0, fontSize: '20px' }}>
{course.name}
</h3>
{course.is_complited && (
<span style={{ color: '#4caf50', fontSize: '16px' }}>✅</span>
)}
</div>
<p
style={{
color: 'var(--color-text-muted)',
fontSize: '14px',
lineHeight: '1.5',
}}
>
{course.description?.trim() || 'Описание курса пока не добавлено.'}
</p>
</div>
<div
style={{
color: 'var(--color-text-muted)',
fontSize: '14px',
lineHeight: '1.5',
marginTop: '20px',
fontSize: '13px',
color: 'var(--color-primary)',
fontWeight: '500',
}}
>
{course.description?.trim()
? course.description
: 'Описание курса пока не добавлено.'}
</p>
</div>

<div
Перейти к задачам &rarr;
</div>
</Link>

<button
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
toggleCourseCompletion(course.id, course.is_complited);
}}
style={{
marginTop: '20px',
fontSize: '13px',
color: 'var(--color-primary)',
fontWeight: '500',
position: 'absolute',
top: '12px',
right: '12px',
background: 'none',
border: 'none',
fontSize: '18px',
cursor: 'pointer',
padding: '6px 10px',
borderRadius: '8px',
backgroundColor: course.is_complited ? 'rgba(76, 175, 80, 0.15)' : 'rgba(158, 158, 158, 0.1)',
color: course.is_complited ? '#4caf50' : 'var(--color-text-muted)',
transition: 'all 0.2s ease',
}}
title={course.is_complited ? 'Отметить как активный' : 'Завершить курс'}
>
Перейти к задачам &rarr;
</div>
</Link>
{course.is_complited ? '✅' : '✔️'}
</button>
</div>
))
)}
</div>
Expand Down
32 changes: 22 additions & 10 deletions frontend/src/pages/TaskDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -658,15 +658,27 @@ export default function TaskDetails() {
}}
/>

<input
ref={attachmentFileInputRef}
type="file"
onChange={(e) => {
const file = e.target.files?.[0] || null;
setSelectedAttachmentFile(file);
}}
disabled={isAddingAttachment}
/>
<div className="file-upload-wrapper">
<label className="file-upload-button">
<span className="icon">📎</span>
{selectedAttachmentFile ? 'Файл выбран' : 'Выбрать файл'}
<input
ref={attachmentFileInputRef}
type="file"
className="file-upload-input"
onChange={(e) => {
const file = e.target.files?.[0] || null;
setSelectedAttachmentFile(file);
}}
disabled={isAddingAttachment}
/>
</label>
{selectedAttachmentFile && (
<span className="file-selected-name" title={selectedAttachmentFile.name}>
{selectedAttachmentFile.name}
</span>
)}
</div>

{selectedAttachmentFile && (
<div style={{color: 'var(--color-text-muted)', fontSize: '14px'}}>
Expand All @@ -676,7 +688,7 @@ export default function TaskDetails() {

<div>
<button
className="btn-secondary"
className="btn-primary"
onClick={addAttachment}
disabled={isAddingAttachment}
style={{
Expand Down
Loading