mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
bugfix: links issue
This commit is contained in:
parent
db4c0b91c4
commit
7b0c90ce06
2 changed files with 10 additions and 8 deletions
|
|
@ -4,7 +4,7 @@ import { useRouter } from "next/navigation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { Title } from "../../../../components/UI/Elements/Styles/Title";
|
import { Title } from "../../../../components/UI/Elements/Styles/Title";
|
||||||
import { getAPIUrl, getBackendUrl } from "../../../../services/config";
|
import { getAPIUrl, getBackendUrl, getUriWithOrg } from "../../../../services/config";
|
||||||
import { deleteCourseFromBackend } from "../../../../services/courses/courses";
|
import { deleteCourseFromBackend } from "../../../../services/courses/courses";
|
||||||
import useSWR, { mutate } from "swr";
|
import useSWR, { mutate } from "swr";
|
||||||
import { swrFetcher } from "@services/utils/requests";
|
import { swrFetcher } from "@services/utils/requests";
|
||||||
|
|
@ -18,7 +18,7 @@ const CoursesIndexPage = (params: any) => {
|
||||||
|
|
||||||
async function deleteCourses(course_id: any) {
|
async function deleteCourses(course_id: any) {
|
||||||
await deleteCourseFromBackend(course_id);
|
await deleteCourseFromBackend(course_id);
|
||||||
mutate(`${getAPIUrl()}courses/${orgslug}/page/1/limit/10`);
|
mutate(`${getAPIUrl()}courses/org_slug/${orgslug}/page/1/limit/10`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to remove "course_" from the course_id
|
// function to remove "course_" from the course_id
|
||||||
|
|
@ -30,7 +30,7 @@ const CoursesIndexPage = (params: any) => {
|
||||||
<>
|
<>
|
||||||
<Title>
|
<Title>
|
||||||
Courses :{" "}
|
Courses :{" "}
|
||||||
<Link href={"/courses/new"}>
|
<Link href={getUriWithOrg(orgslug, "/courses/new")}>
|
||||||
<button>+</button>
|
<button>+</button>
|
||||||
</Link>{" "}
|
</Link>{" "}
|
||||||
</Title>
|
</Title>
|
||||||
|
|
@ -41,12 +41,14 @@ const CoursesIndexPage = (params: any) => {
|
||||||
<CourseWrapper>
|
<CourseWrapper>
|
||||||
{courses.map((course: any) => (
|
{courses.map((course: any) => (
|
||||||
<div key={course.course_id}>
|
<div key={course.course_id}>
|
||||||
<Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id)}>
|
|
||||||
<button style={{ backgroundColor: "red", border: "none" }} onClick={() => deleteCourses(course.course_id)}>
|
<button style={{ backgroundColor: "red", border: "none" }} onClick={() => deleteCourses(course.course_id)}>
|
||||||
Delete <Trash size={10}></Trash>
|
Delete <Trash size={10}></Trash>
|
||||||
</button>
|
</button>
|
||||||
|
<Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id)}>
|
||||||
<Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id) + "/edit"}>
|
<Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id) + "/edit"}>
|
||||||
<button>Edit <Edit2 size={10} ></Edit2></button>
|
<button>
|
||||||
|
Edit <Edit2 size={10}></Edit2>
|
||||||
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
<CourseThumbnail>
|
<CourseThumbnail>
|
||||||
<img src={`${getBackendUrl()}content/uploads/img/${course.thumbnail}`} alt="" />
|
<img src={`${getBackendUrl()}content/uploads/img/${course.thumbnail}`} alt="" />
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ export default function middleware(req: NextRequest) {
|
||||||
|
|
||||||
// if url starts with "/organizations" rewrite to path
|
// if url starts with "/organizations" rewrite to path
|
||||||
if (url.pathname.startsWith("/organizations")) {
|
if (url.pathname.startsWith("/organizations")) {
|
||||||
url.pathname = url.pathname.replace("/organizations", `/organizations/${currentHost}`);
|
url.pathname = url.pathname.replace("/organizations", `/organizations${currentHost}`);
|
||||||
// remove localhost:3000 from url
|
// remove localhost:3000 from url
|
||||||
url.pathname = url.pathname.replace(`localhost:3000`, "");
|
url.pathname = url.pathname.replace(`localhost:3000`, "");
|
||||||
console.log(url);
|
console.log(url);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue