@@ -277,7 +282,8 @@ const AIMessagePlaceHolder = (props: { activity_uuid: string, sendMessage: any }
Hello
-
+
+
{session.user.username},
how can we help today ?
diff --git a/apps/web/components/Objects/Editor/AI/AIEditorToolkit.tsx b/apps/web/components/Objects/Editor/AI/AIEditorToolkit.tsx
index 7ff15559..d2babbd0 100644
--- a/apps/web/components/Objects/Editor/AI/AIEditorToolkit.tsx
+++ b/apps/web/components/Objects/Editor/AI/AIEditorToolkit.tsx
@@ -57,7 +57,7 @@ function AIEditorToolkit(props: AIEditorToolkitProps) {
-
AI Editor
+
AI Editor PRE-ALPHA
diff --git a/apps/web/components/Objects/Editor/Editor.tsx b/apps/web/components/Objects/Editor/Editor.tsx
index 586f78e0..29a9566d 100644
--- a/apps/web/components/Objects/Editor/Editor.tsx
+++ b/apps/web/components/Objects/Editor/Editor.tsx
@@ -42,6 +42,7 @@ import { CourseProvider } from "@components/Contexts/CourseContext";
import { useSession } from "@components/Contexts/SessionContext";
import AIEditorToolkit from "./AI/AIEditorToolkit";
import useGetAIFeatures from "@components/AI/Hooks/useGetAIFeatures";
+import UserAvatar from "../UserAvatar";
interface Editor {
@@ -163,7 +164,7 @@ function Editor(props: Editor) {
-
+
@@ -207,7 +208,7 @@ function Editor(props: Editor) {
{!session.isAuthenticated && Loading}
- {session.isAuthenticated && }
+ {session.isAuthenticated && }
diff --git a/apps/web/components/Objects/Menu/ProfileArea.tsx b/apps/web/components/Objects/Menu/ProfileArea.tsx
index bffc5e9f..e96f3945 100644
--- a/apps/web/components/Objects/Menu/ProfileArea.tsx
+++ b/apps/web/components/Objects/Menu/ProfileArea.tsx
@@ -9,6 +9,7 @@ import { usePathname } from "next/navigation";
import { useRouter } from "next/router";
import path from "path";
import { Settings } from "lucide-react";
+import UserAvatar from "@components/Objects/UserAvatar";
export interface Auth {
access_token: string;
@@ -91,7 +92,7 @@ function ProfileArea() {
{auth.userInfo.user_object.username}
diff --git a/apps/web/components/Objects/Modals/Course/Create/CreateCourse.tsx b/apps/web/components/Objects/Modals/Course/Create/CreateCourse.tsx
index d1cc4db2..1da3f5d2 100644
--- a/apps/web/components/Objects/Modals/Course/Create/CreateCourse.tsx
+++ b/apps/web/components/Objects/Modals/Course/Create/CreateCourse.tsx
@@ -111,22 +111,22 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
Please provide a thumbnail for your course
-
+
- Course tags (separated by comma)
+ Course Learnings (separated by comma)
Please provide learning elements, separated by comma (,)
-
+
Course Visibility
- Please choose cours visibility
+ Please choose course visibility
+ }
+
+ >
+ )
+}
+
+export default AdminAuthorization
\ No newline at end of file
diff --git a/apps/web/components/Security/AuthenticatedClientElement.tsx b/apps/web/components/Security/AuthenticatedClientElement.tsx
index a02ead11..138b4ca5 100644
--- a/apps/web/components/Security/AuthenticatedClientElement.tsx
+++ b/apps/web/components/Security/AuthenticatedClientElement.tsx
@@ -1,8 +1,5 @@
'use client';
import React from "react";
-import useSWR, { mutate } from "swr";
-import { getAPIUrl } from "@services/config/config";
-import { swrFetcher } from "@services/utils/ts/requests";
import { useSession } from "@components/Contexts/SessionContext";
import { useOrg } from "@components/Contexts/OrgContext";
@@ -20,18 +17,18 @@ export const AuthenticatedClientElement = (props: AuthenticatedClientElementProp
const [isAllowed, setIsAllowed] = React.useState(false);
const session = useSession() as any;
const org = useOrg() as any;
-
+
function isUserAllowed(roles: any[], action: string, resourceType: string, org_uuid: string): boolean {
// Iterate over the user's roles
for (const role of roles) {
-
+
// Check if the role is for the right organization
if (role.org.org_uuid === org_uuid) {
// Check if the user has the role for the resource type
if (role.role.rights && role.role.rights[resourceType]) {
-
+
// Check if the user is allowed to execute the action
const actionKey = `action_${action}`;
if (role.role.rights[resourceType][actionKey] === true) {
@@ -46,11 +43,16 @@ export const AuthenticatedClientElement = (props: AuthenticatedClientElementProp
}
function check() {
-
- if (props.checkMethod === 'authentication') {
- setIsAllowed(session.isAuthenticated);
- } else if (props.checkMethod === 'roles') {
- return setIsAllowed(isUserAllowed(session.roles, props.action!, props.ressourceType!, org.org_uuid));
+ if (session.isAuthenticated === false) {
+ setIsAllowed(false);
+ return;
+ }
+ else {
+ if (props.checkMethod === 'authentication') {
+ setIsAllowed(session.isAuthenticated);
+ } else if (props.checkMethod === 'roles') {
+ return setIsAllowed(isUserAllowed(session.roles, props.action!, props.ressourceType!, org.org_uuid));
+ }
}
}
diff --git a/apps/web/components/Security/HeaderProfileBox.tsx b/apps/web/components/Security/HeaderProfileBox.tsx
index 5d1e5464..02a4fd70 100644
--- a/apps/web/components/Security/HeaderProfileBox.tsx
+++ b/apps/web/components/Security/HeaderProfileBox.tsx
@@ -1,11 +1,12 @@
'use client';
-import React, { use, useEffect } from "react";
+import React, { useEffect } from "react";
import styled from "styled-components";
import Link from "next/link";
import Avvvatars from "avvvatars-react";
import { GearIcon } from "@radix-ui/react-icons";
import { Settings } from "lucide-react";
import { useSession } from "@components/Contexts/SessionContext";
+import UserAvatar from "@components/Objects/UserAvatar";
export const HeaderProfileBox = () => {
const session = useSession() as any;
@@ -33,9 +34,7 @@ export const HeaderProfileBox = () => {
@@ -51,7 +50,6 @@ const AccountArea = styled.div`
img {
width: 29px;
- border-radius: 19px;
}
`;
diff --git a/apps/web/components/StyledElements/Error/Error.tsx b/apps/web/components/StyledElements/Error/Error.tsx
index 63dc470f..b2b8e35f 100644
--- a/apps/web/components/StyledElements/Error/Error.tsx
+++ b/apps/web/components/StyledElements/Error/Error.tsx
@@ -1,22 +1,20 @@
+import { XCircle } from 'lucide-react'
import React from 'react'
-
function ErrorUI() {
return (
-
-
-
-
Error
-
Something went wrong
+
+
+
+
+
+
Error
+
Something went wrong
+
-
)
}
diff --git a/apps/web/components/StyledElements/Form/Form.tsx b/apps/web/components/StyledElements/Form/Form.tsx
index f038aefc..8abf88fe 100644
--- a/apps/web/components/StyledElements/Form/Form.tsx
+++ b/apps/web/components/StyledElements/Form/Form.tsx
@@ -5,7 +5,7 @@ import { blackA, violet, mauve } from '@radix-ui/colors';
import { Info } from 'lucide-react';
const FormLayout = (props: any, onSubmit: any) => (
-
+
{props.children}
);
diff --git a/apps/web/components/StyledElements/Modal/Modal.tsx b/apps/web/components/StyledElements/Modal/Modal.tsx
index 506ee123..f30f9752 100644
--- a/apps/web/components/StyledElements/Modal/Modal.tsx
+++ b/apps/web/components/StyledElements/Modal/Modal.tsx
@@ -27,7 +27,7 @@ const Modal = (params: ModalParams) => (
-
+
{params.dialogTitle}
@@ -118,7 +118,6 @@ const DialogContent = styled(Dialog.Content, {
left: '50%',
transform: 'translate(-50%, -50%)',
width: '90vw',
- overflow: 'hidden',
maxHeight: '85vh',
minHeight: '300px',
maxWidth: '600px',
diff --git a/apps/web/package-lock.json b/apps/web/package-lock.json
index a806572c..bac37a39 100644
--- a/apps/web/package-lock.json
+++ b/apps/web/package-lock.json
@@ -25,6 +25,7 @@
"@tiptap/react": "^2.0.0-beta.199",
"@tiptap/starter-kit": "^2.0.0-beta.199",
"avvvatars-react": "^0.4.2",
+ "dayjs": "^1.11.10",
"formik": "^2.2.9",
"framer-motion": "^10.16.1",
"lowlight": "^3.0.0",
@@ -4948,6 +4949,11 @@
"integrity": "sha512-4FbVrHDwfOASx7uQVxeiCTo7ggSdYZbqs8lH+WU6ViypPlDbe9y6IP5VVUDQBv9DcnyaiPT5XT0UWHgJ64zLeQ==",
"peer": true
},
+ "node_modules/dayjs": {
+ "version": "1.11.10",
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz",
+ "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ=="
+ },
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
diff --git a/apps/web/package.json b/apps/web/package.json
index 54d55a89..1deadc16 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -16,7 +16,7 @@
"@radix-ui/react-icons": "^1.1.1",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tooltip": "^1.0.5",
- "@sentry/nextjs": "^7.92.0",
+ "@sentry/nextjs": "^7.93.0",
"@stitches/react": "^1.2.8",
"@tiptap/extension-code-block-lowlight": "^2.1.11",
"@tiptap/extension-collaboration": "^2.0.0-beta.199",
@@ -26,6 +26,7 @@
"@tiptap/react": "^2.0.0-beta.199",
"@tiptap/starter-kit": "^2.0.0-beta.199",
"avvvatars-react": "^0.4.2",
+ "dayjs": "^1.11.10",
"formik": "^2.2.9",
"framer-motion": "^10.16.1",
"lowlight": "^3.0.0",
diff --git a/apps/web/public/ai_avatar.png b/apps/web/public/ai_avatar.png
new file mode 100644
index 00000000..6c1dea2f
Binary files /dev/null and b/apps/web/public/ai_avatar.png differ
diff --git a/apps/web/public/empty_avatar.png b/apps/web/public/empty_avatar.png
new file mode 100644
index 00000000..80fc9f32
Binary files /dev/null and b/apps/web/public/empty_avatar.png differ
diff --git a/apps/web/public/empty_thumbnail.png b/apps/web/public/empty_thumbnail.png
new file mode 100644
index 00000000..52eb3faf
Binary files /dev/null and b/apps/web/public/empty_thumbnail.png differ
diff --git a/apps/web/sentry.client.config.ts b/apps/web/sentry.client.config.ts
index df526510..c128f326 100644
--- a/apps/web/sentry.client.config.ts
+++ b/apps/web/sentry.client.config.ts
@@ -4,27 +4,31 @@
import * as Sentry from "@sentry/nextjs";
-Sentry.init({
- dsn: "https://5a456d54654c494b9a416c19e3b94573@o4505007882436608.ingest.sentry.io/4505008095625216",
+if (process.env.NODE_ENV !== "development") {
+ const DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
- // Adjust this value in production, or use tracesSampler for greater control
- tracesSampleRate: 1,
+ Sentry.init({
+ dsn: DSN,
- // Setting this option to true will print useful information to the console while you're setting up Sentry.
- debug: false,
+ // Adjust this value in production, or use tracesSampler for greater control
+ tracesSampleRate: 1,
- replaysOnErrorSampleRate: 1.0,
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
+ debug: false,
- // This sets the sample rate to be 10%. You may want this to be 100% while
- // in development and sample at a lower rate in production
- replaysSessionSampleRate: 0.1,
+ replaysOnErrorSampleRate: 1.0,
- // You can remove this option if you're not planning to use the Sentry Session Replay feature:
- integrations: [
- new Sentry.Replay({
- // Additional Replay configuration goes in here, for example:
- maskAllText: true,
- blockAllMedia: true,
- }),
- ],
-});
+ // This sets the sample rate to be 10%. You may want this to be 100% while
+ // in development and sample at a lower rate in production
+ replaysSessionSampleRate: 0.1,
+
+ // You can remove this option if you're not planning to use the Sentry Session Replay feature:
+ integrations: [
+ new Sentry.Replay({
+ // Additional Replay configuration goes in here, for example:
+ maskAllText: true,
+ blockAllMedia: true,
+ }),
+ ],
+ });
+}
diff --git a/apps/web/sentry.edge.config.ts b/apps/web/sentry.edge.config.ts
deleted file mode 100644
index 00fc639b..00000000
--- a/apps/web/sentry.edge.config.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
-// The config you add here will be used whenever one of the edge features is loaded.
-// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
-// https://docs.sentry.io/platforms/javascript/guides/nextjs/
-
-import * as Sentry from "@sentry/nextjs";
-
-Sentry.init({
- dsn: "https://5a456d54654c494b9a416c19e3b94573@o4505007882436608.ingest.sentry.io/4505008095625216",
-
- // Adjust this value in production, or use tracesSampler for greater control
- tracesSampleRate: 1,
-
- // Setting this option to true will print useful information to the console while you're setting up Sentry.
- debug: false,
-});
diff --git a/apps/web/sentry.server.config.ts b/apps/web/sentry.server.config.ts
index ea085c48..a2a48ed9 100644
--- a/apps/web/sentry.server.config.ts
+++ b/apps/web/sentry.server.config.ts
@@ -4,12 +4,10 @@
import * as Sentry from "@sentry/nextjs";
-Sentry.init({
- dsn: "https://5a456d54654c494b9a416c19e3b94573@o4505007882436608.ingest.sentry.io/4505008095625216",
-
- // Adjust this value in production, or use tracesSampler for greater control
- tracesSampleRate: 1,
-
- // Setting this option to true will print useful information to the console while you're setting up Sentry.
- debug: false,
-});
+if (process.env.NODE_ENV !== "development") {
+ const DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
+ Sentry.init({
+ dsn: DSN,
+ tracesSampleRate: 1.0,
+ });
+}
diff --git a/apps/web/services/auth/auth.ts b/apps/web/services/auth/auth.ts
index 7269f1a6..38da9485 100644
--- a/apps/web/services/auth/auth.ts
+++ b/apps/web/services/auth/auth.ts
@@ -1,5 +1,4 @@
import { getAPIUrl } from "@services/config/config";
-import { NextApiRequestCookies } from "next/dist/server/api-utils";
interface LoginAndGetTokenResponse {
access_token: "string";
@@ -83,7 +82,7 @@ export async function getUserSession(token: string): Promise {
export async function getNewAccessTokenUsingRefreshToken(): Promise {
const requestOptions: any = {
- method: "POST",
+ method: "GET",
redirect: "follow",
credentials: "include",
};
@@ -95,7 +94,7 @@ export async function getNewAccessTokenUsingRefreshToken(): Promise {
export async function getNewAccessTokenUsingRefreshTokenServer(refresh_token_cookie: any): Promise {
const requestOptions: any = {
- method: "POST",
+ method: "GET",
redirect: "follow",
headers: {
Cookie: `refresh_token_cookie=${refresh_token_cookie}`,
@@ -139,3 +138,18 @@ export async function signup(body: NewAccountBody): Promise {
return res;
}
+
+export async function signUpWithInviteCode(body: NewAccountBody,invite_code:string): Promise {
+ const HeadersConfig = new Headers({ "Content-Type": "application/json" });
+
+ const requestOptions: any = {
+ method: "POST",
+ headers: HeadersConfig,
+ body: JSON.stringify(body),
+ redirect: "follow",
+ };
+
+ const res = await fetch(`${getAPIUrl()}users/${body.org_id}/invite/${invite_code}`, requestOptions);
+
+ return res;
+}
diff --git a/apps/web/services/courses/courses.ts b/apps/web/services/courses/courses.ts
index e9ba32f4..200557de 100644
--- a/apps/web/services/courses/courses.ts
+++ b/apps/web/services/courses/courses.ts
@@ -1,5 +1,5 @@
import { getAPIUrl } from "@services/config/config";
-import { RequestBody, RequestBodyForm, RequestBodyWithAuthHeader, errorHandling } from "@services/utils/ts/requests";
+import { RequestBody, RequestBodyForm, RequestBodyWithAuthHeader, errorHandling, getResponseMetadata } from "@services/utils/ts/requests";
/*
This file includes only POST, PUT, DELETE requests
@@ -36,6 +36,14 @@ export async function getCourse(course_uuid: string, next: any) {
return res;
}
+export async function updateCourseThumbnail(course_uuid: any, thumbnail: any) {
+ const formData = new FormData();
+ formData.append("thumbnail", thumbnail);
+ const result: any = await fetch(`${getAPIUrl()}courses/${course_uuid}/thumbnail`, RequestBodyForm("PUT", formData, null));
+ const res = await getResponseMetadata(result);
+ return res;
+}
+
export async function createNewCourse(org_id: string, course_body: any, thumbnail: any) {
// Send file thumbnail as form data
const formData = new FormData();
@@ -45,7 +53,10 @@ export async function createNewCourse(org_id: string, course_body: any, thumbnai
formData.append("learnings", course_body.tags);
formData.append("tags", course_body.tags);
formData.append("about", course_body.description);
- formData.append("thumbnail", thumbnail);
+
+ if (thumbnail) {
+ formData.append("thumbnail", thumbnail);
+ }
const result = await fetch(`${getAPIUrl()}courses/?org_id=${org_id}`, RequestBodyForm("POST", formData, null));
const res = await errorHandling(result);
diff --git a/apps/web/services/media/media.ts b/apps/web/services/media/media.ts
index b17191a2..c99161d9 100644
--- a/apps/web/services/media/media.ts
+++ b/apps/web/services/media/media.ts
@@ -9,38 +9,43 @@ function getMediaUrl() {
}
}
-export function getCourseThumbnailMediaDirectory(orgId: string, courseId: string, fileId: string) {
- let uri = `${getMediaUrl()}content/${orgId}/courses/${courseId}/thumbnails/${fileId}`;
+export function getCourseThumbnailMediaDirectory(orgUUID: string, courseId: string, fileId: string) {
+ let uri = `${getMediaUrl()}content/orgs/${orgUUID}/courses/${courseId}/thumbnails/${fileId}`;
return uri;
}
-export function getActivityBlockMediaDirectory(orgId: string, courseId: string, activityId: string, blockId: any, fileId: any, type: string) {
+export function getUserAvatarMediaDirectory(userUUID: string, fileId: string) {
+ let uri = `${getMediaUrl()}content/users/${userUUID}/avatars/${fileId}`;
+ return uri;
+}
+
+export function getActivityBlockMediaDirectory(orgUUID: string, courseId: string, activityId: string, blockId: any, fileId: any, type: string) {
if (type == "pdfBlock") {
- let uri = `${getMediaUrl()}content/${orgId}/courses/${courseId}/activities/${activityId}/dynamic/blocks/pdfBlock/${blockId}/${fileId}`;
+ let uri = `${getMediaUrl()}content/orgs/${orgUUID}/courses/${courseId}/activities/${activityId}/dynamic/blocks/pdfBlock/${blockId}/${fileId}`;
return uri;
}
if (type == "videoBlock") {
- let uri = `${getMediaUrl()}content/${orgId}/courses/${courseId}/activities/${activityId}/dynamic/blocks/videoBlock/${blockId}/${fileId}`;
+ let uri = `${getMediaUrl()}content/orgs/${orgUUID}/courses/${courseId}/activities/${activityId}/dynamic/blocks/videoBlock/${blockId}/${fileId}`;
return uri;
}
if (type == "imageBlock") {
- let uri = `${getMediaUrl()}content/${orgId}/courses/${courseId}/activities/${activityId}/dynamic/blocks/imageBlock/${blockId}/${fileId}`;
+ let uri = `${getMediaUrl()}content/orgs/${orgUUID}/courses/${courseId}/activities/${activityId}/dynamic/blocks/imageBlock/${blockId}/${fileId}`;
return uri;
}
}
-export function getActivityMediaDirectory(orgId: string, courseId: string, activityId: string, fileId: string, activityType: string) {
+export function getActivityMediaDirectory(orgUUID: string, courseId: string, activityId: string, fileId: string, activityType: string) {
if (activityType == "video") {
- let uri = `${getMediaUrl()}content/${orgId}/courses/${courseId}/activities/${activityId}/video/${fileId}`;
+ let uri = `${getMediaUrl()}content/orgs/${orgUUID}/courses/${courseId}/activities/${activityId}/video/${fileId}`;
return uri;
}
if (activityType == "documentpdf") {
- let uri = `${getMediaUrl()}content/${orgId}/courses/${courseId}/activities/${activityId}/documentpdf/${fileId}`;
+ let uri = `${getMediaUrl()}content/orgs/${orgUUID}/courses/${courseId}/activities/${activityId}/documentpdf/${fileId}`;
return uri;
}
}
-export function getOrgLogoMediaDirectory(orgId: string, fileId: string) {
- let uri = `${getMediaUrl()}content/${orgId}/logos/${fileId}`;
+export function getOrgLogoMediaDirectory(orgUUID: string, fileId: string) {
+ let uri = `${getMediaUrl()}content/orgs/${orgUUID}/logos/${fileId}`;
return uri;
}
diff --git a/apps/web/services/organizations/invites.ts b/apps/web/services/organizations/invites.ts
new file mode 100644
index 00000000..8d90fb6f
--- /dev/null
+++ b/apps/web/services/organizations/invites.ts
@@ -0,0 +1,26 @@
+import { getAPIUrl } from "@services/config/config";
+import { RequestBody, errorHandling, getResponseMetadata } from "@services/utils/ts/requests";
+
+export async function createInviteCode(org_id: any) {
+ const result = await fetch(`${getAPIUrl()}orgs/${org_id}/invites`, RequestBody("POST", null, null));
+ const res = await getResponseMetadata(result);
+ return res;
+}
+
+export async function deleteInviteCode(org_id: any, org_invite_code_uuid: string) {
+ const result = await fetch(`${getAPIUrl()}orgs/${org_id}/invites/${org_invite_code_uuid}`, RequestBody("DELETE", null, null));
+ const res = await getResponseMetadata(result);
+ return res;
+}
+
+export async function changeSignupMechanism(org_id: any, signup_mechanism: string) {
+ const result = await fetch(`${getAPIUrl()}orgs/${org_id}/signup_mechanism?signup_mechanism=${signup_mechanism}`, RequestBody("PUT", null, null));
+ const res = await getResponseMetadata(result);
+ return res;
+}
+
+export async function validateInviteCode(org_id: any, invite_code: string) {
+ const result = await fetch(`${getAPIUrl()}orgs/${org_id}/invites/code/${invite_code}`, RequestBody("GET", null, null));
+ const res = await getResponseMetadata(result);
+ return res;
+}
diff --git a/apps/web/services/organizations/orgs.ts b/apps/web/services/organizations/orgs.ts
index 7af9c6af..59a38163 100644
--- a/apps/web/services/organizations/orgs.ts
+++ b/apps/web/services/organizations/orgs.ts
@@ -1,5 +1,5 @@
import { getAPIUrl } from "@services/config/config";
-import { RequestBody, errorHandling } from "@services/utils/ts/requests";
+import { RequestBody, errorHandling, getResponseMetadata } from "@services/utils/ts/requests";
/*
This file includes only POST, PUT, DELETE requests
@@ -49,3 +49,15 @@ export function getOrganizationContextInfoNoAsync(org_slug: any, next: any) {
const result = fetch(`${getAPIUrl()}orgs/slug/${org_slug}`, RequestBody("GET", null, next));
return result;
}
+
+export async function updateUserRole(org_id: any, user_id: any, role_uuid: any) {
+ const result = await fetch(`${getAPIUrl()}orgs/${org_id}/users/${user_id}/role/${role_uuid}`, RequestBody("PUT", null, null));
+ const res = await getResponseMetadata(result);
+ return res;
+}
+
+export async function removeUserFromOrg(org_id: any, user_id: any) {
+ const result = await fetch(`${getAPIUrl()}orgs/${org_id}/users/${user_id}`, RequestBody("DELETE", null, null));
+ const res = await getResponseMetadata(result);
+ return res;
+}
diff --git a/apps/web/services/users/users.ts b/apps/web/services/users/users.ts
index 798079ab..b267412b 100644
--- a/apps/web/services/users/users.ts
+++ b/apps/web/services/users/users.ts
@@ -1,8 +1,16 @@
import { getAPIUrl } from "@services/config/config";
-import { RequestBody, errorHandling } from "@services/utils/ts/requests";
+import { RequestBody, RequestBodyForm, errorHandling, getResponseMetadata } from "@services/utils/ts/requests";
export async function getUser(user_id: string) {
const result = await fetch(`${getAPIUrl()}users/user_id/${user_id}`, RequestBody("GET", null, null));
const res = await errorHandling(result);
return res;
+}
+
+export async function updateUserAvatar(user_uuid: any, avatar_file: any) {
+ const formData = new FormData();
+ formData.append("avatar_file", avatar_file);
+ const result: any = await fetch(`${getAPIUrl()}users/update_avatar/${user_uuid}`, RequestBodyForm("PUT", formData, null));
+ const res = await getResponseMetadata(result);
+ return res;
}
\ No newline at end of file
diff --git a/apps/web/services/utils/ts/requests.ts b/apps/web/services/utils/ts/requests.ts
index 3b3761fa..21455572 100644
--- a/apps/web/services/utils/ts/requests.ts
+++ b/apps/web/services/utils/ts/requests.ts
@@ -75,6 +75,23 @@ export const errorHandling = (res: any) => {
return res.json();
};
+
+type CustomResponseTyping = {
+ success: boolean;
+ data: any;
+ status: number;
+ HTTPmessage: string;
+};
+
+export const getResponseMetadata = async (fetch_result: any): Promise => {
+ const json = await fetch_result.json();
+ if (fetch_result.status === 200) {
+ return { success: true, data: json, status: fetch_result.status, HTTPmessage: fetch_result.statusText };
+ } else {
+ return { success: false, data: json, status: fetch_result.status, HTTPmessage: fetch_result.statusText };
+ }
+};
+
export const revalidateTags = async (tags: string[], orgslug: string) => {
const url = getUriWithOrg(orgslug, "");
tags.forEach((tag) => {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 10ac1539..b882fd1e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -42,7 +42,7 @@ importers:
specifier: ^1.0.5
version: 1.0.7(@types/react-dom@18.0.6)(@types/react@18.2.8)(react-dom@18.2.0)(react@18.2.0)
'@sentry/nextjs':
- specifier: ^7.92.0
+ specifier: ^7.93.0
version: 7.93.0(next@14.0.4)(react@18.2.0)
'@stitches/react':
specifier: ^1.2.8
@@ -71,6 +71,9 @@ importers:
avvvatars-react:
specifier: ^0.4.2
version: 0.4.2(csstype@3.1.2)(react-dom@18.2.0)(react@18.2.0)
+ dayjs:
+ specifier: ^1.11.10
+ version: 1.11.10
formik:
specifier: ^2.2.9
version: 2.4.5(react@18.2.0)
@@ -3398,6 +3401,10 @@ packages:
/caniuse-lite@1.0.30001547:
resolution: {integrity: sha512-W7CrtIModMAxobGhz8iXmDfuJiiKg1WADMO/9x7/CLNin5cpSbuBjooyoIUVB5eyCc36QuTVlkVa1iB2S5+/eA==}
+ /caniuse-lite@1.0.30001579:
+ resolution: {integrity: sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==}
+ dev: false
+
/case-anything@2.1.13:
resolution: {integrity: sha512-zlOQ80VrQ2Ue+ymH5OuM/DlDq64mEm+B9UTdHULv5osUMD6HalNTblf2b1u/m6QecjsnOkBpqVZ+XPwIVsy7Ng==}
engines: {node: '>=12.13'}
@@ -3544,6 +3551,10 @@ packages:
resolution: {integrity: sha512-4FbVrHDwfOASx7uQVxeiCTo7ggSdYZbqs8lH+WU6ViypPlDbe9y6IP5VVUDQBv9DcnyaiPT5XT0UWHgJ64zLeQ==}
dev: false
+ /dayjs@1.11.10:
+ resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==}
+ dev: false
+
/debug@2.6.9:
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
peerDependencies:
@@ -4949,7 +4960,7 @@ packages:
'@next/env': 14.0.4
'@swc/helpers': 0.5.2
busboy: 1.6.0
- caniuse-lite: 1.0.30001547
+ caniuse-lite: 1.0.30001579
graceful-fs: 4.2.11
postcss: 8.4.31
react: 18.2.0