"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; import React from "react"; import styled from "styled-components"; import { Title } from "../../../../components/UI/Elements/Styles/Title"; import { getAPIUrl, getBackendUrl } from "../../../../services/config"; import { deleteCourseFromBackend } from "../../../../services/courses/courses"; import useSWR, { mutate } from "swr"; import { swrFetcher } from "@services/utils/requests"; const CoursesIndexPage = (params: any) => { const router = useRouter(); const orgslug = params.params.orgslug; const { data: courses, error: error } = useSWR(`${getAPIUrl()}courses/org_slug/${orgslug}/page/1/limit/10`, swrFetcher); async function deleteCourses(course_id: any) { await deleteCourseFromBackend(course_id); mutate(`${getAPIUrl()}courses/${orgslug}/page/1/limit/10`); } // function to remove "course_" from the course_id function removeCoursePrefix(course_id: string) { return course_id.replace("course_", ""); } return ( <>
Failed to load
} {!courses ? (