MCPcopy Create free account
hub / github.com/code100x/daily-code / updateTrack

Function updateTrack

apps/web/components/utils.tsx:260–315  ·  view source on GitHub ↗
(
  trackId: string,
  data: {
    id: string;
    title: string;
    description: string;
    image: string;
    selectedCategory?: string[];
    problems?: { problem: Prisma.ProblemCreateManyInput; sortingOrder: number }[];
    hidden: boolean;
    cohort?: number;
    canvaLink?: string;
    trackType: "NOTION" | "CANVA";
  }
)

Source from the content-addressed store, hash-verified

258}
259
260export async function updateTrack(
261 trackId: string,
262 data: {
263 id: string;
264 title: string;
265 description: string;
266 image: string;
267 selectedCategory?: string[];
268 problems?: { problem: Prisma.ProblemCreateManyInput; sortingOrder: number }[];
269 hidden: boolean;
270 cohort?: number;
271 canvaLink?: string;
272 trackType: "NOTION" | "CANVA";
273 }
274) {
275 try {
276 const track = await db.track.update({
277 where: {
278 id: trackId,
279 },
280 data: {
281 id: data.id,
282 title: data.title,
283 description: data.description,
284 image: data.image,
285 hidden: data.hidden,
286 cohort: data.cohort,
287 canvaLink: data.canvaLink,
288 trackType: data.trackType,
289 },
290 });
291 await db.trackCategory.deleteMany({
292 where: {
293 trackId: trackId,
294 },
295 });
296 if (data.selectedCategory) {
297 data.selectedCategory.forEach(async (category) => {
298 await db.trackCategory.create({
299 data: {
300 trackId: trackId,
301 categoryId: category,
302 },
303 });
304 });
305 }
306
307 await cache.evict("getAllTracks", []);
308 await getAllTracks();
309
310 return track;
311 } catch (e) {
312 console.log(e);
313 return null;
314 }
315}
316
317export async function getAllCategories() {

Callers 1

handleEditFunction · 0.90

Calls 2

getAllTracksFunction · 0.85
evictMethod · 0.65

Tested by

no test coverage detected