mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: navigation bugs
This commit is contained in:
parent
898928759d
commit
aeebcf1d63
4 changed files with 22 additions and 7 deletions
|
|
@ -6,6 +6,7 @@ import { createCollection } from "@services/collections";
|
|||
import useSWR from "swr";
|
||||
import { getAPIUrl } from "@services/config";
|
||||
import { swrFetcher } from "@services/utils/requests";
|
||||
import { getOrganizationContextInfo } from "@services/orgs";
|
||||
|
||||
function NewCollection(params : any) {
|
||||
const orgslug = params.params.orgslug;
|
||||
|
|
@ -17,6 +18,14 @@ function NewCollection(params : any) {
|
|||
|
||||
const { data: courses, error: error } = useSWR(`${getAPIUrl()}courses/org_slug/${orgslug}/page/1/limit/10`, swrFetcher);
|
||||
|
||||
React.useEffect(() => {
|
||||
async function getOrg() {
|
||||
const org = await getOrganizationContextInfo(orgslug);
|
||||
setOrg(org);
|
||||
}
|
||||
getOrg();
|
||||
}, []);
|
||||
|
||||
const handleNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setName(event.target.value);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import React from "react";
|
|||
import styled from "styled-components";
|
||||
import { Title } from "@components/UI/Elements/Styles/Title";
|
||||
import { deleteCollection } from "@services/collections";
|
||||
import { getAPIUrl, getBackendUrl } from "@services/config";
|
||||
import { getAPIUrl, getBackendUrl, getUriWithOrg } from "@services/config";
|
||||
import { swrFetcher } from "@services/utils/requests";
|
||||
import useSWR, { mutate } from "swr";
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ function Collections(params: any) {
|
|||
<>
|
||||
<Title>
|
||||
{orgslug} Collections :{" "}
|
||||
<Link href={"/collections/new"}>
|
||||
<Link href={getUriWithOrg(orgslug, "/collections/new")}>
|
||||
<button>+</button>
|
||||
</Link>{" "}
|
||||
</Title>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ const Organizations = () => {
|
|||
}
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<>
|
||||
<Title>
|
||||
Your Organizations{" "}
|
||||
<Link href={"/organizations/new"}>
|
||||
|
|
@ -40,7 +40,7 @@ const Organizations = () => {
|
|||
))}
|
||||
</div>
|
||||
)}
|
||||
</Layout>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,17 @@ export const getAPIUrl = () => LEARNHOUSE_API_URL;
|
|||
|
||||
export const getBackendUrl = () => LEARNHOUSE_BACKEND_URL;
|
||||
|
||||
export const getUriWithOrg = ( orgslug: string, path: string) => {
|
||||
export const getUriWithOrg = (orgslug: string, path: string) => {
|
||||
return `http://localhost:3000/org/${orgslug}${path}`;
|
||||
};
|
||||
|
||||
export const getOrgFromUri = (uri: any) => {
|
||||
// if url contains /org
|
||||
if (uri.includes("/org/")) {
|
||||
let org = uri.match(/\/org\/([\w]+)/)[1];
|
||||
return org;
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue