feat: Add LTI launch, lesson preview, course progress, bookmarks, and asset management features.

This commit is contained in:
2026-02-23 15:43:45 -03:00
parent f365e585a2
commit 7f7ea3d70c
45 changed files with 5250 additions and 697 deletions
+409 -1
View File
@@ -11,14 +11,17 @@
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"framer-motion": "^11.2.10",
"lodash": "^4.17.21",
"lucide-react": "^0.395.0",
"next": "14.2.21",
"react": "^18",
"react-dom": "^18",
"react-markdown": "^10.1.0",
"recharts": "^3.7.0",
"tailwind-merge": "^2.3.0"
},
"devDependencies": {
"@types/lodash": "^4.17.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
@@ -461,6 +464,42 @@
"node": ">=14"
}
},
"node_modules/@reduxjs/toolkit": {
"version": "2.11.2",
"resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.11.2.tgz",
"integrity": "sha512-Kd6kAHTA6/nUpp8mySPqj3en3dm0tdMIgbttnQ1xFMVpufoj+ADi8pXLBsd4xzTRHQa7t/Jv8W5UnCuW4kuWMQ==",
"license": "MIT",
"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@standard-schema/utils": "^0.3.0",
"immer": "^11.0.0",
"redux": "^5.0.1",
"redux-thunk": "^3.1.0",
"reselect": "^5.1.0"
},
"peerDependencies": {
"react": "^16.9.0 || ^17.0.0 || ^18 || ^19",
"react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0"
},
"peerDependenciesMeta": {
"react": {
"optional": true
},
"react-redux": {
"optional": true
}
}
},
"node_modules/@reduxjs/toolkit/node_modules/immer": {
"version": "11.1.4",
"resolved": "https://registry.npmjs.org/immer/-/immer-11.1.4.tgz",
"integrity": "sha512-XREFCPo6ksxVzP4E0ekD5aMdf8WMwmdNaz6vuvxgI40UaEiu6q3p8X52aU6GdyvLY3XXX/8R7JOTXStz/nBbRw==",
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/immer"
}
},
"node_modules/@rtsao/scc": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz",
@@ -473,6 +512,18 @@
"integrity": "sha512-ojSshQPKwVvSMR8yT2L/QtUkV5SXi/IfDiJ4/8d6UbTPjiHVmxZzUAzGD8Tzks1b9+qQkZa0isUOvYObedITaw==",
"dev": true
},
"node_modules/@standard-schema/spec": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
"integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",
"license": "MIT"
},
"node_modules/@standard-schema/utils": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@standard-schema/utils/-/utils-0.3.0.tgz",
"integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
"license": "MIT"
},
"node_modules/@swc/counter": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz",
@@ -497,6 +548,69 @@
"tslib": "^2.4.0"
}
},
"node_modules/@types/d3-array": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz",
"integrity": "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==",
"license": "MIT"
},
"node_modules/@types/d3-color": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz",
"integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==",
"license": "MIT"
},
"node_modules/@types/d3-ease": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz",
"integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==",
"license": "MIT"
},
"node_modules/@types/d3-interpolate": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz",
"integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==",
"license": "MIT",
"dependencies": {
"@types/d3-color": "*"
}
},
"node_modules/@types/d3-path": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz",
"integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==",
"license": "MIT"
},
"node_modules/@types/d3-scale": {
"version": "4.0.9",
"resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz",
"integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==",
"license": "MIT",
"dependencies": {
"@types/d3-time": "*"
}
},
"node_modules/@types/d3-shape": {
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.1.8.tgz",
"integrity": "sha512-lae0iWfcDeR7qt7rA88BNiqdvPS5pFVPpo5OfjElwNaT2yyekbM0C9vK+yqBqEmHr6lDkRnYNoTBYlAgJa7a4w==",
"license": "MIT",
"dependencies": {
"@types/d3-path": "*"
}
},
"node_modules/@types/d3-time": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz",
"integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g==",
"license": "MIT"
},
"node_modules/@types/d3-timer": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz",
"integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==",
"license": "MIT"
},
"node_modules/@types/debug": {
"version": "4.1.12",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz",
@@ -536,6 +650,13 @@
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
"dev": true
},
"node_modules/@types/lodash": {
"version": "4.17.24",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.24.tgz",
"integrity": "sha512-gIW7lQLZbue7lRSWEFql49QJJWThrTFFeIMJdp3eH4tKoxm1OvEPg02rm4wCCSHS0cL3/Fizimb35b7k8atwsQ==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/mdast": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",
@@ -590,6 +711,12 @@
"integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",
"license": "MIT"
},
"node_modules/@types/use-sync-external-store": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg==",
"license": "MIT"
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.50.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.50.0.tgz",
@@ -1816,6 +1943,127 @@
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="
},
"node_modules/d3-array": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
"license": "ISC",
"dependencies": {
"internmap": "1 - 2"
},
"engines": {
"node": ">=12"
}
},
"node_modules/d3-color": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz",
"integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==",
"license": "ISC",
"engines": {
"node": ">=12"
}
},
"node_modules/d3-ease": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz",
"integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==",
"license": "BSD-3-Clause",
"engines": {
"node": ">=12"
}
},
"node_modules/d3-format": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.2.tgz",
"integrity": "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==",
"license": "ISC",
"engines": {
"node": ">=12"
}
},
"node_modules/d3-interpolate": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz",
"integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==",
"license": "ISC",
"dependencies": {
"d3-color": "1 - 3"
},
"engines": {
"node": ">=12"
}
},
"node_modules/d3-path": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz",
"integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==",
"license": "ISC",
"engines": {
"node": ">=12"
}
},
"node_modules/d3-scale": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz",
"integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==",
"license": "ISC",
"dependencies": {
"d3-array": "2.10.0 - 3",
"d3-format": "1 - 3",
"d3-interpolate": "1.2.0 - 3",
"d3-time": "2.1.1 - 3",
"d3-time-format": "2 - 4"
},
"engines": {
"node": ">=12"
}
},
"node_modules/d3-shape": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz",
"integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==",
"license": "ISC",
"dependencies": {
"d3-path": "^3.1.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/d3-time": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz",
"integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==",
"license": "ISC",
"dependencies": {
"d3-array": "2 - 3"
},
"engines": {
"node": ">=12"
}
},
"node_modules/d3-time-format": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz",
"integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==",
"license": "ISC",
"dependencies": {
"d3-time": "1 - 3"
},
"engines": {
"node": ">=12"
}
},
"node_modules/d3-timer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz",
"integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==",
"license": "ISC",
"engines": {
"node": ">=12"
}
},
"node_modules/damerau-levenshtein": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
@@ -1899,6 +2147,12 @@
}
}
},
"node_modules/decimal.js-light": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz",
"integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==",
"license": "MIT"
},
"node_modules/decode-named-character-reference": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.2.0.tgz",
@@ -2199,6 +2453,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/es-toolkit": {
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.44.0.tgz",
"integrity": "sha512-6penXeZalaV88MM3cGkFZZfOoLGWshWWfdy0tWw/RlVVyhvMaWSBTOvXNeiW3e5FwdS5ePW0LGEu17zT139ktg==",
"license": "MIT",
"workspaces": [
"docs",
"benchmarks"
]
},
"node_modules/escalade": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
@@ -2656,6 +2920,12 @@
"node": ">=0.10.0"
}
},
"node_modules/eventemitter3": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.4.tgz",
"integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==",
"license": "MIT"
},
"node_modules/extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
@@ -3238,6 +3508,16 @@
"node": ">= 4"
}
},
"node_modules/immer": {
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/immer/-/immer-10.2.0.tgz",
"integrity": "sha512-d/+XTN3zfODyjr89gM3mPq1WNX2B8pYsu7eORitdwyA2sBubnTl3laYlBk4sXY5FUa5qTZGBDPJICVbvqzjlbw==",
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/immer"
}
},
"node_modules/import-fresh": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
@@ -3300,6 +3580,15 @@
"node": ">= 0.4"
}
},
"node_modules/internmap": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz",
"integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==",
"license": "ISC",
"engines": {
"node": ">=12"
}
},
"node_modules/is-alphabetical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz",
@@ -3954,6 +4243,12 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/lodash": {
"version": "4.17.23",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
"license": "MIT"
},
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
@@ -5382,7 +5677,7 @@
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
"dev": true
"peer": true
},
"node_modules/react-markdown": {
"version": "10.1.0",
@@ -5411,6 +5706,30 @@
"react": ">=18"
}
},
"node_modules/react-redux": {
"version": "9.2.0",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
"license": "MIT",
"peer": true,
"dependencies": {
"@types/use-sync-external-store": "^0.0.6",
"use-sync-external-store": "^1.4.0"
},
"peerDependencies": {
"@types/react": "^18.2.25 || ^19",
"react": "^18.0 || ^19",
"redux": "^5.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"redux": {
"optional": true
}
}
},
"node_modules/read-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
@@ -5432,6 +5751,52 @@
"node": ">=8.10.0"
}
},
"node_modules/recharts": {
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/recharts/-/recharts-3.7.0.tgz",
"integrity": "sha512-l2VCsy3XXeraxIID9fx23eCb6iCBsxUQDnE8tWm6DFdszVAO7WVY/ChAD9wVit01y6B2PMupYiMmQwhgPHc9Ew==",
"license": "MIT",
"workspaces": [
"www"
],
"dependencies": {
"@reduxjs/toolkit": "1.x.x || 2.x.x",
"clsx": "^2.1.1",
"decimal.js-light": "^2.5.1",
"es-toolkit": "^1.39.3",
"eventemitter3": "^5.0.1",
"immer": "^10.1.1",
"react-redux": "8.x.x || 9.x.x",
"reselect": "5.1.1",
"tiny-invariant": "^1.3.3",
"use-sync-external-store": "^1.2.2",
"victory-vendor": "^37.0.2"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
"node_modules/redux": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
"license": "MIT",
"peer": true
},
"node_modules/redux-thunk": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz",
"integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==",
"license": "MIT",
"peerDependencies": {
"redux": "^5.0.0"
}
},
"node_modules/reflect.getprototypeof": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",
@@ -5507,6 +5872,12 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/reselect": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz",
"integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==",
"license": "MIT"
},
"node_modules/resolve": {
"version": "1.22.11",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz",
@@ -6274,6 +6645,12 @@
"node": ">=0.8"
}
},
"node_modules/tiny-invariant": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==",
"license": "MIT"
},
"node_modules/tinyglobby": {
"version": "0.2.15",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",
@@ -6683,6 +7060,15 @@
"punycode": "^2.1.0"
}
},
"node_modules/use-sync-external-store": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz",
"integrity": "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==",
"license": "MIT",
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -6717,6 +7103,28 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/victory-vendor": {
"version": "37.3.6",
"resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-37.3.6.tgz",
"integrity": "sha512-SbPDPdDBYp+5MJHhBCAyI7wKM3d5ivekigc2Dk2s7pgbZ9wIgIBYGVw4zGHBml/qTFbexrofXW6Gu4noGxrOwQ==",
"license": "MIT AND ISC",
"dependencies": {
"@types/d3-array": "^3.0.3",
"@types/d3-ease": "^3.0.0",
"@types/d3-interpolate": "^3.0.1",
"@types/d3-scale": "^4.0.2",
"@types/d3-shape": "^3.1.0",
"@types/d3-time": "^3.0.0",
"@types/d3-timer": "^3.0.0",
"d3-array": "^3.1.6",
"d3-ease": "^3.0.1",
"d3-interpolate": "^3.0.1",
"d3-scale": "^4.0.2",
"d3-shape": "^3.1.0",
"d3-time": "^3.0.0",
"d3-timer": "^3.0.1"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+4 -3
View File
@@ -12,17 +12,18 @@
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"framer-motion": "^11.2.10",
"lodash": "^4.17.21",
"lucide-react": "^0.395.0",
"next": "14.2.21",
"lodash": "^4.17.21",
"react": "^18",
"react-dom": "^18",
"react-markdown": "^10.1.0",
"recharts": "^3.7.0",
"tailwind-merge": "^2.3.0"
},
"devDependencies": {
"@types/node": "^20",
"@types/lodash": "^4.17.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.4.19",
@@ -32,4 +33,4 @@
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}
}
+127
View File
@@ -0,0 +1,127 @@
"use client";
import React, { useEffect, useState } from 'react';
import { lmsApi, UserBookmark, Course, Module } from '@/lib/api';
import { Bookmark, ChevronRight, BookOpen, Clock, Trash2 } from 'lucide-react';
import Link from 'next/link';
import { formatDistanceToNow } from 'date-fns';
import { es } from 'date-fns/locale';
export default function BookmarksPage() {
const [bookmarks, setBookmarks] = useState<UserBookmark[]>([]);
const [courses, setCourses] = useState<Record<string, Course & { modules: Module[] }>>({});
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchBookmarks = async () => {
try {
const data = await lmsApi.getBookmarks();
setBookmarks(data);
// Fetch course details for each unique course_id
const courseIds = [...new Set(data.map(b => b.course_id))];
const courseData: Record<string, Course & { modules: Module[] }> = {};
await Promise.all(courseIds.map(async (id) => {
try {
const outline = await lmsApi.getCourseOutline(id);
courseData[id] = { ...outline.course, modules: outline.modules };
} catch (e) {
console.error(`Error fetching course ${id}`, e);
}
}));
setCourses(courseData);
} catch (err) {
console.error("Error fetching bookmarks:", err);
} finally {
setLoading(false);
}
};
fetchBookmarks();
}, []);
const handleRemoveBookmark = async (lessonId: string) => {
try {
await lmsApi.toggleBookmark(lessonId);
setBookmarks(prev => prev.filter(b => b.lesson_id !== lessonId));
} catch (err) {
console.error("Error removing bookmark:", err);
}
};
if (loading) return <div className="p-20 text-center animate-pulse text-gray-500 font-bold uppercase tracking-widest">Cargando Marcadores...</div>;
return (
<div className="max-w-6xl mx-auto px-6 py-20">
<div className="mb-12">
<div className="flex items-center gap-4 mb-2">
<div className="w-12 h-12 rounded-2xl glass border-yellow-500/20 bg-yellow-500/10 flex items-center justify-center">
<Bookmark size={24} className="text-yellow-400" fill="currentColor" />
</div>
<h1 className="text-4xl font-black tracking-tight text-white">Mis Lecciones Guardadas</h1>
</div>
<p className="text-gray-500 font-bold uppercase tracking-widest text-[10px]">Acceso rápido a los contenidos que marcaste como importantes</p>
</div>
{bookmarks.length === 0 ? (
<div className="py-20 text-center glass rounded-[2.5rem] border-white/5 bg-white/[0.02]">
<div className="w-20 h-20 rounded-full bg-white/5 flex items-center justify-center mx-auto mb-6">
<Bookmark size={32} className="text-gray-600" />
</div>
<h3 className="text-xl font-bold text-white mb-2">Aún no tienes marcadores</h3>
<p className="text-gray-500 max-w-md mx-auto">Cuando encuentres una lección interesante, haz clic en el icono de marcador para guardarla aquí.</p>
</div>
) : (
<div className="grid gap-6">
{bookmarks.map((bookmark) => {
const course = courses[bookmark.course_id];
return (
<div key={bookmark.id} className="group relative glass rounded-3xl border-white/5 hover:border-yellow-500/30 transition-all duration-500 bg-white/[0.02] hover:bg-yellow-500/[0.02] p-6 flex flex-col md:flex-row md:items-center justify-between gap-6">
<div className="flex items-center gap-6">
<div className="w-16 h-16 rounded-2xl bg-gradient-to-br from-yellow-500/20 to-orange-500/20 flex items-center justify-center shrink-0 border border-white/5">
<BookOpen size={24} className="text-yellow-400" />
</div>
<div>
<div className="flex items-center gap-2 mb-1">
<span className="text-[10px] font-black uppercase tracking-widest text-yellow-500/60">{course?.title || 'Curso'}</span>
<span className="text-gray-700"></span>
<span className="text-[10px] font-bold text-gray-500 flex items-center gap-1">
<Clock size={10} />
Guardado {formatDistanceToNow(new Date(bookmark.created_at), { addSuffix: true, locale: es })}
</span>
</div>
<Link href={`/courses/${bookmark.course_id}/lessons/${bookmark.lesson_id}`}>
<h3 className="text-xl font-black text-white group-hover:text-yellow-400 transition-colors tracking-tight">
{(() => {
const lesson = course?.modules?.flatMap(m => m.lessons).find(l => l.id === bookmark.lesson_id);
return lesson?.title || `Lección ${bookmark.lesson_id.substring(0, 8)}`;
})()}
</h3>
</Link>
</div>
</div>
<div className="flex items-center gap-4">
<button
onClick={() => handleRemoveBookmark(bookmark.lesson_id)}
className="p-3 rounded-xl hover:bg-red-500/10 text-gray-500 hover:text-red-400 transition-all border border-transparent hover:border-red-500/20"
title="Eliminar marcador"
>
<Trash2 size={20} />
</button>
<Link
href={`/courses/${bookmark.course_id}/lessons/${bookmark.lesson_id}`}
className="btn-premium !py-3 !px-6 text-xs group/btn"
>
Continuar <ChevronRight size={16} className="group-hover/btn:translate-x-1 transition-transform" />
</Link>
</div>
</div>
);
})}
</div>
)}
</div>
);
}
@@ -3,7 +3,7 @@
import { useEffect, useState } from "react";
import { lmsApi, Lesson, Course, Module, UserGrade } from "@/lib/api";
import Link from "next/link";
import { ChevronLeft, ChevronRight, Menu, CheckCircle2 } from "lucide-react";
import { ChevronLeft, ChevronRight, Menu, CheckCircle2, Bookmark } from "lucide-react";
import { useAuth } from "@/context/AuthContext";
import DescriptionPlayer from "@/components/blocks/DescriptionPlayer";
@@ -35,6 +35,7 @@ export default function LessonPlayerPage({ params }: { params: { id: string, les
const [currentTime, setCurrentTime] = useState(0);
const [userGrade, setUserGrade] = useState<UserGrade | null>(null);
const [allGrades, setAllGrades] = useState<UserGrade[]>([]);
const [isBookmarked, setIsBookmarked] = useState(false);
const { user } = useAuth();
useEffect(() => {
@@ -48,10 +49,14 @@ export default function LessonPlayerPage({ params }: { params: { id: string, les
setCourse({ ...outlineData.course, modules: outlineData.modules });
if (user) {
const grades = await lmsApi.getUserGrades(user.id, params.id);
const [grades, bookmarks] = await Promise.all([
lmsApi.getUserGrades(user.id, params.id),
lmsApi.getBookmarks(params.id)
]);
setAllGrades(grades);
const currentGrade = grades.find((g: UserGrade) => g.lesson_id === params.lessonId);
setUserGrade(currentGrade || null);
setIsBookmarked(bookmarks.some(b => b.lesson_id === params.lessonId));
}
} catch (err) {
console.error("Error al cargar los datos de la lección", err);
@@ -129,6 +134,15 @@ export default function LessonPlayerPage({ params }: { params: { id: string, les
}
};
const handleToggleBookmark = async () => {
try {
await lmsApi.toggleBookmark(params.lessonId);
setIsBookmarked(!isBookmarked);
} catch (err) {
console.error("Error toggling bookmark", err);
}
};
const getLessonStatus = (l: Lesson) => {
const grade = allGrades.find(g => g.lesson_id === l.id);
const isCurrent = l.id === params.lessonId;
@@ -215,6 +229,13 @@ export default function LessonPlayerPage({ params }: { params: { id: string, les
>
<Menu size={20} />
</button>
<button
onClick={handleToggleBookmark}
className={`p-3 rounded-xl glass border-white/10 transition-all bg-black/40 ${isBookmarked ? 'text-yellow-400' : 'text-gray-400 hover:text-white'}`}
title={isBookmarked ? "Quitar Marcador" : "Guardar Marcador"}
>
<Bookmark size={20} fill={isBookmarked ? "currentColor" : "none"} />
</button>
{hasTranscription && (
<button
onClick={() => {
+31 -4
View File
@@ -18,6 +18,7 @@ export default function CourseOutlinePage({ params }: { params: { id: string } }
const [userGrades, setUserGrades] = useState<UserGrade[]>([]);
const [isEnrolled, setIsEnrolled] = useState(false);
const [lessonDependencies, setLessonDependencies] = useState<any[]>([]);
const [instructors, setInstructors] = useState<any[]>([]);
useEffect(() => {
const fetchData = async () => {
@@ -26,6 +27,7 @@ export default function CourseOutlinePage({ params }: { params: { id: string } }
const data = await lmsApi.getCourseOutline(params.id);
setCourseData({ ...data.course, modules: data.modules });
setLessonDependencies(data.dependencies || []);
setInstructors(data.instructors || []);
if (user) {
const grades = await lmsApi.getUserGrades(user.id, params.id);
@@ -171,6 +173,25 @@ export default function CourseOutlinePage({ params }: { params: { id: string } }
)}
</div>
{instructors.length > 0 && (
<div className="mb-10 animate-in fade-in slide-in-from-left-4 duration-700">
<span className="text-[10px] font-black uppercase tracking-[0.2em] text-gray-500 mb-4 block">Equipo docente</span>
<div className="flex flex-wrap gap-6">
{instructors.map((inst) => (
<div key={inst.id} className="flex items-center gap-3 glass border-white/5 px-4 py-2 rounded-2xl hover:bg-white/5 transition-all">
<div className="w-8 h-8 rounded-full bg-blue-500/20 flex items-center justify-center border border-blue-500/30 text-blue-400 font-bold text-xs">
{inst.full_name?.charAt(0) || inst.email?.charAt(0)}
</div>
<div>
<div className="text-xs font-bold text-gray-200">{inst.full_name}</div>
<div className="text-[8px] font-black uppercase tracking-widest text-blue-500/60">{inst.role === 'primary' ? 'Instructor principal' : inst.role}</div>
</div>
</div>
))}
</div>
</div>
)}
<div className="flex items-center justify-between">
<div className="flex items-center gap-8">
<div className="flex flex-col">
@@ -291,7 +312,8 @@ export default function CourseOutlinePage({ params }: { params: { id: string } }
<div className="grid gap-3 pl-14">
{module.lessons.map((lesson: any) => {
const locked = isLessonLocked(lesson.id);
return isEnrolled ? (
const isPreviewable = lesson.is_previewable;
return (isEnrolled || isPreviewable) ? (
locked ? (
<div key={lesson.id} className="glass-card !p-4 border-white/5 opacity-60 cursor-not-allowed">
<div className="flex items-center justify-between">
@@ -316,13 +338,18 @@ export default function CourseOutlinePage({ params }: { params: { id: string } }
<div className="flex items-center gap-4">
<div className="w-10 h-10 rounded-lg bg-white/5 flex items-center justify-center group-hover:bg-blue-500/20 transition-colors">
{lesson.content_type === 'video' ? (
<PlayCircle size={18} className="text-gray-400 group-hover:text-blue-400" />
<PlayCircle size={18} className={`${isPreviewable && !isEnrolled ? 'text-green-400' : 'text-gray-400'} group-hover:text-blue-400`} />
) : (
<BookOpen size={18} className="text-gray-400 group-hover:text-blue-400" />
<BookOpen size={18} className={`${isPreviewable && !isEnrolled ? 'text-green-400' : 'text-gray-400'} group-hover:text-blue-400`} />
)}
</div>
<div>
<h3 className="text-sm font-bold text-gray-200 group-hover:text-white transition-colors">{lesson.title}</h3>
<div className="flex items-center gap-2">
<h3 className="text-sm font-bold text-gray-200 group-hover:text-white transition-colors">{lesson.title}</h3>
{isPreviewable && !isEnrolled && (
<span className="text-[8px] font-black uppercase px-1.5 py-0.5 bg-green-500/10 text-green-400 border border-green-500/20 rounded">Vista previa</span>
)}
</div>
<span className="text-[10px] font-bold uppercase tracking-widest text-gray-500">
{lesson.content_type === 'activity' ? 'Actividad Interactiva' : 'Lección en Video'}
</span>
@@ -1,280 +1,49 @@
"use client";
import React, { useState, useEffect } from "react";
import { useParams, useRouter } from "next/navigation";
import { lmsApi, GradingCategory, UserGrade, Course, Module } from "@/lib/api";
import { useAuth } from "@/context/AuthContext";
import {
Award,
BarChart3,
CheckCircle2,
ChevronRight,
Target,
BookOpen,
ArrowLeft,
TrendingUp
} from "lucide-react";
import PerformanceBar from "@/components/PerformanceBar";
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export default function StudentProgressPage() {
const { id } = useParams() as { id: string };
const router = useRouter();
const [course, setCourse] = useState<(Course & { modules: Module[], grading_categories?: GradingCategory[] }) | null>(null);
const [userGrades, setUserGrades] = useState<UserGrade[]>([]);
const [loading, setLoading] = useState(true);
const { user } = useAuth();
const loadData = React.useCallback(async () => {
try {
const { course, modules, grading_categories } = await lmsApi.getCourseOutline(id);
setCourse({ ...course, modules, grading_categories });
if (user) {
const grades = await lmsApi.getUserGrades(user.id, id);
setUserGrades(grades);
}
} catch (err) {
console.error("Error al cargar los datos de progreso", err);
} finally {
setLoading(false);
}
}, [id, user]);
useEffect(() => {
loadData();
}, [loadData]);
if (loading) return (
<div className="min-h-screen bg-slate-950 flex items-center justify-center">
<div className="w-12 h-12 border-4 border-blue-500/20 border-t-blue-500 rounded-full animate-spin"></div>
</div>
);
if (!course) return <div className="p-20 text-center text-white">Curso no encontrado.</div>;
const gradingCategories = course.grading_categories || [];
// Calculate progress
const categoryStats = gradingCategories.map(cat => {
const catLessons = course.modules.flatMap(m => m.lessons).filter(l => l.grading_category_id === cat.id);
const catGrades = userGrades.filter(g => catLessons.some(l => l.id === g.lesson_id));
const count = catLessons.length;
const completedCount = catGrades.length;
const avgScore = completedCount > 0
? (catGrades.reduce((sum, g) => sum + g.score, 0) / completedCount) * 100
: 0;
const weightedScore = (avgScore * cat.weight) / 100;
return {
...cat,
count,
completedCount,
avgScore,
weightedScore
};
});
const totalWeightedGrade = categoryStats.reduce((sum, s) => sum + s.weightedScore, 0);
import React from 'react';
import ProgressDashboard from '@/components/ProgressDashboard';
import { ChevronLeft, LayoutDashboard } from 'lucide-react';
import Link from 'next/link';
export default function ProgressPage({ params }: { params: { id: string } }) {
return (
<div className="min-h-screen bg-slate-950 text-white pb-20">
{/* Nav */}
<div className="sticky top-0 z-50 bg-slate-950/80 backdrop-blur-xl border-b border-white/5 py-4 px-8">
<div className="max-w-6xl mx-auto flex items-center justify-between">
<div className="flex items-center gap-4">
<button onClick={() => router.back()} className="p-2 hover:bg-white/5 rounded-full transition-colors">
<ArrowLeft className="w-5 h-5 text-gray-400" />
</button>
<h1 className="text-xl font-bold">{course.title}</h1>
<div className="max-w-6xl mx-auto px-6 py-20">
<div className="mb-12 flex flex-col md:flex-row md:items-end justify-between gap-6">
<div>
<Link
href={`/courses/${params.id}`}
className="flex items-center gap-2 text-blue-500 font-bold text-xs uppercase tracking-widest mb-6 hover:text-white transition-colors group"
>
<ChevronLeft size={16} className="group-hover:-translate-x-1 transition-transform" />
Volver al curso
</Link>
<div className="flex items-center gap-4 mb-2">
<div className="w-12 h-12 rounded-2xl glass border-blue-500/20 bg-blue-500/10 flex items-center justify-center">
<LayoutDashboard size={24} className="text-blue-400" />
</div>
<h1 className="text-4xl font-black tracking-tight text-white">Tu Progreso de Aprendizaje</h1>
</div>
<p className="text-gray-500 font-bold uppercase tracking-widest text-[10px]">Análisis detallado de tu avance y predicción de finalización</p>
</div>
</div>
<div className="max-w-6xl mx-auto px-8 mt-12 grid grid-cols-1 lg:grid-cols-3 gap-12">
{/* Left: Overall Progress */}
<div className="lg:col-span-1 space-y-8">
<div className="bg-gradient-to-br from-blue-600/20 to-indigo-600/20 rounded-[2.5rem] p-12 border border-blue-500/20 text-center relative overflow-hidden group">
<div className="absolute top-0 right-0 w-32 h-32 bg-blue-500/10 blur-3xl rounded-full -translate-y-1/2 translate-x-1/2 group-hover:bg-blue-500/20 transition-all duration-700"></div>
<h2 className="text-gray-400 font-bold uppercase tracking-widest text-xs mb-8">Estado General</h2>
<ProgressDashboard courseId={params.id} />
<div className="relative inline-flex items-center justify-center mb-8">
<svg className="w-48 h-48 -rotate-90">
<circle
className="text-white/5"
strokeWidth="8"
stroke="currentColor"
fill="transparent"
r="88"
cx="96"
cy="96"
/>
<circle
className="text-blue-500 transition-all duration-1000 ease-out"
strokeWidth="8"
strokeDasharray={88 * 2 * Math.PI}
strokeDashoffset={88 * 2 * Math.PI * (1 - totalWeightedGrade / 100)}
strokeLinecap="round"
stroke="currentColor"
fill="transparent"
r="88"
cx="96"
cy="96"
/>
</svg>
<div className="absolute inset-0 flex flex-col items-center justify-center">
<span className="text-6xl font-black">{Math.round(totalWeightedGrade)}%</span>
<span className="text-xs text-blue-400 font-bold uppercase tracking-widest mt-1">Calificación Actual</span>
</div>
</div>
{/* Performance Bar */}
<div className="mt-8">
<PerformanceBar
score={Math.round(totalWeightedGrade)}
passingPercentage={course.passing_percentage || 70}
/>
</div>
<div className="mt-12 p-8 glass rounded-[2.5rem] border-white/5 bg-blue-500/[0.02]">
<h3 className="text-lg font-black text-white tracking-tight mb-4">¿Cómo se calcula mi progreso?</h3>
<div className="grid md:grid-cols-3 gap-8">
<div className="space-y-2">
<span className="text-[10px] font-black uppercase tracking-widest text-blue-400">Completado</span>
<p className="text-sm text-gray-400 leading-relaxed">Consideramos una lección como completada cuando has visualizado el contenido o aprobado la evaluación correspondiente.</p>
</div>
<div className="bg-white/5 rounded-3xl p-8 border border-white/10 space-y-6">
<h3 className="text-sm font-bold uppercase tracking-[0.2em] text-gray-500 flex items-center gap-2">
<BarChart3 className="w-4 h-4" /> Resumen de Evaluaciones
</h3>
<div className="space-y-4">
{categoryStats.map(stat => (
<div key={stat.id} className="flex items-center justify-between group">
<div className="flex items-center gap-3">
<div className="w-2 h-2 rounded-full bg-blue-500 shadow-[0_0_10px_rgba(59,130,246,0.5)]"></div>
<span className="text-gray-400 group-hover:text-white transition-colors">{stat.name}</span>
</div>
<span className="font-bold">{Math.round(stat.weightedScore)} / {stat.weight}%</span>
</div>
))}
</div>
<div className="space-y-2">
<span className="text-[10px] font-black uppercase tracking-widest text-indigo-400">Predicción</span>
<p className="text-sm text-gray-400 leading-relaxed">Calculamos tu fecha estimada analizando cuántas lecciones completas por día desde que iniciaste el curso.</p>
</div>
<div className="space-y-2">
<span className="text-[10px] font-black uppercase tracking-widest text-purple-400">Recomendaciones</span>
<p className="text-sm text-gray-400 leading-relaxed">Si tu ritmo es bajo, verás sugerencias personalizadas en la página principal para ayudarte a retomar el camino.</p>
</div>
</div>
{/* Right: Detailed Breakdown */}
<div className="lg:col-span-2 space-y-12">
<section>
<h2 className="text-2xl font-black mb-8 flex items-center gap-3">
<Target className="w-8 h-8 text-blue-500" />
Desglose Detallado
</h2>
<div className="space-y-4">
{categoryStats.map(cat => (
<div key={cat.id} className="bg-white/5 border border-white/10 rounded-3xl p-8 hover:bg-white/[0.07] transition-all group">
<div className="flex items-start justify-between mb-8">
<div>
<h3 className="text-xl font-bold">{cat.name}</h3>
<p className="text-gray-400 text-sm mt-1">
Peso: {cat.weight}% de la calificación total del curso
</p>
</div>
<div className="text-right">
<div className="text-4xl font-black text-blue-500">{Math.round(cat.avgScore)}%</div>
<div className="text-[10px] text-gray-500 font-bold uppercase tracking-widest mt-1">Puntuación Promedio</div>
</div>
</div>
<div className="space-y-6">
<div className="relative h-2 bg-white/5 rounded-full overflow-hidden">
<div
className="absolute inset-y-0 left-0 bg-gradient-to-r from-blue-600 to-indigo-600 rounded-full transition-all duration-1000 ease-out"
style={{ width: `${cat.avgScore}%` }}
></div>
</div>
<div className="flex items-center justify-between text-sm">
<div className="flex items-center gap-4">
<div className="flex items-center gap-2">
<BookOpen className="w-4 h-4 text-gray-500" />
<span className="text-gray-400">{cat.completedCount} / {cat.count} evaluaciones completadas</span>
</div>
</div>
{cat.completedCount === cat.count && (
<div className="flex items-center gap-2 text-green-400 font-bold">
<CheckCircle2 className="w-4 h-4" />
Categoría Finalizada
</div>
)}
</div>
</div>
</div>
))}
</div>
</section>
{/* Certificate Section */}
{totalWeightedGrade >= (course.passing_percentage || 70) ? (
<section className="bg-green-500/10 border border-green-500/20 rounded-[2rem] p-8 flex items-center justify-between">
<div className="flex items-center gap-6">
<div className="w-16 h-16 rounded-2xl bg-green-500/20 flex items-center justify-center text-green-400">
<Award className="w-8 h-8" />
</div>
<div>
<h3 className="text-lg font-bold text-green-400">¡Curso Completado!</h3>
<p className="text-sm text-green-300/60 mt-0.5">
¡Felicidades! Has aprobado <b>{course.title}</b>.
</p>
</div>
</div>
<button
onClick={() => {
if (!course.certificate_template || !user) {
alert("Plantilla de certificado no disponible.");
return;
}
const filledTemplate = course.certificate_template
.replace(/{{student_name}}/g, user.full_name)
.replace(/{{course_title}}/g, course.title)
.replace(/{{date}}/g, new Date().toLocaleDateString())
.replace(/{{score}}/g, Math.round(totalWeightedGrade).toString());
const win = window.open('', '_blank');
if (win) {
win.document.write(filledTemplate);
win.document.close();
// Wait visuals to render then print
setTimeout(() => {
win.focus();
win.print();
}, 500);
}
}}
className="px-6 py-3 bg-green-500 hover:bg-green-600 text-white font-bold rounded-xl transition-colors shadow-lg shadow-green-900/20 flex items-center gap-2"
>
<Award className="w-4 h-4" />
Descargar Certificado
</button>
</section>
) : (
<section className="bg-indigo-600/10 border border-indigo-500/20 rounded-[2rem] p-8 flex items-center justify-between">
<div className="flex items-center gap-6">
<div className="w-16 h-16 rounded-2xl bg-indigo-500/20 flex items-center justify-center text-indigo-400">
<TrendingUp className="w-8 h-8" />
</div>
<div>
<h3 className="text-lg font-bold">Ruta de Certificación</h3>
<p className="text-sm text-indigo-300/60 mt-0.5">
Mantén {course.passing_percentage || 70}% o más para obtener tu certificado verificado.
</p>
</div>
</div>
<div className="text-indigo-400 font-bold text-sm">
Falta {Math.max(0, (course.passing_percentage || 70) - Math.round(totalWeightedGrade))}%
</div>
</section>
)}
</div>
</div>
</div>
@@ -0,0 +1,85 @@
"use client";
import { useEffect, useState, Suspense } from "react";
import { useRouter, useSearchParams } from "next/navigation";
import { lmsApi } from "@/lib/api";
import { useAuth } from "@/context/AuthContext";
function LtiLaunchContent() {
const router = useRouter();
const searchParams = useSearchParams();
const { login } = useAuth();
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const handleLaunch = async () => {
const token = searchParams.get("token");
const target = searchParams.get("target") || "/dashboard";
if (!token) {
setError("No launch token provided");
return;
}
try {
// 1. Temporarily save token so api client can use it for getMe
localStorage.setItem("experience_token", token);
// 2. Fetch user details
const user = await lmsApi.getMe();
// 3. Initialize session in AuthContext
login(user, token);
// 4. Redirect to final destination
router.replace(target);
} catch (err: any) {
console.error("LTI Launch Error:", err);
setError("Failed to initialize session. Please try again.");
}
};
handleLaunch();
}, [searchParams, login, router]);
if (error) {
return (
<div className="min-h-screen flex items-center justify-center bg-[#0a0a0a] text-white p-6">
<div className="max-w-md w-full bg-white/5 border border-white/10 rounded-3xl p-8 text-center space-y-4">
<div className="text-4xl"></div>
<h1 className="text-2xl font-black text-red-400">Error de Inicio</h1>
<p className="text-gray-400">{error}</p>
<button
onClick={() => router.push("/auth/login")}
className="btn-primary w-full py-3 rounded-xl font-bold uppercase tracking-widest text-xs"
>
Volver al Login
</button>
</div>
</div>
);
}
return (
<div className="min-h-screen flex items-center justify-center bg-[#0a0a0a] text-white">
<div className="text-center space-y-6">
<div className="relative w-20 h-20 mx-auto">
<div className="absolute inset-0 border-t-4 border-purple-500 rounded-full animate-spin"></div>
<div className="absolute inset-2 border-t-4 border-blue-500 rounded-full animate-spin-slow"></div>
</div>
<div>
<h1 className="text-2xl font-black tracking-tighter uppercase italic">Iniciando Sesión</h1>
<p className="text-gray-500 text-sm font-bold tracking-widest uppercase mt-2">OpenCCB LTI Gateway</p>
</div>
</div>
</div>
);
}
export default function LtiLaunchPage() {
return (
<Suspense fallback={null}>
<LtiLaunchContent />
</Suspense>
);
}
@@ -48,6 +48,9 @@ export default function AppHeader() {
<Link href="/my-learning" className="text-[10px] font-black uppercase tracking-[0.2em] text-gray-400 hover:text-white transition-colors">
{t('nav.myLearning')}
</Link>
<Link href="/bookmarks" className="text-[10px] font-black uppercase tracking-[0.2em] text-gray-400 hover:text-white transition-colors">
{t('nav.bookmarks')}
</Link>
</nav>
<div className="flex items-center gap-2 md:gap-4">
@@ -117,6 +120,13 @@ export default function AppHeader() {
>
{t('nav.myLearning')}
</Link>
<Link
href="/bookmarks"
onClick={() => setIsMenuOpen(false)}
className="text-sm font-black uppercase tracking-widest text-gray-300 hover:text-white border-l-2 border-transparent hover:border-blue-500 pl-4 transition-all"
>
{t('nav.bookmarks')}
</Link>
<div className="pt-6 mt-6 border-t border-white/5 space-y-4">
<div className="flex items-center gap-3 px-4 py-2 rounded-xl bg-white/5">
@@ -0,0 +1,181 @@
"use client";
import React, { useEffect, useState } from 'react';
import { lmsApi, ProgressStats } from '@/lib/api';
import {
LineChart,
Line,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
ResponsiveContainer,
AreaChart,
Area
} from 'recharts';
import { Calendar, CheckCircle2, TrendingUp, Clock, AlertTriangle } from 'lucide-react';
import { format, parseISO } from 'date-fns';
import { es } from 'date-fns/locale';
interface ProgressDashboardProps {
courseId: string;
}
const ProgressDashboard: React.FC<ProgressDashboardProps> = ({ courseId }) => {
const [stats, setStats] = useState<ProgressStats | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const fetchStats = async () => {
try {
const data = await lmsApi.getProgressStats(courseId);
setStats(data);
} catch (err) {
console.error("Error fetching progress stats:", err);
setError("No se pudieron cargar las estadísticas de progreso.");
} finally {
setLoading(false);
}
};
fetchStats();
}, [courseId]);
if (loading) return <div className="p-8 animate-pulse space-y-4">
<div className="h-40 bg-white/5 rounded-3xl" />
<div className="h-64 bg-white/5 rounded-3xl" />
</div>;
if (error || !stats) return <div className="p-8 text-center text-red-400">
<AlertTriangle className="mx-auto mb-2" />
{error || "Error al cargar datos."}
</div>;
const chartData = stats.daily_completions.map(d => ({
date: format(parseISO(d.date), 'dd MMM', { locale: es }),
count: d.count
}));
return (
<div className="space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700">
{/* Summary Cards */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div className="glass p-6 rounded-3xl border-white/5 space-y-2">
<div className="flex items-center justify-between">
<span className="text-[10px] font-black uppercase tracking-widest text-blue-400">Progreso Total</span>
<TrendingUp size={16} className="text-blue-400" />
</div>
<div className="flex items-baseline gap-2">
<span className="text-3xl font-black text-white">{Math.round(stats.progress_percentage)}%</span>
<span className="text-xs text-gray-500 font-bold uppercase tracking-widest">Completado</span>
</div>
<div className="w-full h-1.5 bg-white/10 rounded-full overflow-hidden">
<div
className="h-full bg-blue-500 shadow-[0_0_10px_rgba(59,130,246,0.5)] transition-all duration-1000"
style={{ width: `${stats.progress_percentage}%` }}
/>
</div>
</div>
<div className="glass p-6 rounded-3xl border-white/5 space-y-2">
<div className="flex items-center justify-between">
<span className="text-[10px] font-black uppercase tracking-widest text-green-400">Lecciones</span>
<CheckCircle2 size={16} className="text-green-400" />
</div>
<div className="flex items-baseline gap-2">
<span className="text-3xl font-black text-white">{stats.completed_lessons}</span>
<span className="text-xs text-gray-500 font-bold uppercase tracking-widest">de {stats.total_lessons}</span>
</div>
<p className="text-[10px] text-gray-400 font-medium">Lecciones finalizadas con éxito</p>
</div>
<div className="glass p-6 rounded-3xl border-white/5 space-y-2">
<div className="flex items-center justify-between">
<span className="text-[10px] font-black uppercase tracking-widest text-indigo-400">Predicción</span>
<Clock size={16} className="text-indigo-400" />
</div>
<div className="space-y-1">
<span className="text-sm font-black text-white block">
{stats.estimated_completion_date
? format(parseISO(stats.estimated_completion_date), "d 'de' MMMM", { locale: es })
: "N/A"
}
</span>
<span className="text-[10px] text-gray-500 font-bold uppercase tracking-widest">Fecha estimada de cierre</span>
</div>
</div>
<div className="glass p-6 rounded-3xl border-white/5 space-y-2">
<div className="flex items-center justify-between">
<span className="text-[10px] font-black uppercase tracking-widest text-purple-400">Estado</span>
<Calendar size={16} className="text-purple-400" />
</div>
<div className="space-y-1">
<span className="text-sm font-black text-white block uppercase">
{stats.progress_percentage >= 80 ? 'Excelente' : stats.progress_percentage >= 50 ? 'Buen Ritmo' : 'En Progreso'}
</span>
<span className="text-[10px] text-gray-500 font-bold uppercase tracking-widest">Según tu ritmo actual</span>
</div>
</div>
</div>
{/* Activity Chart */}
<div className="glass p-8 rounded-[2.5rem] border-white/5">
<div className="flex items-center justify-between mb-8">
<div>
<h3 className="text-lg font-black text-white tracking-tight">Actividad de Aprendizaje</h3>
<p className="text-xs text-gray-500 font-bold uppercase tracking-widest">Lecciones completadas por día (Últimos 30 días)</p>
</div>
</div>
<div className="h-[300px] w-full">
<ResponsiveContainer width="100%" height="100%">
<AreaChart data={chartData}>
<defs>
<linearGradient id="colorCount" x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stopColor="#3b82f6" stopOpacity={0.3} />
<stop offset="95%" stopColor="#3b82f6" stopOpacity={0} />
</linearGradient>
</defs>
<CartesianGrid strokeDasharray="3 3" vertical={false} stroke="rgba(255,255,255,0.05)" />
<XAxis
dataKey="date"
axisLine={false}
tickLine={false}
tick={{ fill: '#6b7280', fontSize: 10, fontWeight: 900 }}
dy={10}
/>
<YAxis
hide={true}
/>
<Tooltip
contentStyle={{
backgroundColor: 'rgba(0,0,0,0.8)',
border: '1px solid rgba(255,255,255,0.1)',
borderRadius: '16px',
backdropFilter: 'blur(10px)',
fontSize: '12px',
fontWeight: 'bold'
}}
itemStyle={{ color: '#3b82f6' }}
cursor={{ stroke: 'rgba(59,130,246,0.2)', strokeWidth: 2 }}
/>
<Area
type="monotone"
dataKey="count"
stroke="#3b82f6"
strokeWidth={4}
fillOpacity={1}
fill="url(#colorCount)"
animationDuration={2000}
/>
</AreaChart>
</ResponsiveContainer>
</div>
</div>
</div>
);
};
export default ProgressDashboard;
@@ -183,7 +183,7 @@ export default function PeerReviewPlayer({ courseId, lessonId, block }: PeerRevi
>
<span className="text-2xl mb-2 block group-hover:scale-110 transition-transform">👀</span>
<div className="font-bold text-purple-400">Review a Peer</div>
<div className="text-xs text-gray-500 mt-1">Earn credit by reviewing other students' work.</div>
<div className="text-xs text-gray-500 mt-1">Earn credit by reviewing other students&apos; work.</div>
</button>
<button
+45 -1
View File
@@ -105,6 +105,16 @@ export interface Block {
metadata?: any;
}
export interface CourseInstructor {
id: string;
course_id: string;
user_id: string;
role: 'primary' | 'instructor' | 'assistant';
created_at: string;
email: string;
full_name: string;
}
export interface Lesson {
id: string;
module_id: string;
@@ -127,6 +137,7 @@ export interface Lesson {
position: number;
due_date?: string;
important_date_type?: 'exam' | 'assignment' | 'milestone' | 'live-session';
is_previewable: boolean;
created_at: string;
}
@@ -199,6 +210,28 @@ export interface Notification {
created_at: string;
}
export interface DailyProgress {
date: string;
count: number;
}
export interface UserBookmark {
id: string;
organization_id: string;
user_id: string;
course_id: string;
lesson_id: string;
created_at: string;
}
export interface ProgressStats {
total_lessons: number;
completed_lessons: number;
progress_percentage: number;
daily_completions: DailyProgress[];
estimated_completion_date?: string;
}
export interface AuthResponse {
user: User;
token: string;
@@ -393,6 +426,7 @@ export const lmsApi = {
modules: Module[],
grading_categories: GradingCategory[],
organization: Organization,
instructors?: CourseInstructor[],
dependencies?: LessonDependency[]
}> {
return apiFetch(`/courses/${courseId}/outline`);
@@ -417,7 +451,7 @@ export const lmsApi = {
},
async getMe(): Promise<User> {
return apiFetch('/auth/me', {}, true); // isCMS = true
return apiFetch('/auth/me', {}, false);
},
initSSOLogin(orgId: string): void {
@@ -663,4 +697,14 @@ export const lmsApi = {
async getMySubmissionFeedback(courseId: string, lessonId: string): Promise<PeerReview[]> {
return apiFetch(`/courses/${courseId}/lessons/${lessonId}/feedback`);
},
async getProgressStats(courseId: string): Promise<ProgressStats> {
return apiFetch(`/courses/${courseId}/progress-stats`);
},
async toggleBookmark(lessonId: string): Promise<void> {
return apiFetch(`/lessons/${lessonId}/bookmark`, { method: 'POST' });
},
async getBookmarks(courseId?: string): Promise<UserBookmark[]> {
const query = courseId ? `?cohort_id=${courseId}` : '';
return apiFetch(`/bookmarks${query}`);
}
};
+1
View File
@@ -10,6 +10,7 @@
"nav": {
"catalog": "Catalog",
"myLearning": "My Learning",
"bookmarks": "Bookmarks",
"profile": "Profile",
"signOut": "Sign Out"
},
+1
View File
@@ -10,6 +10,7 @@
"nav": {
"catalog": "Catálogo",
"myLearning": "Mi Aprendizaje",
"bookmarks": "Marcadores",
"profile": "Perfil",
"signOut": "Cerrar Sesión"
},
+1
View File
@@ -10,6 +10,7 @@
"nav": {
"catalog": "Catálogo",
"myLearning": "Meu Aprendizado",
"bookmarks": "Favoritos",
"profile": "Perfil",
"signOut": "Sair"
},
@@ -58,6 +58,7 @@ export default function LessonEditor({ params }: { params: { id: string; lessonI
const [allowRetry, setAllowRetry] = useState(true);
const [dueDate, setDueDate] = useState<string>("");
const [importantDateType, setImportantDateType] = useState<string>("");
const [isPreviewable, setIsPreviewable] = useState(false);
// Rubric State
const [courseRubrics, setCourseRubrics] = useState<Rubric[]>([]);
@@ -122,6 +123,7 @@ export default function LessonEditor({ params }: { params: { id: string; lessonI
setAllowRetry(lessonData.allow_retry);
setDueDate(lessonData.due_date ? new Date(lessonData.due_date).toISOString().split('T')[0] : "");
setImportantDateType(lessonData.important_date_type || "");
setIsPreviewable(lessonData.is_previewable || false);
if (lessonData.metadata?.blocks) {
setBlocks(lessonData.metadata.blocks);
@@ -224,7 +226,8 @@ export default function LessonEditor({ params }: { params: { id: string; lessonI
max_attempts: maxAttempts,
allow_retry: allowRetry,
due_date: dueDate ? new Date(dueDate).toISOString() : undefined,
important_date_type: (importantDateType || undefined) as 'exam' | 'assignment' | 'milestone' | 'live-session' | undefined
important_date_type: (importantDateType || undefined) as 'exam' | 'assignment' | 'milestone' | 'live-session' | undefined,
is_previewable: isPreviewable
});
setLesson(updated);
setEditMode(false);
@@ -436,6 +439,27 @@ export default function LessonEditor({ params }: { params: { id: string; lessonI
</label>
</div>
<div className="flex items-center justify-between pt-6 border-t border-white/5">
<div>
<h3 className="text-xl font-bold flex items-center gap-2">
<span className="text-blue-500">🔓</span> Course Preview
</h3>
<p className="text-sm text-gray-500 mt-1">Allow students to view this lesson without being enrolled</p>
</div>
<label className="relative inline-flex items-center cursor-pointer group">
<input
type="checkbox"
checked={isPreviewable}
onChange={(e) => setIsPreviewable(e.target.checked)}
className="sr-only peer"
/>
<div className="w-14 h-8 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[4px] after:start-[4px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-6 after:w-6 after:transition-all peer-checked:bg-blue-600 group-hover:after:scale-110 transition-all"></div>
<span className="ms-3 text-sm font-bold uppercase tracking-widest text-gray-400 peer-checked:text-blue-400 transition-colors">
{isPreviewable ? "Preview Enabled" : "Preview Disabled"}
</span>
</label>
</div>
{isGraded && (
<>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
@@ -0,0 +1,257 @@
"use client";
import { useEffect, useState } from "react";
import { cmsApi, CourseInstructor, User } from "@/lib/api";
import { useParams } from "next/navigation";
import { Plus, Trash2, UserPlus, Shield, ShieldCheck, ShieldAlert, X, Search, Check, Mail, GraduationCap } from "lucide-react";
import CourseEditorLayout from "@/components/CourseEditorLayout";
export default function CourseTeamPage() {
const { id } = useParams() as { id: string };
const [instructors, setInstructors] = useState<CourseInstructor[]>([]);
const [loading, setLoading] = useState(true);
const [isAddModalOpen, setIsAddModalOpen] = useState(false);
const [searchQuery, setSearchQuery] = useState("");
const [users, setUsers] = useState<User[]>([]);
const [searching, setSearching] = useState(false);
const [selectedRole, setSelectedRole] = useState<'instructor' | 'assistant'>('instructor');
useEffect(() => {
loadTeam();
}, [id]);
const loadTeam = async () => {
try {
setLoading(true);
const team = await cmsApi.getCourseTeam(id);
setInstructors(team);
} catch (err) {
console.error("Failed to load team:", err);
} finally {
setLoading(false);
}
};
const handleSearch = async (e: React.FormEvent) => {
e.preventDefault();
if (!searchQuery.includes('@')) return; // Basic validation for email search
try {
setSearching(true);
// This is a bit of a hack since we don't have a specific "search users" endpoint
// for instructors. Let's assume listOrganizationsUsers or similar could work,
// or just try to find by email if we had that endpoint.
// For now, let's try to list all users and filter locally as a fallback.
const allUsers = await cmsApi.getUsers();
const filtered = allUsers.filter((u: User) =>
u.email.toLowerCase().includes(searchQuery.toLowerCase()) ||
u.full_name.toLowerCase().includes(searchQuery.toLowerCase())
);
setUsers(filtered);
} catch (err) {
console.error("Search failed:", err);
} finally {
setSearching(false);
}
};
const handleAddMember = async (user: User) => {
try {
await cmsApi.addTeamMember(id, user.email, selectedRole);
setIsAddModalOpen(false);
setSearchQuery("");
setUsers([]);
loadTeam();
} catch (err) {
console.error("Failed to add member:", err);
alert("Failed to add team member.");
}
};
const handleRemoveMember = async (userId: string) => {
if (!confirm("Are you sure you want to remove this instructor?")) return;
try {
await cmsApi.removeTeamMember(id, userId);
setInstructors(instructors.filter(i => i.user_id !== userId));
} catch (err) {
console.error("Failed to remove member:", err);
alert("Failed to remove team member.");
}
};
const getRoleIcon = (role: string) => {
switch (role) {
case 'primary': return <ShieldAlert className="w-4 h-4 text-orange-400" />;
case 'instructor': return <ShieldCheck className="w-4 h-4 text-blue-400" />;
default: return <Shield className="w-4 h-4 text-gray-400" />;
}
};
const getRoleLabel = (role: string) => {
switch (role) {
case 'primary': return 'Primary Instructor';
case 'instructor': return 'Instructor';
default: return 'Assistant';
}
};
return (
<div className="max-w-6xl mx-auto p-8">
<div className="flex items-center justify-between mb-8">
<div>
<h1 className="text-3xl font-bold">Course Team</h1>
<p className="text-gray-400 mt-1">Manage multiple instructors and assistants for this course</p>
</div>
<button
onClick={() => setIsAddModalOpen(true)}
className="btn-premium px-6 py-2.5 flex items-center gap-2 group"
>
<UserPlus className="w-4 h-4 group-hover:scale-110 transition-transform" /> Add Member
</button>
</div>
<CourseEditorLayout activeTab="team">
<div className="grid gap-4">
{loading ? (
<div className="py-20 text-center text-gray-500 animate-pulse">Loading team members...</div>
) : instructors.length === 0 ? (
<div className="py-20 glass rounded-2xl flex flex-col items-center justify-center text-gray-500 gap-4">
<GraduationCap className="w-12 h-12 opacity-20" />
<p>No instructors assigned yet.</p>
</div>
) : (
instructors.map((inst) => (
<div key={inst.id} className="glass p-6 rounded-2xl border-white/5 flex items-center justify-between group">
<div className="flex items-center gap-6">
<div className="w-12 h-12 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center text-xl font-bold border-2 border-white/10 shadow-xl">
{inst.full_name?.charAt(0) || inst.email?.charAt(0)}
</div>
<div className="space-y-1">
<h3 className="text-lg font-bold flex items-center gap-2">
{inst.full_name}
{inst.role === 'primary' && (
<span className="text-[10px] font-black uppercase px-2 py-0.5 bg-orange-500/10 text-orange-400 border border-orange-500/20 rounded-full">
Owner
</span>
)}
</h3>
<div className="flex items-center gap-3 text-sm text-gray-400">
<span className="flex items-center gap-1.5">
<Mail className="w-3.5 h-3.5 opacity-60" /> {inst.email}
</span>
<span className="w-1 h-1 rounded-full bg-gray-700" />
<span className="flex items-center gap-1.5">
{getRoleIcon(inst.role)} {getRoleLabel(inst.role)}
</span>
</div>
</div>
</div>
<div className="flex items-center gap-2">
{inst.role !== 'primary' && (
<button
onClick={() => handleRemoveMember(inst.user_id)}
className="p-3 rounded-xl hover:bg-red-500/10 text-gray-500 hover:text-red-400 transition-all active:scale-95"
title="Remove member"
>
<Trash2 className="w-5 h-5" />
</button>
)}
</div>
</div>
))
)}
</div>
</CourseEditorLayout>
{/* Add Member Modal */}
{isAddModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-300">
<div className="bg-[#1a1c22] border border-white/10 rounded-3xl w-full max-w-lg overflow-hidden shadow-2xl animate-in zoom-in-95 duration-300">
<div className="p-8 border-b border-white/5 flex justify-between items-center">
<div>
<h2 className="text-2xl font-bold">Add Team Member</h2>
<p className="text-sm text-gray-400 mt-1">Search for a user by name or email</p>
</div>
<button onClick={() => setIsAddModalOpen(false)} className="p-2 hover:bg-white/5 rounded-full transition-colors text-gray-500">
<X className="w-6 h-6" />
</button>
</div>
<div className="p-8 space-y-8">
<form onSubmit={handleSearch} className="relative">
<Search className="absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500" />
<input
autoFocus
placeholder="Type name or email..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="w-full bg-white/5 border border-white/10 rounded-2xl pl-12 pr-4 py-4 text-sm focus:outline-none focus:border-blue-500 transition-all font-medium"
/>
{searching && (
<div className="absolute right-4 top-1/2 -translate-y-1/2">
<div className="w-5 h-5 border-2 border-white/20 border-t-blue-500 rounded-full animate-spin" />
</div>
)}
</form>
<div className="space-y-4">
<label className="block">
<span className="text-[10px] font-black uppercase tracking-widest text-gray-500 mb-3 block">Assign Role</span>
<div className="grid grid-cols-2 gap-3">
<button
onClick={() => setSelectedRole('instructor')}
className={`flex items-center gap-3 p-4 rounded-2xl border transition-all text-left ${selectedRole === 'instructor' ? 'bg-blue-600/10 border-blue-500/50 text-blue-400' : 'bg-white/5 border-white/10 text-gray-500 hover:border-white/20'}`}
>
<ShieldCheck className="w-5 h-5" />
<div>
<div className="font-bold text-sm">Instructor</div>
<div className="text-[10px] mt-0.5 opacity-60">Full access</div>
</div>
</button>
<button
onClick={() => setSelectedRole('assistant')}
className={`flex items-center gap-3 p-4 rounded-2xl border transition-all text-left ${selectedRole === 'assistant' ? 'bg-blue-600/10 border-blue-500/50 text-blue-400' : 'bg-white/5 border-white/10 text-gray-500 hover:border-white/20'}`}
>
<Shield className="w-5 h-5" />
<div>
<div className="font-bold text-sm">Assistant</div>
<div className="text-[10px] mt-0.5 opacity-60">Limited access</div>
</div>
</button>
</div>
</label>
</div>
<div className="space-y-3 max-h-60 overflow-y-auto pr-2 custom-scrollbar">
{users.length > 0 ? (
users.map(u => (
<button
key={u.id}
onClick={() => handleAddMember(u)}
className="w-full flex items-center justify-between p-4 rounded-2xl bg-white/5 border border-white/10 hover:border-blue-500/30 hover:bg-white/10 transition-all group"
>
<div className="flex items-center gap-4 text-left">
<div className="w-10 h-10 rounded-full bg-white/10 flex items-center justify-center font-bold text-sm">
{u.full_name.charAt(0)}
</div>
<div>
<div className="font-bold text-sm">{u.full_name}</div>
<div className="text-xs text-gray-500">{u.email}</div>
</div>
</div>
<div className="w-8 h-8 rounded-lg bg-blue-500/0 flex items-center justify-center group-hover:bg-blue-500/20 transition-all">
<Plus className="w-4 h-4 text-blue-400 opacity-0 group-hover:opacity-100" />
</div>
</button>
))
) : searchQuery && !searching ? (
<div className="py-8 text-center text-gray-600 italic text-sm">No users found matching your search.</div>
) : null}
</div>
</div>
</div>
</div>
)}
</div>
);
}
+256
View File
@@ -0,0 +1,256 @@
"use client";
import React, { useEffect, useState, useCallback } from "react";
import {
Search, Image as ImageIcon, FileText, Film, File as FileIcon,
Loader2, Upload, Trash2, ExternalLink, Filter, Plus, ChevronLeft
} from "lucide-react";
import { cmsApi, Asset, AssetFilters, getImageUrl } from "@/lib/api";
import { useAuth } from "@/context/AuthContext";
import { useTranslation } from "@/context/I18nContext";
import Link from "next/link";
export default function AssetLibraryPage() {
const { t } = useTranslation();
const { user } = useAuth();
const [assets, setAssets] = useState<Asset[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [searchTerm, setSearchTerm] = useState("");
const [filterType, setFilterType] = useState<string>("all");
const [isUploading, setIsUploading] = useState(false);
const [uploadProgress, setUploadProgress] = useState(0);
const loadAssets = useCallback(async () => {
setIsLoading(true);
try {
const filters: AssetFilters = {};
if (searchTerm) filters.search = searchTerm;
if (filterType !== "all") filters.mimetype = filterType;
const data = await cmsApi.getAssets(filters);
setAssets(data);
} catch (error) {
console.error("Failed to load assets:", error);
} finally {
setIsLoading(false);
}
}, [searchTerm, filterType]);
useEffect(() => {
const timer = setTimeout(() => {
loadAssets();
}, 300);
return () => clearTimeout(timer);
}, [loadAssets]);
const handleFileUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
const files = e.target.files;
if (!files || files.length === 0) return;
setIsUploading(true);
setUploadProgress(0);
try {
for (let i = 0; i < files.length; i++) {
await cmsApi.uploadAsset(files[i], (pct) => {
setUploadProgress(pct);
});
}
loadAssets();
} catch (error) {
console.error("Upload failed:", error);
alert("Failed to upload assets.");
} finally {
setIsUploading(false);
setUploadProgress(0);
}
};
const handleDelete = async (id: string) => {
if (!confirm("Are you sure you want to delete this asset? This will break content that uses it.")) return;
try {
await cmsApi.deleteAsset(id);
setAssets(prev => prev.filter(a => a.id !== id));
} catch (error) {
console.error("Delete failed:", error);
alert("Failed to delete asset.");
}
};
const getIcon = (mimetype: string) => {
if (mimetype.startsWith('image/')) return <ImageIcon className="w-8 h-8 text-blue-400" />;
if (mimetype.startsWith('video/')) return <Film className="w-8 h-8 text-purple-400" />;
if (mimetype.includes('pdf')) return <FileText className="w-8 h-8 text-red-400" />;
return <FileIcon className="w-8 h-8 text-gray-400" />;
};
return (
<div className="min-h-screen bg-black text-white pt-24 pb-12 px-6">
<div className="max-w-7xl mx-auto space-y-8">
{/* Header */}
<div className="flex flex-col md:flex-row md:items-end justify-between gap-4">
<div className="space-y-1">
<Link href="/" className="flex items-center gap-2 text-gray-500 hover:text-blue-400 transition-colors text-xs uppercase font-bold tracking-widest mb-2">
<ChevronLeft className="w-4 h-4" />
Back to Dashboard
</Link>
<h1 className="text-4xl font-black tracking-tight flex items-center gap-4">
Global <span className="gradient-text">Asset Library</span>
</h1>
<p className="text-gray-500 text-sm font-medium">Manage and reuse your organization's media files across all courses.</p>
</div>
<div className="flex gap-3">
<label className="flex items-center gap-2 px-6 py-3 bg-blue-600 hover:bg-blue-500 text-white rounded-2xl font-bold transition-all cursor-pointer shadow-lg shadow-blue-600/20 active:scale-95">
<Upload className="w-5 h-5" />
Upload Files
<input
type="file"
multiple
className="hidden"
onChange={handleFileUpload}
disabled={isUploading}
/>
</label>
</div>
</div>
{/* Upload Progress Bar */}
{isUploading && (
<div className="w-full bg-white/5 rounded-2xl border border-white/10 p-4 animate-in fade-in slide-in-from-top-4">
<div className="flex justify-between items-center mb-2">
<span className="text-xs font-black uppercase tracking-widest text-blue-400">Uploading Assets...</span>
<span className="text-xs font-bold text-white">{uploadProgress}%</span>
</div>
<div className="w-full h-2 bg-white/5 rounded-full overflow-hidden">
<div
className="h-full bg-blue-500 transition-all duration-300 shadow-[0_0_10px_rgba(59,130,246,0.5)]"
style={{ width: `${uploadProgress}%` }}
/>
</div>
</div>
)}
{/* Controls */}
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
<div className="md:col-span-2 relative group">
<Search className="absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500 group-focus-within:text-blue-500 transition-colors" />
<input
type="text"
placeholder="Search by filename..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="w-full bg-white/5 border border-white/10 rounded-2xl pl-12 pr-4 py-4 text-sm font-medium focus:outline-none focus:border-blue-500/50 focus:bg-white/10 transition-all"
/>
</div>
<div className="relative">
<Filter className="absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500" />
<select
value={filterType}
onChange={(e) => setFilterType(e.target.value)}
className="w-full bg-white/5 border border-white/10 rounded-2xl pl-12 pr-4 py-4 text-sm font-bold uppercase tracking-widest focus:outline-none focus:border-blue-500/50 appearance-none cursor-pointer hover:bg-white/10 transition-all"
>
<option value="all" className="bg-gray-900">All Types</option>
<option value="image/" className="bg-gray-900">Images</option>
<option value="video/" className="bg-gray-900">Videos</option>
<option value="application/pdf" className="bg-gray-900">Documents (PDF)</option>
</select>
</div>
<div className="flex items-center justify-end px-4 text-gray-500 font-bold text-[10px] uppercase tracking-[0.2em]">
{assets.length} Total Assets
</div>
</div>
{/* Asset Grid */}
{isLoading && assets.length === 0 ? (
<div className="flex flex-col items-center justify-center py-40 gap-4">
<Loader2 className="w-12 h-12 animate-spin text-blue-500" />
<span className="text-[10px] uppercase font-black tracking-[0.3em] text-gray-500">Retrieving Cloud Assets...</span>
</div>
) : assets.length === 0 ? (
<div className="py-40 flex flex-col items-center gap-6 border-2 border-dashed border-white/5 rounded-[40px] bg-white/[0.02]">
<div className="p-8 bg-white/5 rounded-[32px] border border-white/5">
<Plus className="w-12 h-12 text-gray-700" />
</div>
<div className="text-center space-y-2">
<h3 className="text-xl font-bold text-gray-400">Your library is empty</h3>
<p className="text-sm text-gray-600 font-medium">Start contributing to your organization's shared assets.</p>
</div>
</div>
) : (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
{assets.map((asset) => (
<div
key={asset.id}
className="group bg-white/5 border border-white/5 rounded-[32px] overflow-hidden hover:bg-white/10 hover:border-white/10 transition-all duration-300 hover:-translate-y-1 relative"
>
{/* Preview Area */}
<div className="aspect-video w-full bg-black/40 flex items-center justify-center relative overflow-hidden">
{asset.mimetype.startsWith('image/') ? (
<div
className="w-full h-full bg-cover bg-center transition-transform duration-700 group-hover:scale-110"
style={{ backgroundImage: `url(${getImageUrl(asset.storage_path)})` }}
/>
) : (
<div className="w-full h-full flex items-center justify-center">
{getIcon(asset.mimetype)}
</div>
)}
<div className="absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-4">
<a
href={getImageUrl(asset.storage_path)}
target="_blank"
rel="noreferrer"
className="p-3 bg-white/10 hover:bg-white/20 rounded-2xl border border-white/10 transition-all"
title="View Full"
>
<ExternalLink className="w-5 h-5" />
</a>
<button
onClick={() => handleDelete(asset.id)}
className="p-3 bg-red-500/10 hover:bg-red-500/20 text-red-500 rounded-2xl border border-red-500/10 transition-all"
title="Delete Asset"
>
<Trash2 className="w-5 h-5" />
</button>
</div>
<div className="absolute top-4 left-4">
<div className="px-3 py-1 bg-black/60 backdrop-blur-md rounded-full text-[9px] font-black uppercase tracking-widest border border-white/10">
{asset.mimetype.split('/')[1]}
</div>
</div>
</div>
{/* Content Info */}
<div className="p-6 space-y-3">
<h3 className="text-sm font-bold text-gray-200 truncate pr-2" title={asset.filename}>
{asset.filename}
</h3>
<div className="flex items-center justify-between">
<div className="flex flex-col">
<span className="text-[10px] text-gray-500 uppercase font-bold tracking-wider">
{(asset.size_bytes / 1024 / 1024).toFixed(2)} MB
</span>
<span className="text-[9px] text-gray-600 font-medium">
{new Date(asset.created_at).toLocaleDateString()}
</span>
</div>
{asset.course_id && (
<div className="px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-md text-[8px] font-bold uppercase tracking-widest border border-blue-500/10">
Course Linked
</div>
)}
</div>
</div>
</div>
))}
</div>
)}
</div>
</div>
);
}
+4 -4
View File
@@ -171,7 +171,7 @@ export default function StudioDashboard() {
<div className="flex items-center gap-3">
<label className="flex items-center gap-2 px-6 py-3 bg-white/5 hover:bg-white/10 border border-white/10 rounded-xl font-bold transition-all cursor-pointer active:scale-95">
<Upload size={18} />
Import
Importar
<input type="file" accept=".json" onChange={handleImport} className="hidden" />
</label>
<button
@@ -199,7 +199,7 @@ export default function StudioDashboard() {
</div>
) : courses.length === 0 ? (
<div className="text-center py-20 glass-card border-dashed border-white/10">
<p className="text-gray-500">You haven&apos;t created any courses yet.</p>
<p className="text-gray-500">Aún no has creado ningún curso.</p>
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
@@ -227,10 +227,10 @@ export default function StudioDashboard() {
</button>
</div>
<h3 className="font-bold text-lg mb-2 group-hover:text-blue-400 transition-colors">{course.title}</h3>
<p className="text-sm text-gray-400 line-clamp-2">{course.description || "No description provided."}</p>
<p className="text-sm text-gray-400 line-clamp-2">{course.description || "Sin descripción disponible."}</p>
</div>
<div className="flex items-center justify-between mt-6 pt-4 border-t border-white/5 text-xs text-gray-500">
<span>Last updated: {new Date(course.updated_at).toLocaleDateString()}</span>
<span>Última actualización: {new Date(course.updated_at).toLocaleDateString()}</span>
<span>ID: {course.id.slice(0, 4)}...</span>
</div>
</div>
+75 -32
View File
@@ -8,9 +8,9 @@ import { cmsApi, Asset } from "@/lib/api";
interface AssetPickerModalProps {
isOpen: boolean;
onClose: () => void;
courseId: string;
courseId?: string;
onSelect: (asset: Asset) => void;
filterType?: "image" | "file" | "all";
filterType?: "image" | "file" | "video" | "all";
}
export default function AssetPickerModal({
@@ -23,34 +23,46 @@ export default function AssetPickerModal({
const [assets, setAssets] = useState<Asset[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [searchTerm, setSearchTerm] = useState("");
const [viewMode, setViewMode] = useState<"course" | "global">(courseId ? "course" : "global");
const loadAssets = useCallback(async () => {
if (!isOpen) return;
setIsLoading(true);
try {
const data = await cmsApi.getCourseAssets(courseId);
const filters: any = {};
if (viewMode === "course" && courseId) {
filters.course_id = courseId;
}
if (searchTerm) {
filters.search = searchTerm;
}
const data = await cmsApi.getAssets(filters);
let filtered = data;
if (filterType === "image") {
filtered = data.filter(a => a.mimetype.startsWith("image/"));
} else if (filterType === "file") {
filtered = data.filter(a => !a.mimetype.startsWith("image/"));
filtered = data.filter(a => !a.mimetype.startsWith("image/") && !a.mimetype.startsWith("video/"));
} else if (filterType === "video") {
filtered = data.filter(a => a.mimetype.startsWith("video/"));
}
setAssets(filtered);
} catch (error) {
console.error("Failed to load assets for picker:", error);
} finally {
setIsLoading(false);
}
}, [courseId, isOpen, filterType]);
}, [courseId, isOpen, filterType, viewMode, searchTerm]);
useEffect(() => {
loadAssets();
const timer = setTimeout(() => {
loadAssets();
}, 300);
return () => clearTimeout(timer);
}, [loadAssets]);
const filteredAssets = assets.filter(asset =>
asset.filename.toLowerCase().includes(searchTerm.toLowerCase())
);
const getIcon = (mimetype: string) => {
if (mimetype.startsWith('image/')) return <ImageIcon className="w-5 h-5 text-blue-400" />;
if (mimetype.startsWith('video/')) return <Film className="w-5 h-5 text-purple-400" />;
@@ -62,47 +74,78 @@ export default function AssetPickerModal({
<Modal
isOpen={isOpen}
onClose={onClose}
title={filterType === "image" ? "Select Image" : filterType === "file" ? "Select File" : "Select Asset"}
title={filterType === "image" ? "Select Image" : filterType === "video" ? "Select Video" : "Select Asset"}
>
<div className="space-y-4 max-h-[60vh] overflow-hidden flex flex-col">
<div className="space-y-4 max-h-[70vh] overflow-hidden flex flex-col">
<div className="flex gap-2 p-1 bg-white/5 rounded-xl border border-white/10">
{courseId && (
<button
onClick={() => setViewMode("course")}
className={`flex-1 py-2 text-[10px] uppercase font-bold tracking-widest rounded-lg transition-all ${viewMode === "course" ? "bg-blue-500 text-white shadow-lg shadow-blue-500/20" : "text-gray-400 hover:text-gray-200"}`}
>
This Course
</button>
)}
<button
onClick={() => setViewMode("global")}
className={`flex-1 py-2 text-[10px] uppercase font-bold tracking-widest rounded-lg transition-all ${viewMode === "global" ? "bg-blue-500 text-white shadow-lg shadow-blue-500/20" : "text-gray-400 hover:text-gray-200"}`}
>
Global Library
</button>
</div>
<div className="relative">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500" />
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400" />
<input
type="text"
placeholder="Search files..."
placeholder="Search assets by filename..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="w-full bg-white/5 border border-white/10 rounded-xl pl-10 pr-4 py-2 text-sm focus:outline-none focus:border-blue-500/50"
className="w-full bg-white/5 border border-white/10 rounded-xl pl-10 pr-4 py-2.5 text-sm font-medium text-gray-200 placeholder:text-gray-500 focus:outline-none focus:border-blue-500/50 transition-colors"
/>
</div>
<div className="flex-1 overflow-y-auto space-y-2 min-h-[300px] pr-2 custom-scrollbar">
<div className="flex-1 overflow-y-auto space-y-2 min-h-[350px] pr-2 custom-scrollbar">
{isLoading ? (
<div className="flex flex-col items-center justify-center py-20 text-gray-500 gap-3">
<Loader2 className="w-8 h-8 animate-spin text-blue-500" />
<span className="text-xs uppercase font-bold tracking-widest">Loading assets...</span>
<div className="flex flex-col items-center justify-center py-24 text-gray-500 gap-4">
<Loader2 className="w-10 h-10 animate-spin text-blue-500" />
<span className="text-[10px] uppercase font-black tracking-[0.2em] opacity-50">Synchronizing...</span>
</div>
) : filteredAssets.length === 0 ? (
<div className="text-center py-20 text-gray-500 text-sm">
{searchTerm ? "No files match your search." : "No assets found for this course."}
) : assets.length === 0 ? (
<div className="text-center py-24 flex flex-col items-center gap-4">
<div className="p-4 bg-white/5 rounded-2xl border border-white/5">
<FileIcon className="w-8 h-8 text-gray-600" />
</div>
<div className="space-y-1">
<div className="text-sm font-bold text-gray-400">Empty Collection</div>
<div className="text-[10px] text-gray-500 uppercase tracking-widest">
{searchTerm ? "No results found" : "No assets uploaded yet"}
</div>
</div>
</div>
) : (
filteredAssets.map((asset) => (
assets.map((asset) => (
<button
key={asset.id}
onClick={() => {
onSelect(asset);
onClose();
}}
className="w-full flex items-center gap-3 p-3 rounded-xl bg-white/5 border border-transparent hover:border-white/10 hover:bg-white/10 transition-all text-left group"
className="w-full flex items-center gap-4 p-3.5 rounded-2xl bg-white/5 border border-white/5 hover:border-blue-500/30 hover:bg-blue-500/5 transition-all text-left group"
>
<div className="p-2 bg-white/5 rounded-lg group-hover:bg-white/10 transition-colors">
<div className="w-12 h-12 flex items-center justify-center bg-white/5 rounded-xl group-hover:bg-blue-500/10 transition-colors shrink-0">
{getIcon(asset.mimetype)}
</div>
<div className="flex-1 min-w-0">
<div className="text-sm font-bold text-gray-200 truncate">{asset.filename}</div>
<div className="text-[10px] text-gray-500 uppercase tracking-wider">
{(asset.size_bytes / 1024 / 1024).toFixed(2)} MB {asset.mimetype.split('/')[1]}
<div className="text-sm font-bold text-gray-200 truncate group-hover:text-blue-400 transition-colors">{asset.filename}</div>
<div className="flex items-center gap-2 mt-1">
<div className="text-[10px] text-gray-500 uppercase font-bold tracking-wider">
{(asset.size_bytes / 1024 / 1024).toFixed(2)} MB
</div>
<div className="w-1 h-1 rounded-full bg-gray-700" />
<div className="text-[10px] text-gray-500 uppercase font-bold tracking-wider truncate">
{asset.mimetype.split('/')[1]}
</div>
</div>
</div>
</button>
@@ -110,10 +153,10 @@ export default function AssetPickerModal({
)}
</div>
<div className="pt-4 border-t border-white/5 text-center">
<p className="text-[10px] text-gray-500 uppercase tracking-widest">
Only assets uploaded to this course are shown.
</p>
<div className="pt-4 border-t border-white/10 flex items-center justify-between">
<div className="text-[10px] text-gray-500 uppercase font-bold tracking-[0.1em]">
{assets.length} Assets Found
</div>
</div>
</div>
</Modal>
@@ -7,7 +7,7 @@ import { Layout, CheckCircle2, Calendar, BarChart2, Settings, Folder, Graduation
interface CourseEditorLayoutProps {
children: React.ReactNode;
activeTab: "outline" | "grading" | "rubrics" | "calendar" | "analytics" | "settings" | "files" | "grades" | "announcements";
activeTab: "outline" | "grading" | "rubrics" | "calendar" | "analytics" | "settings" | "files" | "grades" | "announcements" | "team";
}
export default function CourseEditorLayout({ children, activeTab }: CourseEditorLayoutProps) {
@@ -17,6 +17,7 @@ export default function CourseEditorLayout({ children, activeTab }: CourseEditor
{ key: "outline", label: "Outline", icon: Layout, href: `/courses/${id}` },
{ key: "grading", label: "Grading Policy", icon: CheckCircle2, href: `/courses/${id}/grading` },
{ key: "rubrics", label: "Rubrics", icon: Layout, href: `/courses/${id}/rubrics` },
{ key: "team", label: "Team", icon: GraduationCap, href: `/courses/${id}/team` },
{ key: "grades", label: "Gradebook", icon: GraduationCap, href: `/courses/${id}/grades` },
{ key: "announcements", label: "Announcements", icon: Megaphone, href: `/courses/${id}/announcements` },
{ key: "calendar", label: "Calendar", icon: Calendar, href: `/courses/${id}/calendar` },
+9 -1
View File
@@ -3,7 +3,7 @@
import Link from 'next/link';
import { useAuth } from '@/context/AuthContext';
import { useTranslation } from '@/context/I18nContext';
import { LayoutDashboard, ShieldCheck, LogOut, Webhook, Settings, Globe } from 'lucide-react';
import { LayoutDashboard, ShieldCheck, LogOut, Webhook, Settings, Globe, Library } from 'lucide-react';
export function Navbar() {
const { t, language, setLanguage } = useTranslation();
@@ -28,6 +28,14 @@ export function Navbar() {
{t('nav.courses')}
</Link>
<Link
href="/library/assets"
className="text-sm font-medium text-gray-400 hover:text-blue-400 transition-colors flex items-center gap-2"
>
<Library className="w-4 h-4" />
{t('nav.library') || 'Library'}
</Link>
{user?.role === 'admin' && (
<>
{user.organization_id === '00000000-0000-0000-0000-000000000001' && (
+27 -1
View File
@@ -112,6 +112,7 @@ export interface Lesson {
cues?: { start: number; end: number; text: string }[];
} | null;
transcription_status?: 'idle' | 'queued' | 'processing' | 'completed' | 'failed';
is_previewable: boolean;
created_at: string;
}
@@ -188,6 +189,8 @@ export interface UploadResponse {
id: string;
filename: string;
url: string;
mimetype?: string;
size_bytes?: number;
logo_url?: string;
favicon_url?: string;
}
@@ -406,6 +409,8 @@ export interface CreateWebhookPayload {
export interface Asset {
id: string;
organization_id: string;
uploaded_by: string | null;
course_id: string | null;
filename: string;
storage_path: string;
@@ -414,6 +419,14 @@ export interface Asset {
created_at: string;
}
export interface AssetFilters {
mimetype?: string;
course_id?: string;
search?: string;
page?: number;
limit?: number;
}
export interface Cohort {
id: string;
organization_id: string;
@@ -568,6 +581,7 @@ export const cmsApi = {
getCourseTeam: (courseId: string): Promise<CourseInstructor[]> => apiFetch(`/courses/${courseId}/team`),
addTeamMember: (courseId: string, email: string, role: string): Promise<CourseInstructor> => apiFetch(`/courses/${courseId}/team`, { method: 'POST', body: JSON.stringify({ email, role }) }),
removeTeamMember: (courseId: string, userId: string): Promise<void> => apiFetch(`/courses/${courseId}/team/${userId}`, { method: 'DELETE' }),
getUsers: (): Promise<User[]> => apiFetch('/users'),
// Modules & Lessons
createModule: (course_id: string, title: string, position: number): Promise<Module> => apiFetch('/modules', { method: 'POST', body: JSON.stringify({ course_id, title, position }) }),
@@ -625,7 +639,19 @@ export const cmsApi = {
deleteWebhook: (id: string): Promise<void> => apiFetch(`/webhooks/${id}`, { method: 'DELETE' }),
// Assets
getCourseAssets: (courseId: string): Promise<Asset[]> => apiFetch(`/courses/${courseId}/assets`),
getAssets: (filters?: AssetFilters): Promise<Asset[]> => {
const params = new URLSearchParams();
if (filters) {
if (filters.mimetype) params.append('mimetype', filters.mimetype);
if (filters.course_id) params.append('course_id', filters.course_id);
if (filters.search) params.append('search', filters.search);
if (filters.page) params.append('page', filters.page.toString());
if (filters.limit) params.append('limit', filters.limit.toString());
}
const query = params.toString();
return apiFetch(`/api/assets${query ? `?${query}` : ''}`);
},
getCourseAssets: (courseId: string): Promise<Asset[]> => apiFetch(`/api/assets?course_id=${courseId}`),
deleteAsset: (id: string): Promise<void> => apiFetch(`/api/assets/${id}`, { method: 'DELETE' }),
uploadAsset: (file: File, onProgress?: (pct: number) => void, courseId?: string): Promise<UploadResponse> => {
return new Promise((resolve, reject) => {