fix up git

This commit is contained in:
2026-06-30 15:06:12 +07:00
parent 11e5a76977
commit 38e22b3390
13 changed files with 883 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { useAuth } from '../auth/AuthContext';
import { apiAdmin, type EmailDomainItem } from '../api';
import { useGitHubConnection } from '../hooks/useGitHubConnection';
import { GitHubReposPanel } from './GitHubReposPanel';
export function ChangePasswordPage({ forced }: { forced?: boolean }) {
const { changePassword, logout } = useAuth();
@@ -177,6 +178,11 @@ export function MyAccountTab() {
<button type="button" className="btn btn-secondary btn-sm" onClick={gh.disconnect}>
Ngắt kết nối
</button>
{!gh.canDeleteRepos && (
<button type="button" className="btn btn-primary btn-sm" disabled={gh.connecting} onClick={gh.connect}>
{gh.connecting ? 'Đang mở GitHub...' : 'Cấp quyền xóa repo'}
</button>
)}
</>
) : (
<button
@@ -189,13 +195,24 @@ export function MyAccountTab() {
</button>
)}
</div>
{gh.connected && !gh.canDeleteRepos && (
<div className="login-error" style={{ marginTop: '0.75rem' }}>
Token hiện tại chưa quyền <strong>delete_repo</strong> không xóa đưc repo. Bấm <strong>Cấp quyền xóa repo</strong> (hoặc ngắt kết nối rồi kết nối lại).
</div>
)}
{gh.error && <div className="login-error">{gh.error}</div>}
{gh.message && <div className="login-success">{gh.message}</div>}
{!gh.connected && (
<p className="exam-git-hint">
Sau khi kết nối, vào <strong>Phòng thi</strong> chọn phòng tab <strong>Bài nộp</strong> bấm <strong>Đy lên Git</strong>.
Sau khi kết nối, vào <strong>Phòng thi</strong> tab <strong>Bài nộp</strong> đy Git (gộp hoặc từng sinh viên).
</p>
)}
{gh.connected && (
<>
<h3 className="section-subtitle" style={{ marginTop: '1rem' }}>Repo đã tạo</h3>
<GitHubReposPanel connected={gh.connected} canDeleteRepos={gh.canDeleteRepos} />
</>
)}
</div>
<div className="card" style={{ padding: '1.25rem' }}>