Initial commit
This commit is contained in:
+66
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
ApiService
|
||||
} from "./chunk-2TRRHRR7.js";
|
||||
import {
|
||||
Injectable,
|
||||
inject,
|
||||
map,
|
||||
setClassMetadata,
|
||||
ɵɵdefineInjectable
|
||||
} from "./chunk-WI7WFVZR.js";
|
||||
import {
|
||||
__spreadProps,
|
||||
__spreadValues
|
||||
} from "./chunk-WDMUDEB6.js";
|
||||
|
||||
// src/app/services/course.service.ts
|
||||
var INT_TO_TYPE = { 0: "Url", 1: "Video", 2: "Text", 3: "File" };
|
||||
function normalizeType(r) {
|
||||
return __spreadProps(__spreadValues({}, r), { type: typeof r.type === "number" ? INT_TO_TYPE[r.type] ?? "Url" : r.type });
|
||||
}
|
||||
var CourseService = class _CourseService {
|
||||
api = inject(ApiService);
|
||||
getCourses(search) {
|
||||
const params = search ? { search } : void 0;
|
||||
return this.api.get("/api/courses", params);
|
||||
}
|
||||
getCourseById(id) {
|
||||
return this.api.get(`/api/courses/${id}`).pipe(map((c) => __spreadProps(__spreadValues({}, c), {
|
||||
topics: (c.topics ?? []).map((t) => __spreadProps(__spreadValues({}, t), {
|
||||
resources: (t.resources ?? []).map(normalizeType)
|
||||
}))
|
||||
})));
|
||||
}
|
||||
createCourse(title, description, creatorId) {
|
||||
return this.api.post("/api/courses", { title, description, creatorId });
|
||||
}
|
||||
updateCourse(id, title, description) {
|
||||
return this.api.put(`/api/courses/${id}`, { id, title, description });
|
||||
}
|
||||
publishCourse(id) {
|
||||
return this.api.patch(`/api/courses/${id}/publish`, {});
|
||||
}
|
||||
deleteCourse(id) {
|
||||
return this.api.delete(`/api/courses/${id}`);
|
||||
}
|
||||
getMyCourses(userId) {
|
||||
return this.api.get(`/api/users/${userId}/courses`);
|
||||
}
|
||||
static \u0275fac = function CourseService_Factory(__ngFactoryType__) {
|
||||
return new (__ngFactoryType__ || _CourseService)();
|
||||
};
|
||||
static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({ token: _CourseService, factory: _CourseService.\u0275fac, providedIn: "root" });
|
||||
};
|
||||
(() => {
|
||||
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CourseService, [{
|
||||
type: Injectable,
|
||||
args: [{
|
||||
providedIn: "root"
|
||||
}]
|
||||
}], null, null);
|
||||
})();
|
||||
|
||||
export {
|
||||
CourseService
|
||||
};
|
||||
//# sourceMappingURL=chunk-6K3TDILH.js.map
|
||||
Reference in New Issue
Block a user