Skip to content

Commit

Permalink
feat(conif): config file for urls
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalEsMagico committed Dec 13, 2023
1 parent 4cd51ea commit c6db1b8
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
10 changes: 10 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const courseManagerBackendUrl =
process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL ||
'http://localhost:3000';
const marketplaceBackendUrl =
process.env.NEXT_PUBLIC_MARKETPLACE_SERVICE_BACKEND_URL ||
'http://localhost:3000';
module.exports = {
courseManagerBackendUrl,
marketplaceBackendUrl,
};
8 changes: 4 additions & 4 deletions src/services/accountVerficationServices.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { courseManagerBackendUrl } from '@root/config';
import axios from 'axios';

// course manager
export const getAllProviders = async () => {
const data = await axios.get(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/providers`
`${courseManagerBackendUrl}/api/admin/providers`
);
return data.data.data;
};

// course manager
export const approvedAccount = async (providerId: string) => {
await axios.patch(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/providers/${providerId}/verify`
`${courseManagerBackendUrl}/api/admin/providers/${providerId}/verify`
);
};

// course manager
export const rejectAccount = async (providerId: string, reason: string) => {
await axios.patch(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/providers/${providerId}/reject`,
`${courseManagerBackendUrl}/api/admin/providers/${providerId}/reject`,
{ rejectionReason: reason }
);
};
5 changes: 3 additions & 2 deletions src/services/authService.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { courseManagerBackendUrl } from '@root/config';
import axios from 'axios';

import { LoginDataType } from '@/app/login/page';

// course manager
export const loginAdmin = async (userData: LoginDataType) => {
const data = await axios.post(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/login`,
`${courseManagerBackendUrl}/api/admin/login`,
userData
);
return data.data.data;
};

export const signupAdmin = async (userData: FormData) => {
const data = await axios.post(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/signup`,
`${courseManagerBackendUrl}/api/admin/signup`,
userData
);
return data.data.data;
Expand Down
10 changes: 4 additions & 6 deletions src/services/marketPlaceServices.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { courseManagerBackendUrl } from '@root/config';
import axios from 'axios';

// course manager api
export const getAllCourses = async () => {
const data = await axios.get(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/courses`
);
const data = await axios.get(`${courseManagerBackendUrl}/api/admin/courses`);
return data.data.data;
};

// course manager api
export const approveCourse = async (courseId: string) => {
const data = await axios.patch(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/courses/${courseId}/accept`
`${courseManagerBackendUrl}/api/admin/courses/${courseId}/accept`
);
return data.data.data;
};

// course manager api
export const rejectCourse = async (courseId: string, reason: string) => {
const data = await axios.patch(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/courses/${courseId}/reject`,
`${courseManagerBackendUrl}/api/admin/courses/${courseId}/reject`,
{ rejectionReason: reason }
);
return data.data.data;
Expand Down
5 changes: 3 additions & 2 deletions src/services/settlementsSevices.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { courseManagerBackendUrl } from '@root/config';
import axios from 'axios';

export const getSettlementsData = async (adminId: string) => {
const data = await axios.get(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/${adminId}/providers/settlements`
`${courseManagerBackendUrl}/api/admin/${adminId}/providers/settlements`
);
return data.data.data;
};

export const handleSettlement = async (userId: string, adminId: string) => {
const payload = { id: userId };
const data = await axios.post(
`${process.env.NEXT_PUBLIC_COURSE_MANAGER_SERVICE_BACKEND_URL}/api/admin/${adminId}/providers/settlements`,
`${courseManagerBackendUrl}/api/admin/${adminId}/providers/settlements`,
payload
);
return data.data.data;
Expand Down
9 changes: 5 additions & 4 deletions src/services/userWalletSevices.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { marketplaceBackendUrl } from '@root/config';
import axios from 'axios';

export const getUserWalletDetails = async (adminId: string) => {
const data = await axios.get(
`${process.env.NEXT_PUBLIC_MARKETPLACE_SERVICE_BACKEND_URL}/api/admin/${adminId}/consumers`
`${marketplaceBackendUrl}/api/admin/${adminId}/consumers`
);
return data.data.data;
};
Expand All @@ -18,7 +19,7 @@ export const addCreditToUser = async (
adminId: string
) => {
const data = await axios.post(
`${process.env.NEXT_PUBLIC_MARKETPLACE_SERVICE_BACKEND_URL}/api/admin/${adminId}/addCredits`,
`${marketplaceBackendUrl}/api/admin/${adminId}/addCredits`,
payload
);
return data.data.data;
Expand All @@ -30,7 +31,7 @@ export const removeCreditFromUser = async (
adminId: string
) => {
const data = await axios.post(
`${process.env.NEXT_PUBLIC_MARKETPLACE_SERVICE_BACKEND_URL}/api/admin/${adminId}/reduceCredits`,
`${marketplaceBackendUrl}/api/admin/${adminId}/reduceCredits`,
payload
);
return data.data.data;
Expand All @@ -41,7 +42,7 @@ export const getTransactionHistory = async (
consumerId: string
) => {
const data = await axios.get(
`${process.env.NEXT_PUBLIC_MARKETPLACE_SERVICE_BACKEND_URL}/api/admin/${adminId}/userWallets/transactions/${consumerId}`
`${marketplaceBackendUrl}/api/admin/${adminId}/userWallets/transactions/${consumerId}`
);
return data.data.data;
};
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"~/*": ["./public/*"]
"~/*": ["./public/*"],
"@root/*": ["./*"]
},
"incremental": true,
"plugins": [
Expand Down

0 comments on commit c6db1b8

Please sign in to comment.