sync-docs-and-fixes
This commit is contained in:
@@ -25,7 +25,7 @@ function isRecord(v: unknown): v is Record<string, unknown> {
|
||||
|
||||
export function OnboardingGate() {
|
||||
const router = useRouter()
|
||||
const { status, data: session } = useSession()
|
||||
const { status, data: session, update } = useSession()
|
||||
const [required, setRequired] = useState(false)
|
||||
const [currentRole, setCurrentRole] = useState<Role>("student")
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -142,6 +142,7 @@ export function OnboardingGate() {
|
||||
throw new Error(msg || "提交失败")
|
||||
}
|
||||
|
||||
await update?.()
|
||||
toast.success("配置完成")
|
||||
setRequired(false)
|
||||
setOpen(false)
|
||||
|
||||
@@ -18,19 +18,12 @@ import {
|
||||
ListOrdered,
|
||||
Quote,
|
||||
Undo,
|
||||
Redo,
|
||||
MoreHorizontal
|
||||
Redo
|
||||
} from "lucide-react"
|
||||
|
||||
import { cn } from "@/shared/lib/utils"
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import { Separator } from "@/shared/components/ui/separator"
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/shared/components/ui/dropdown-menu"
|
||||
|
||||
// Since we don't have Toggle component yet, let's create a local one or use Button
|
||||
// We will use Button for simplicity and to avoid dependency issues if Radix Toggle isn't installed
|
||||
|
||||
@@ -25,10 +25,6 @@ export const users = mysqlTable("users", {
|
||||
email: varchar("email", { length: 255 }).notNull().unique(),
|
||||
emailVerified: timestamp("emailVerified", { mode: "date" }),
|
||||
image: varchar("image", { length: 255 }),
|
||||
|
||||
// Custom Role Field for RBAC (Default Role)
|
||||
role: varchar("role", { length: 50 }).default("student"),
|
||||
|
||||
// Credentials Auth (Optional)
|
||||
password: varchar("password", { length: 255 }),
|
||||
|
||||
@@ -338,23 +334,27 @@ export const classes = mysqlTable("classes", {
|
||||
}).onDelete("set null"),
|
||||
}));
|
||||
|
||||
export const classSubjectEnum = mysqlEnum("subject", ["语文", "数学", "英语", "美术", "体育", "科学", "社会", "音乐"]);
|
||||
|
||||
export const classSubjectTeachers = mysqlTable("class_subject_teachers", {
|
||||
classId: varchar("class_id", { length: 128 }).notNull(),
|
||||
subject: classSubjectEnum.notNull(),
|
||||
subjectId: varchar("subject_id", { length: 128 }).notNull(),
|
||||
teacherId: varchar("teacher_id", { length: 128 }).references(() => users.id, { onDelete: "set null" }),
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(),
|
||||
}, (table) => ({
|
||||
pk: primaryKey({ columns: [table.classId, table.subject] }),
|
||||
pk: primaryKey({ columns: [table.classId, table.subjectId] }),
|
||||
classIdx: index("class_subject_teachers_class_idx").on(table.classId),
|
||||
teacherIdx: index("class_subject_teachers_teacher_idx").on(table.teacherId),
|
||||
subjectIdIdx: index("class_subject_teachers_subject_id_idx").on(table.subjectId),
|
||||
classFk: foreignKey({
|
||||
columns: [table.classId],
|
||||
foreignColumns: [classes.id],
|
||||
name: "cst_c_fk",
|
||||
}).onDelete("cascade"),
|
||||
subjectFk: foreignKey({
|
||||
columns: [table.subjectId],
|
||||
foreignColumns: [subjects.id],
|
||||
name: "cst_s_fk",
|
||||
}).onDelete("cascade"),
|
||||
}));
|
||||
|
||||
export const classEnrollments = mysqlTable("class_enrollments", {
|
||||
|
||||
Reference in New Issue
Block a user