mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: getOrganization issue
This commit is contained in:
parent
4aa2d537e1
commit
122c802c62
5 changed files with 23 additions and 9 deletions
|
|
@ -8,7 +8,7 @@ import { useRouter } from "next/navigation";
|
|||
import NewChapterModal from "@components/Objects/Modals/Chapters/NewChapter";
|
||||
import NewActivityModal from "@components/Objects/Modals/Activities/Create/NewActivity";
|
||||
import { createActivity, createFileActivity, createExternalVideoActivity } from "@services/courses/activities";
|
||||
import { getOrganizationContextInfo } from "@services/organizations/orgs";
|
||||
import { getOrganizationContextInfo, getOrganizationContextInfoWithoutCredentials } from "@services/organizations/orgs";
|
||||
import Modal from "@components/StyledElements/Modal/Modal";
|
||||
import { denyAccessToUser } from "@services/utils/react/middlewares/views";
|
||||
import { Folders, Hexagon, SaveIcon } from "lucide-react";
|
||||
|
|
@ -71,7 +71,7 @@ function CourseContentEdition(props: any) {
|
|||
|
||||
// Submit new activity
|
||||
const submitActivity = async (activity: any) => {
|
||||
let org = await getOrganizationContextInfo(orgslug, { revalidate: 1800 });
|
||||
let org = await getOrganizationContextInfoWithoutCredentials(orgslug, { revalidate: 1800 });
|
||||
await updateChaptersMetadata(courseid, data);
|
||||
await createActivity(activity, activity.chapterId, org.org_id);
|
||||
mutate(`${getAPIUrl()}chapters/meta/course_${courseid}`);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import React from "react";
|
||||
import Link from "next/link";
|
||||
import { getUriWithOrg } from "@services/config/config";
|
||||
import { getOrganizationContextInfo } from "@services/organizations/orgs";
|
||||
import { getOrganizationContextInfo, getOrganizationContextInfoWithoutCredentials } from "@services/organizations/orgs";
|
||||
import ClientComponentSkeleton from "@components/Utils/ClientComp";
|
||||
import { HeaderProfileBox } from "@components/Security/HeaderProfileBox";
|
||||
import MenuLinks from "./MenuLinks";
|
||||
|
|
@ -10,7 +10,7 @@ import { getOrgLogoMediaDirectory } from "@services/media/media";
|
|||
|
||||
export const Menu = async (props: any) => {
|
||||
const orgslug = props.orgslug;
|
||||
const org = await getOrganizationContextInfo(orgslug, { revalidate: 0, tags: ['organizations'] });
|
||||
const org = await getOrganizationContextInfoWithoutCredentials(orgslug, { revalidate: 0, tags: ['organizations'] });
|
||||
return (
|
||||
<>
|
||||
<div className="backdrop-blur-lg h-[60px] blur-3xl z-10" style={{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as Form from '@radix-ui/react-form'
|
|||
import { getAPIUrl, getUriWithOrg } from '@services/config/config';
|
||||
import { FormMessage } from "@radix-ui/react-form";
|
||||
import { createNewCourse } from '@services/courses/courses';
|
||||
import { getOrganizationContextInfo } from '@services/organizations/orgs';
|
||||
import { getOrganizationContextInfo, getOrganizationContextInfoWithoutCredentials } from '@services/organizations/orgs';
|
||||
import React, { useState } from 'react'
|
||||
import { BarLoader } from 'react-spinners'
|
||||
import { mutate } from 'swr';
|
||||
|
|
@ -22,7 +22,7 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
|
|||
|
||||
|
||||
const getOrgMetadata = async () => {
|
||||
const org = await getOrganizationContextInfo(orgslug, { revalidate: 360, tags: ['organizations'] });
|
||||
const org = await getOrganizationContextInfoWithoutCredentials(orgslug, { revalidate: 360, tags: ['organizations'] });
|
||||
setOrgId(org.org_id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,12 +62,11 @@ const AuthProvider = ({ children }: any) => {
|
|||
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
checkRefreshToken();
|
||||
checkAuth();
|
||||
return () => {
|
||||
auth.isLoading = false;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,22 @@ export async function getOrganizationContextInfo(org_slug: any, next: any) {
|
|||
return res;
|
||||
}
|
||||
|
||||
export async function getOrganizationContextInfoWithoutCredentials(org_slug: any, next: any) {
|
||||
let HeadersConfig = new Headers({ "Content-Type": "application/json" });
|
||||
let options: any = {
|
||||
method: 'GET',
|
||||
headers: HeadersConfig,
|
||||
redirect: "follow",
|
||||
// Next.js
|
||||
next: next,
|
||||
};
|
||||
|
||||
const result = await fetch(`${getAPIUrl()}orgs/slug/${org_slug}`, options);
|
||||
const res = await errorHandling(result);
|
||||
return res;
|
||||
}
|
||||
|
||||
export function getOrganizationContextInfoNoAsync(org_slug: any, next: any) {
|
||||
const result = fetch(`${getAPIUrl()}orgs/slug/${org_slug}`, RequestBody("GET", null, next));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue