mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: session issues/bugs
This commit is contained in:
parent
81bc8e7e82
commit
644693149a
20 changed files with 20 additions and 21 deletions
|
|
@ -13,7 +13,7 @@ import useSWR from 'swr'
|
||||||
function Trail(params: any) {
|
function Trail(params: any) {
|
||||||
let orgslug = params.orgslug
|
let orgslug = params.orgslug
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const orgID = org?.id
|
const orgID = org?.id
|
||||||
const { data: trail, error: error } = useSWR(
|
const { data: trail, error: error } = useSWR(
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@ export function CourseProvider({ children, courseuuid }: any) {
|
||||||
const session = useLHSession() as any;
|
const session = useLHSession() as any;
|
||||||
const access_token = session?.data?.tokens?.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
|
|
||||||
const { data: courseStructureData, error } = useSWR(
|
const { data: courseStructureData, error } = useSWR(`${getAPIUrl()}courses/${courseuuid}/meta`,
|
||||||
access_token ? `${getAPIUrl()}courses/${courseuuid}/meta` : null,
|
|
||||||
url => swrFetcher(url, access_token)
|
url => swrFetcher(url, access_token)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import { updateUserAvatar } from '@services/users/users'
|
||||||
|
|
||||||
function UserEditGeneral() {
|
function UserEditGeneral() {
|
||||||
const session = useLHSession() as any;
|
const session = useLHSession() as any;
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const [localAvatar, setLocalAvatar] = React.useState(null) as any
|
const [localAvatar, setLocalAvatar] = React.useState(null) as any
|
||||||
const [isLoading, setIsLoading] = React.useState(false) as any
|
const [isLoading, setIsLoading] = React.useState(false) as any
|
||||||
const [error, setError] = React.useState() as any
|
const [error, setError] = React.useState() as any
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import React, { useEffect } from 'react'
|
||||||
|
|
||||||
function UserEditPassword() {
|
function UserEditPassword() {
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
|
|
||||||
const updatePasswordUI = async (values: any) => {
|
const updatePasswordUI = async (values: any) => {
|
||||||
let user_id = session.data.user.id
|
let user_id = session.data.user.id
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||||
function OrgAccess() {
|
function OrgAccess() {
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const { data: invites } = useSWR(
|
const { data: invites } = useSWR(
|
||||||
org ? `${getAPIUrl()}orgs/${org?.id}/invites` : null,
|
org ? `${getAPIUrl()}orgs/${org?.id}/invites` : null,
|
||||||
(url) => swrFetcher(url, access_token)
|
(url) => swrFetcher(url, access_token)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import useSWR, { mutate } from 'swr'
|
||||||
function OrgUserGroups() {
|
function OrgUserGroups() {
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const [userGroupManagementModal, setUserGroupManagementModal] = React.useState(false)
|
const [userGroupManagementModal, setUserGroupManagementModal] = React.useState(false)
|
||||||
const [createUserGroupModal, setCreateUserGroupModal] = React.useState(false)
|
const [createUserGroupModal, setCreateUserGroupModal] = React.useState(false)
|
||||||
const [selectedUserGroup, setSelectedUserGroup] = React.useState(null) as any
|
const [selectedUserGroup, setSelectedUserGroup] = React.useState(null) as any
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import useSWR, { mutate } from 'swr'
|
||||||
function OrgUsers() {
|
function OrgUsers() {
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const { data: orgUsers } = useSWR(
|
const { data: orgUsers } = useSWR(
|
||||||
org ? `${getAPIUrl()}orgs/${org?.id}/users` : null,
|
org ? `${getAPIUrl()}orgs/${org?.id}/users` : null,
|
||||||
(url) => swrFetcher(url, access_token)
|
(url) => swrFetcher(url, access_token)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import useSWR, { mutate } from 'swr'
|
||||||
function OrgUsersAdd() {
|
function OrgUsersAdd() {
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const [isLoading, setIsLoading] = React.useState(false)
|
const [isLoading, setIsLoading] = React.useState(false)
|
||||||
const [invitedUsers, setInvitedUsers] = React.useState('');
|
const [invitedUsers, setInvitedUsers] = React.useState('');
|
||||||
const [selectedInviteCode, setSelectedInviteCode] = React.useState('');
|
const [selectedInviteCode, setSelectedInviteCode] = React.useState('');
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ type ActivityChatMessageBoxProps = {
|
||||||
|
|
||||||
function ActivityChatMessageBox(props: ActivityChatMessageBoxProps) {
|
function ActivityChatMessageBox(props: ActivityChatMessageBoxProps) {
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const aiChatBotState = useAIChatBot() as AIChatBotStateTypes
|
const aiChatBotState = useAIChatBot() as AIChatBotStateTypes
|
||||||
const dispatchAIChatBot = useAIChatBotDispatch() as any
|
const dispatchAIChatBot = useAIChatBotDispatch() as any
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ function AIActionButton(props: {
|
||||||
activity: any
|
activity: any
|
||||||
}) {
|
}) {
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const dispatchAIChatBot = useAIChatBotDispatch() as any
|
const dispatchAIChatBot = useAIChatBotDispatch() as any
|
||||||
const aiChatBotState = useAIChatBot() as AIChatBotStateTypes
|
const aiChatBotState = useAIChatBot() as AIChatBotStateTypes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ const UserFeedbackModal = (props: AIEditorToolkitProps) => {
|
||||||
const dispatchAIEditor = useAIEditorDispatch() as any
|
const dispatchAIEditor = useAIEditorDispatch() as any
|
||||||
const aiEditorState = useAIEditor() as AIEditorStateTypes
|
const aiEditorState = useAIEditor() as AIEditorStateTypes
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
await dispatchAIEditor({
|
await dispatchAIEditor({
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ interface EditorWrapperProps {
|
||||||
|
|
||||||
function EditorWrapper(props: EditorWrapperProps): JSX.Element {
|
function EditorWrapper(props: EditorWrapperProps): JSX.Element {
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
// Define provider in the state
|
// Define provider in the state
|
||||||
const [provider, setProvider] = React.useState<HocuspocusProvider | null>(null);
|
const [provider, setProvider] = React.useState<HocuspocusProvider | null>(null);
|
||||||
const [thisPageColor, setThisPageColor] = useState(randomColor({ luminosity: 'light' }) as string)
|
const [thisPageColor, setThisPageColor] = useState(randomColor({ luminosity: 'light' }) as string)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ function ImageBlockComponent(props: any) {
|
||||||
const course = useCourse() as any
|
const course = useCourse() as any
|
||||||
const editorState = useEditorProvider() as any
|
const editorState = useEditorProvider() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
|
|
||||||
const isEditable = editorState.isEditable
|
const isEditable = editorState.isEditable
|
||||||
const [image, setImage] = React.useState(null)
|
const [image, setImage] = React.useState(null)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ function PDFBlockComponent(props: any) {
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const course = useCourse() as any
|
const course = useCourse() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const [pdf, setPDF] = React.useState(null)
|
const [pdf, setPDF] = React.useState(null)
|
||||||
const [isLoading, setIsLoading] = React.useState(false)
|
const [isLoading, setIsLoading] = React.useState(false)
|
||||||
const [blockObject, setblockObject] = React.useState(
|
const [blockObject, setblockObject] = React.useState(
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ function VideoBlockComponents(props: any) {
|
||||||
const isEditable = editorState.isEditable
|
const isEditable = editorState.isEditable
|
||||||
const [video, setVideo] = React.useState(null)
|
const [video, setVideo] = React.useState(null)
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const [isLoading, setIsLoading] = React.useState(false)
|
const [isLoading, setIsLoading] = React.useState(false)
|
||||||
const [blockObject, setblockObject] = React.useState(
|
const [blockObject, setblockObject] = React.useState(
|
||||||
props.node.attrs.blockObject
|
props.node.attrs.blockObject
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ function LinkToUserGroup(props: LinkToUserGroupProps) {
|
||||||
const course = useCourse() as any
|
const course = useCourse() as any
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const courseStructure = course.courseStructure
|
const courseStructure = course.courseStructure
|
||||||
|
|
||||||
const { data: usergroups } = useSWR(
|
const { data: usergroups } = useSWR(
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ type OrgInviteCodeGenerateProps = {
|
||||||
function OrgInviteCodeGenerate(props: OrgInviteCodeGenerateProps) {
|
function OrgInviteCodeGenerate(props: OrgInviteCodeGenerateProps) {
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const [usergroup_id, setUsergroup_id] = React.useState(0);
|
const [usergroup_id, setUsergroup_id] = React.useState(0);
|
||||||
const { data: usergroups } = useSWR(
|
const { data: usergroups } = useSWR(
|
||||||
org ? `${getAPIUrl()}usergroups/org/${org.id}` : null,
|
org ? `${getAPIUrl()}usergroups/org/${org.id}` : null,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ type AddUserGroupProps = {
|
||||||
function AddUserGroup(props: AddUserGroupProps) {
|
function AddUserGroup(props: AddUserGroupProps) {
|
||||||
const org = useOrg() as any;
|
const org = useOrg() as any;
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const [userGroupName, setUserGroupName] = React.useState('')
|
const [userGroupName, setUserGroupName] = React.useState('')
|
||||||
const [userGroupDescription, setUserGroupDescription] = React.useState('')
|
const [userGroupDescription, setUserGroupDescription] = React.useState('')
|
||||||
const [isSubmitting, setIsSubmitting] = React.useState(false)
|
const [isSubmitting, setIsSubmitting] = React.useState(false)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ type ManageUsersProps = {
|
||||||
function ManageUsers(props: ManageUsersProps) {
|
function ManageUsers(props: ManageUsersProps) {
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const { data: OrgUsers } = useSWR(
|
const { data: OrgUsers } = useSWR(
|
||||||
org ? `${getAPIUrl()}orgs/${org.id}/users` : null,
|
org ? `${getAPIUrl()}orgs/${org.id}/users` : null,
|
||||||
swrFetcher
|
swrFetcher
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ interface Props {
|
||||||
function RolesUpdate(props: Props) {
|
function RolesUpdate(props: Props) {
|
||||||
const org = useOrg() as any
|
const org = useOrg() as any
|
||||||
const session = useLHSession() as any
|
const session = useLHSession() as any
|
||||||
const access_token = session.data.tokens.access_token;
|
const access_token = session?.data?.tokens?.access_token;
|
||||||
const [isSubmitting, setIsSubmitting] = React.useState(false)
|
const [isSubmitting, setIsSubmitting] = React.useState(false)
|
||||||
const [assignedRole, setAssignedRole] = React.useState(
|
const [assignedRole, setAssignedRole] = React.useState(
|
||||||
props.alreadyAssignedRole
|
props.alreadyAssignedRole
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue