@defikitdotnet/education-module-ai
Version:
AI Education Module using Agent Framework
34 lines (33 loc) • 3.92 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CourseUrlGenerator = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var AgentContext_1 = require("../context/AgentContext");
var CourseUrlGenerator = function (_a) {
var _b = _a.baseUrl, baseUrl = _b === void 0 ? typeof window !== "undefined" ? window.location.origin : "" : _b;
var agent = (0, AgentContext_1.useAgent)().agent;
var _c = (0, react_1.useState)(false), copied = _c[0], setCopied = _c[1];
var _d = (0, react_1.useState)(false), showCustomLink = _d[0], setShowCustomLink = _d[1];
var _e = (0, react_1.useState)("/student"), customPath = _e[0], setCustomPath = _e[1];
var linkRef = (0, react_1.useRef)(null);
if (!agent || !agent.teacherId) {
return null;
}
// Student login URL with course ID
var studentLoginUrl = "".concat(baseUrl, "/?course=").concat(agent.teacherId);
var customUrl = "".concat(baseUrl).concat(customPath, "?course=").concat(agent.teacherId);
var displayUrl = showCustomLink ? customUrl : studentLoginUrl;
// Copy to clipboard
var handleCopy = function () {
if (linkRef.current) {
linkRef.current.select();
document.execCommand("copy");
setCopied(true);
// Reset copied state after 2 seconds
setTimeout(function () { return setCopied(false); }, 2000);
}
};
return ((0, jsx_runtime_1.jsxs)("div", { className: "course-url-generator bg-white rounded-lg shadow p-4 mb-6", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-lg font-medium mb-2", children: "Student Access Link" }), (0, jsx_runtime_1.jsx)("p", { className: "text-sm text-gray-600 mb-4", children: "Share this link with your students to give them access to this course." }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col space-y-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex", children: [(0, jsx_runtime_1.jsx)("input", { ref: linkRef, type: "text", value: displayUrl, readOnly: true, className: "flex-grow px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-1 focus:ring-indigo-500" }), (0, jsx_runtime_1.jsx)("button", { onClick: handleCopy, className: "px-4 py-2 bg-indigo-600 text-white rounded-r-md hover:bg-indigo-700 transition-colors", "aria-label": "Copy link", children: copied ? "Copied!" : "Copy" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center space-x-2", children: [(0, jsx_runtime_1.jsxs)("label", { className: "text-sm flex items-center", children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: showCustomLink, onChange: function () { return setShowCustomLink(!showCustomLink); }, className: "mr-2 h-4 w-4 text-indigo-600 rounded border-gray-300 focus:ring-indigo-500" }), "Use custom page link"] }), showCustomLink && ((0, jsx_runtime_1.jsxs)("select", { value: customPath, onChange: function (e) { return setCustomPath(e.target.value); }, className: "text-sm px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-indigo-500", children: [(0, jsx_runtime_1.jsx)("option", { value: "/student", children: "Student Dashboard" }), (0, jsx_runtime_1.jsx)("option", { value: "/quiz", children: "Quiz" }), (0, jsx_runtime_1.jsx)("option", { value: "/questions", children: "Questions" }), (0, jsx_runtime_1.jsx)("option", { value: "/learning-path", children: "Learning Path" })] }))] })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-4 p-3 bg-indigo-50 rounded-md text-sm text-indigo-700", children: (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Note:" }), " Students will need to create or use their existing student ID to access this course. Their progress will be tracked throughout this course."] }) })] }));
};
exports.CourseUrlGenerator = CourseUrlGenerator;