@hed-hog/lms 0.0.327 → 0.0.329
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/instructor/instructor.service.d.ts.map +1 -1
- package/dist/instructor/instructor.service.js +22 -16
- package/dist/instructor/instructor.service.js.map +1 -1
- package/hedhog/frontend/app/instructors/_components/instructor-form-sheet.tsx.ejs +92 -26
- package/package.json +6 -6
- package/src/instructor/instructor.service.ts +22 -19
- package/hedhog/frontend/app/_components/create-lms-instructor-sheet.tsx.ejs +0 -591
- package/hedhog/frontend/app/courses/[id]/_components/CourseMainInfoCard.tsx.ejs +0 -109
- package/hedhog/frontend/app/courses/[id]/_components/CourseSummaryCard.tsx.ejs +0 -60
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-tree.tsx.ejs +0 -134
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-course.tsx.ejs +0 -113
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson.tsx.ejs +0 -314
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-session.tsx.ejs +0 -174
- package/hedhog/frontend/app/courses/[id]/structure/_components/mock-data.ts.ejs +0 -185
- package/hedhog/frontend/app/enterprise/_components/enterprise-mocks.ts.ejs +0 -277
- package/hedhog/frontend/app/enterprise/_components/enterprise-user-create-sheet.tsx.ejs +0 -207
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Button } from '@/components/ui/button';
|
|
4
|
-
import {
|
|
5
|
-
Form,
|
|
6
|
-
FormControl,
|
|
7
|
-
FormDescription,
|
|
8
|
-
FormField,
|
|
9
|
-
FormItem,
|
|
10
|
-
FormLabel,
|
|
11
|
-
FormMessage,
|
|
12
|
-
} from '@/components/ui/form';
|
|
13
|
-
import { Input } from '@/components/ui/input';
|
|
14
|
-
import {
|
|
15
|
-
Select,
|
|
16
|
-
SelectContent,
|
|
17
|
-
SelectItem,
|
|
18
|
-
SelectTrigger,
|
|
19
|
-
SelectValue,
|
|
20
|
-
} from '@/components/ui/select';
|
|
21
|
-
import {
|
|
22
|
-
Sheet,
|
|
23
|
-
SheetContent,
|
|
24
|
-
SheetFooter,
|
|
25
|
-
SheetHeader,
|
|
26
|
-
SheetTitle,
|
|
27
|
-
} from '@/components/ui/sheet';
|
|
28
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
29
|
-
import { Loader2 } from 'lucide-react';
|
|
30
|
-
import { useEffect } from 'react';
|
|
31
|
-
import { useForm } from 'react-hook-form';
|
|
32
|
-
import { z } from 'zod';
|
|
33
|
-
import type { EnterpriseUser, EnterpriseUserRole } from './enterprise-types';
|
|
34
|
-
|
|
35
|
-
// ── Schema ─────────────────────────────────────────────────────────────────────
|
|
36
|
-
|
|
37
|
-
const userCreateSchema = z.object({
|
|
38
|
-
name: z.string().trim().min(1, 'Name is required.'),
|
|
39
|
-
email: z
|
|
40
|
-
.string()
|
|
41
|
-
.trim()
|
|
42
|
-
.min(1, 'Email is required.')
|
|
43
|
-
.email('Enter a valid email address.'),
|
|
44
|
-
role: z.enum(['student', 'hr_manager', 'enterprise_admin', 'viewer']),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
type UserCreateValues = z.infer<typeof userCreateSchema>;
|
|
48
|
-
|
|
49
|
-
const DEFAULT_VALUES: UserCreateValues = {
|
|
50
|
-
name: '',
|
|
51
|
-
email: '',
|
|
52
|
-
role: 'student',
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// ── Props ─────────────────────────────────────────────────────────────────────
|
|
56
|
-
|
|
57
|
-
export interface EnterpriseUserCreateSheetProps {
|
|
58
|
-
open: boolean;
|
|
59
|
-
onOpenChange: (open: boolean) => void;
|
|
60
|
-
onCreated?: (user: EnterpriseUser) => void;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ── Component ─────────────────────────────────────────────────────────────────
|
|
64
|
-
|
|
65
|
-
export function EnterpriseUserCreateSheet({
|
|
66
|
-
open,
|
|
67
|
-
onOpenChange,
|
|
68
|
-
onCreated,
|
|
69
|
-
}: EnterpriseUserCreateSheetProps) {
|
|
70
|
-
const form = useForm<UserCreateValues>({
|
|
71
|
-
resolver: zodResolver(userCreateSchema),
|
|
72
|
-
defaultValues: DEFAULT_VALUES,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Reset form whenever the sheet closes
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
if (!open) {
|
|
78
|
-
form.reset(DEFAULT_VALUES);
|
|
79
|
-
}
|
|
80
|
-
}, [open, form]);
|
|
81
|
-
|
|
82
|
-
function handleOpenChange(nextOpen: boolean) {
|
|
83
|
-
if (!nextOpen) form.reset(DEFAULT_VALUES);
|
|
84
|
-
onOpenChange(nextOpen);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function onSubmit(values: UserCreateValues) {
|
|
88
|
-
// Optimistic mock creation — replace with real API call when available
|
|
89
|
-
const newUser: EnterpriseUser = {
|
|
90
|
-
id: Date.now(),
|
|
91
|
-
userId: Date.now() + 1,
|
|
92
|
-
name: values.name,
|
|
93
|
-
email: values.email,
|
|
94
|
-
role: values.role as EnterpriseUserRole,
|
|
95
|
-
status: 'pending',
|
|
96
|
-
lastAccessAt: null,
|
|
97
|
-
};
|
|
98
|
-
onCreated?.(newUser);
|
|
99
|
-
handleOpenChange(false);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const saving = form.formState.isSubmitting;
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<Sheet open={open} onOpenChange={handleOpenChange}>
|
|
106
|
-
<SheetContent side="right" className="flex flex-col gap-0 sm:max-w-md">
|
|
107
|
-
<SheetHeader className="border-b px-6 py-4">
|
|
108
|
-
<SheetTitle>New user</SheetTitle>
|
|
109
|
-
</SheetHeader>
|
|
110
|
-
|
|
111
|
-
<Form {...form}>
|
|
112
|
-
<form
|
|
113
|
-
onSubmit={form.handleSubmit(onSubmit)}
|
|
114
|
-
className="flex flex-1 flex-col overflow-hidden"
|
|
115
|
-
>
|
|
116
|
-
<div className="flex-1 space-y-5 overflow-y-auto px-6 py-5">
|
|
117
|
-
{/* Name */}
|
|
118
|
-
<FormField
|
|
119
|
-
control={form.control}
|
|
120
|
-
name="name"
|
|
121
|
-
render={({ field }) => (
|
|
122
|
-
<FormItem>
|
|
123
|
-
<FormLabel>Full name</FormLabel>
|
|
124
|
-
<FormControl>
|
|
125
|
-
<Input placeholder="e.g. Ana Beatriz Souza" {...field} />
|
|
126
|
-
</FormControl>
|
|
127
|
-
<FormMessage />
|
|
128
|
-
</FormItem>
|
|
129
|
-
)}
|
|
130
|
-
/>
|
|
131
|
-
|
|
132
|
-
{/* Email */}
|
|
133
|
-
<FormField
|
|
134
|
-
control={form.control}
|
|
135
|
-
name="email"
|
|
136
|
-
render={({ field }) => (
|
|
137
|
-
<FormItem>
|
|
138
|
-
<FormLabel>Email</FormLabel>
|
|
139
|
-
<FormControl>
|
|
140
|
-
<Input
|
|
141
|
-
type="email"
|
|
142
|
-
placeholder="user@company.com"
|
|
143
|
-
{...field}
|
|
144
|
-
/>
|
|
145
|
-
</FormControl>
|
|
146
|
-
<FormDescription>
|
|
147
|
-
An invite will be sent to this address.
|
|
148
|
-
</FormDescription>
|
|
149
|
-
<FormMessage />
|
|
150
|
-
</FormItem>
|
|
151
|
-
)}
|
|
152
|
-
/>
|
|
153
|
-
|
|
154
|
-
{/* Role */}
|
|
155
|
-
<FormField
|
|
156
|
-
control={form.control}
|
|
157
|
-
name="role"
|
|
158
|
-
render={({ field }) => (
|
|
159
|
-
<FormItem>
|
|
160
|
-
<FormLabel>Role</FormLabel>
|
|
161
|
-
<Select value={field.value} onValueChange={field.onChange}>
|
|
162
|
-
<FormControl>
|
|
163
|
-
<SelectTrigger className="w-full">
|
|
164
|
-
<SelectValue placeholder="Select a role" />
|
|
165
|
-
</SelectTrigger>
|
|
166
|
-
</FormControl>
|
|
167
|
-
<SelectContent>
|
|
168
|
-
<SelectItem value="enterprise_admin">
|
|
169
|
-
Admin — full account management
|
|
170
|
-
</SelectItem>
|
|
171
|
-
<SelectItem value="hr_manager">
|
|
172
|
-
HR / Manager — manages learners and reports
|
|
173
|
-
</SelectItem>
|
|
174
|
-
<SelectItem value="student">
|
|
175
|
-
Student — access to assigned courses
|
|
176
|
-
</SelectItem>
|
|
177
|
-
<SelectItem value="viewer">
|
|
178
|
-
Viewer — read-only access
|
|
179
|
-
</SelectItem>
|
|
180
|
-
</SelectContent>
|
|
181
|
-
</Select>
|
|
182
|
-
<FormMessage />
|
|
183
|
-
</FormItem>
|
|
184
|
-
)}
|
|
185
|
-
/>
|
|
186
|
-
</div>
|
|
187
|
-
|
|
188
|
-
<SheetFooter className="border-t px-6 py-4">
|
|
189
|
-
<Button
|
|
190
|
-
type="button"
|
|
191
|
-
variant="outline"
|
|
192
|
-
onClick={() => handleOpenChange(false)}
|
|
193
|
-
disabled={saving}
|
|
194
|
-
>
|
|
195
|
-
Cancel
|
|
196
|
-
</Button>
|
|
197
|
-
<Button type="submit" disabled={saving}>
|
|
198
|
-
{saving && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
199
|
-
Create user
|
|
200
|
-
</Button>
|
|
201
|
-
</SheetFooter>
|
|
202
|
-
</form>
|
|
203
|
-
</Form>
|
|
204
|
-
</SheetContent>
|
|
205
|
-
</Sheet>
|
|
206
|
-
);
|
|
207
|
-
}
|