Skip to content

Commit

Permalink
add class api calling
Browse files Browse the repository at this point in the history
  • Loading branch information
scglwsj committed Aug 4, 2024
1 parent 315b137 commit 3eeef2d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ NEXT_PUBLIC_QUEMISTRY_DOMAIN =https://dkraju438qs82.cloudfront.net
NEXT_PUBLIC_RedirectUrl = $NEXT_PUBLIC_QUEMISTRY_DOMAIN/auth/google
NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL=https://dummyUrl
NEXT_PUBLIC_QUEMISTRY_AUTH_URL = $NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL/auth
NEXT_PUBLIC_QUEMISTRY_QUESTIONS_URL = $NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL/questions
NEXT_PUBLIC_QUEMISTRY_QUESTIONS_URL = $NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL/questions
NEXT_PUBLIC_QUEMISTRY_USER_URL = $NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL/user
# NEXT_PUBLIC_QUEMISTRY_USER_URL = 127.0.0.1
9 changes: 5 additions & 4 deletions app/(main)/classes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ChartOptions } from 'chart.js';
import { Dialog } from 'primereact/dialog';
import { InputText } from 'primereact/inputtext';
import { LayoutContext } from '@/layout/context/layoutcontext';
import { UserService } from '../../../service/UserService';

const Classes = () => {
const [addClass, setAddClass] = useState(false);
Expand Down Expand Up @@ -83,17 +84,17 @@ const Classes = () => {
};
};

const saveClass = () => {
clearNewClass();
const saveClass = async () => {
const newClass: Class = {
code: newClassCode,
description: newClassDescription,
educationLevel: newClassEducationLevel,
subject: newClassSubject
};

console.log(newClass);
};
await UserService.addClass("user-id", newClass)
clearNewClass();
}

const addClassFooter = (
<div>
Expand Down
Empty file removed service/UserService
Empty file.
18 changes: 18 additions & 0 deletions service/UserService.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const userServiceUrl = process.env.NEXT_PUBLIC_QUEMISTRY_USER_URL || ''
const saveUserServiceUrl =`${userServiceUrl}/v1/class`

export const UserService = {
async addClass(userId: string, data: Class) {
console.log("calling saveClass ", saveUserServiceUrl);
const res = await fetch(saveUserServiceUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-USER-ID': userId
},
credentials: "include",
body: JSON.stringify(data)
});
console.log("res", res);
}
}

0 comments on commit 3eeef2d

Please sign in to comment.