Skip to content

Commit

Permalink
Merge pull request #183 from Aar-if/main
Browse files Browse the repository at this point in the history
Issue #PS-1840 feat: Taxonomy API integration in Admin App
  • Loading branch information
itsvick authored Sep 3, 2024
2 parents 98f1e03 + 110fef0 commit 5c6c67f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
14 changes: 8 additions & 6 deletions src/pages/importCsv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspace
import RadioButtonUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked';
import dayjs from 'dayjs';
import { Role } from "@/utils/app.constant";
import coursePlannerStore from "@/store/coursePlannerStore";

const ImportCsv = () => {
const router = useRouter();
const store = coursePlannerStore();
const { subject } = router.query;
const { t } = useTranslation();
const [subjectDetails, setSubjectDetails] = useState<any | null>(null);
Expand Down Expand Up @@ -77,10 +79,10 @@ const ImportCsv = () => {
try {
setLoading(true);
const response = await getTargetedSolutions({
subject: 'Tamil',
subject: store?.taxanomySubject,
class: '4',
state: 'Maharashtra',
board: 'TQKR',
board: store?.boardName,
type: 'mainCourse',
medium: 'Telugu',
});
Expand Down Expand Up @@ -115,10 +117,10 @@ const ImportCsv = () => {
});

const updatedResponse = await getTargetedSolutions({
subject: 'Tamil',
subject: store?.taxanomySubject,
class: '4',
state: 'Maharashtra',
board: 'TQKR',
board: store?.boardName,
type: 'mainCourse',
medium: 'Telugu',
});
Expand Down Expand Up @@ -175,10 +177,10 @@ const ImportCsv = () => {
const handleUpload = async () => {
if (selectedFile) {
const metaData: CoursePlannerMetaData = {
subject: 'Tamil',
subject: store?.taxanomySubject,
class: '4',
state: 'Maharashtra',
board: 'TQKR',
board: store?.boardName,
type: 'mainCourse',
medium: 'Telugu',
};
Expand Down
7 changes: 5 additions & 2 deletions src/pages/stateDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import CustomStepper from "@/components/Steper";
import { useTranslation } from "next-i18next";
import Loader from "@/components/Loader";
import { CircularProgressbar, buildStyles } from "react-circular-progressbar";
import coursePlannerStore from "@/store/coursePlannerStore";

const StateDetails = () => {
const router = useRouter();
Expand All @@ -36,6 +37,7 @@ const StateDetails = () => {
const [selectedOption, setSelectedOption] = useState("");
const [card, setCard] = useState<any>(null);
const [boards, setBoards] = useState<any>([]);
const setBoardname = coursePlannerStore((state) => state.setBoardname);

useEffect(() => {
const fetchData = async () => {
Expand Down Expand Up @@ -82,11 +84,12 @@ const StateDetails = () => {
setSelectedOption(event.target.value);
};

const handleBoardClick = (board: string) => {
const handleBoardClick = (board: string, boardName: string) => {
router.push({
pathname: "/subjectDetails",
query: { boardId: board, cardId: card.id },
});
setBoardname(boardName)
};

const handleCopyLink = (state: string) => {
Expand Down Expand Up @@ -161,7 +164,7 @@ const StateDetails = () => {
justifyContent: 'space-between'
}}
onClick={() => {
handleBoardClick(board?.identifier);
handleBoardClick(board?.identifier, board?.name);
}}
>
<Box>
Expand Down
13 changes: 8 additions & 5 deletions src/pages/subjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import FilterSearchBar from "@/components/FilterSearchBar";
import Loader from "@/components/Loader";
import { CircularProgressbar, buildStyles } from "react-circular-progressbar";
import { getFrameworkDetails } from "@/services/coursePlanner";
import coursePlannerStore from "@/store/coursePlannerStore";

// Define Card interface
interface Card {
Expand Down Expand Up @@ -47,7 +48,8 @@ const SubjectDetails = () => {
const [subject, setSubject] = useState<any>();
const [medium, setMedium] = useState<any>([]);
const [grade, setGrade] = useState<any>([]);

const setTaxanomySubject = coursePlannerStore((state) => state.setTaxanomySubject);

useEffect(() => {
const fetchData = async () => {
setTimeout(() => {
Expand Down Expand Up @@ -105,12 +107,13 @@ const SubjectDetails = () => {
router.back();
};

const handleCopyLink = (subject: string) => {};
const handleCopyLink = (subject: any) => {};

const handleCardClick = (subject: string) => {
router.push(`/importCsv?subject=${encodeURIComponent(subject)}`);
const handleCardClick = (subject: any) => {
router.push(`/importCsv?subject=${encodeURIComponent(subject?.name)}`);
setTaxanomySubject(subject?.name);
};

return (
<Box>
<FilterSearchBar
Expand Down
22 changes: 22 additions & 0 deletions src/store/coursePlannerStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable no-unused-vars */
import { create } from "zustand";
import { persist } from "zustand/middleware";

const coursePlannerStore = create(
persist(
(set) => ({
boardName: "",
taxanomySubject: "",
setBoardname: (newBoardname) =>
set((state) => ({ boardName: newBoardname })),
setTaxanomySubject: (newTaxanomySubject) =>
set((state) => ({ taxanomySubject: newTaxanomySubject})),
}),
{
name: "adminApp",
getStorage: () => localStorage,
}
)
);

export default coursePlannerStore;

0 comments on commit 5c6c67f

Please sign in to comment.