Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FRAC): integrating frac via WPCAS #6

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading