Skip to content

Commit

Permalink
Merge pull request #6 from COMPASS-DPG/integrating-frac
Browse files Browse the repository at this point in the history
feat(FRAC): integrating frac via WPCAS
  • Loading branch information
faisalEsMagico authored Apr 8, 2024
2 parents 4affaef + 8f83086 commit a96c09f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
# !STARTERCONF Change to true if you want to log data
NEXT_PUBLIC_SHOW_LOGGER="false"
PORT=3500
NEXT_PUBLIC_COURSE_MANAGER_BACKEND_URL=https://course.backend.compass.samagra.io
NEXT_PUBLIC_COURSE_MANAGER_BACKEND_URL=https://course.backend.compass.samagra.io
NEXT_PUBLIC_WPCAS_SERVICE_URL="https://wpcas.backend.compass.samagra.io"
4 changes: 4 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const courseManagerBackendUrl =
process.env.NEXT_PUBLIC_COURSE_MANAGER_BACKEND_URL || 'http://localhost:4030';

const wpcasBackendUrl =
process.env.NEXT_PUBLIC_WPCAS_SERVICE_URL || 'http://localhost:4010';

module.exports = {
courseManagerBackendUrl,
wpcasBackendUrl,
};
26 changes: 19 additions & 7 deletions src/components/newCourseForm/AddCompetencyAndLevel.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { wpcasBackendUrl } from '@root/config';
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import { AiOutlinePlus } from 'react-icons/ai';
import { RiDeleteBin5Fill } from 'react-icons/ri';

import MultiSelectTag from '@/components/inputtag/MultiSelectTag';
import SelectTag from '@/components/inputtag/SelectTag';
import Label from '@/components/Label';
import { Competency_Options } from '@/components/Options';

import { CompetencyAndLevelsType } from '@/app/my-courses/[add-course]/page';
import { CompetencyType, LevelsType } from '@/app/my-courses/page';
Expand All @@ -27,10 +28,12 @@ const AddCompetencyAndLevel = ({
data,
onChange,
}: PropType) => {
//
const [option, setOption] = useState<CompetencyType[]>([]);

// will filter levels by competency
const levels: LevelsType[] = Competency_Options.find(
(item) => item.name === data.name
)?.levels ?? [{ id: '', name: '', levelNumber: '' }];
const levels: LevelsType[] = option.find((item) => item.name === data.name)
?.levels ?? [{ id: '', name: '', levelNumber: '' }];

// will handle competency data
const handleChangeCompetency = (value: CompetencyType) => {
Expand All @@ -53,6 +56,15 @@ const AddCompetencyAndLevel = ({
}
};

useEffect(() => {
const getOption = async () => {
const response = await axios.get(
`${wpcasBackendUrl}/api/mockFracService/competency/competencyWithLevels`
);
setOption(response.data.data);
};
getOption();
}, []);
return (
<div className='my-[15px] flex items-end gap-4'>
<div className='grid w-[1000px] grid-cols-1 gap-4 lg:grid-cols-2'>
Expand All @@ -61,14 +73,14 @@ const AddCompetencyAndLevel = ({
<SelectTag
onChange={(value) =>
handleChangeCompetency(
Competency_Options?.find((item) => item?.name === value) ?? {
option?.find((item) => item?.name === value) ?? {
name: '',
id: '',
levels: [],
}
)
}
options={Competency_Options?.map((item) => {
options={option?.map((item) => {
return { label: item?.name, value: item?.name };
})}
placeholder='select competency'
Expand Down

0 comments on commit a96c09f

Please sign in to comment.