Skip to content

Commit

Permalink
Merge pull request #180 from Aar-if/main
Browse files Browse the repository at this point in the history
Issue #PS-1775 feat: Course planner API integration to View list of Topics and Sub-Topics
  • Loading branch information
itsvick authored Aug 30, 2024
2 parents c72eb08 + 4df2e3c commit eb7647f
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 171 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ NEXT_PUBLIC_TELEMETRY_URL=https://qa.prathamteacherapp.tekdinext.com
NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://notification.prathamdigital.org
# NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://qa.prathamteacherapp.tekdinext.com/notification-service
NEXT_PUBLIC_SHIKSHALOKAM_API_URL=https://dev.elevate-apis.shikshalokam.org/project/v1
NEXT_PUBLIC_SHIKSHALOKAM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoyNjIsIm5hbWUiOiJ0ZWtkaVRlc3RVc2VyIiwic2Vzc2lvbl9pZCI6NjE5NSwib3JnYW5pemF0aW9uX2lkIjoxLCJyb2xlcyI6W3siaWQiOjEyLCJ0aXRsZSI6InByb2dyYW1fZGVzaWduZXIiLCJsYWJlbCI6IlByb2dyYW0gRGVzaWduZXIiLCJ1c2VyX3R5cGUiOjAsInN0YXR1cyI6IkFDVElWRSIsIm9yZ2FuaXphdGlvbl9pZCI6MSwidmlzaWJpbGl0eSI6IlBVQkxJQyJ9LHsiaWQiOjIxLCJ0aXRsZSI6ImRpc3RyaWN0X3Jlc291cmNlX3BlcnNvbiIsImxhYmVsIjoiRGlzdHJpY3QgUmVzb3VyY2UgUGVyc29uIiwidXNlcl90eXBlIjowLCJzdGF0dXMiOiJBQ1RJVkUiLCJvcmdhbml6YXRpb25faWQiOjI0LCJ2aXNpYmlsaXR5IjoiUFVCTElDIn1dfSwiaWF0IjoxNzI0OTI0ODQxLCJleHAiOjE3MjUwMTEyNDF9.832p0WvwJUxa0upAPXufjclF1lDU9NmzMdILLz54afk

NEXT_PUBLIC_SUNBIRDSAAS_API_URL=https://sunbirdsaas.com
NEXT_PUBLIC_SHIKSHALOKAM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoyNjIsIm5hbWUiOiJ0ZWtkaVRlc3RVc2VyIiwic2Vzc2lvbl9pZCI6NjI2OSwib3JnYW5pemF0aW9uX2lkIjoxLCJyb2xlcyI6W3siaWQiOjEyLCJ0aXRsZSI6InByb2dyYW1fZGVzaWduZXIiLCJsYWJlbCI6IlByb2dyYW0gRGVzaWduZXIiLCJ1c2VyX3R5cGUiOjAsInN0YXR1cyI6IkFDVElWRSIsIm9yZ2FuaXphdGlvbl9pZCI6MSwidmlzaWJpbGl0eSI6IlBVQkxJQyJ9LHsiaWQiOjIxLCJ0aXRsZSI6ImRpc3RyaWN0X3Jlc291cmNlX3BlcnNvbiIsImxhYmVsIjoiRGlzdHJpY3QgUmVzb3VyY2UgUGVyc29uIiwidXNlcl90eXBlIjowLCJzdGF0dXMiOiJBQ1RJVkUiLCJvcmdhbml6YXRpb25faWQiOjI0LCJ2aXNpYmlsaXR5IjoiUFVCTElDIn1dfSwiaWF0IjoxNzI1MDA0MzI0LCJleHAiOjE3MjUwOTA3MjR9.70SVO8SFauUfeleWHFraai70WPLZSbka2QeEAykSALs
21 changes: 20 additions & 1 deletion src/pages/course-planner/foundation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useTranslation } from "next-i18next";
import ProtectedRoute from "../../components/ProtectedRoute";
import cardData from "@/data/cardData";
import Loader from "@/components/Loader";
import { getChannelDetails } from "@/services/coursePlanner";

const Foundation = () => {
const router = useRouter();
Expand All @@ -38,12 +39,30 @@ const Foundation = () => {
const fetchData = async () => {
setTimeout(() => {
setLoading(false);
}, 2000);
}, 1000);
};

fetchData();
}, []);

useEffect(() => {
const fetchChannelDetails = async () => {
try {
const data = await getChannelDetails();
console.log(data?.result?.channel?.frameworks);
localStorage.setItem("channelDetails", JSON.stringify(data?.result?.channel?.frameworks))
} catch (err) {
console.log(err);

} finally {
setLoading(false);
}
};

fetchChannelDetails();
}, []);


const handleCardClick = (id: any) => {
router.push(`/stateDetails?cardId=${id}`);
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/csvDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const FileDetails = () => {
setSelectedFile({ name: fileName } as File);
}
setLoading(false);
}, 2000); // Simulated loading time
}, 1000); // Simulated loading time
};

fetchFileData();
Expand Down
34 changes: 15 additions & 19 deletions src/pages/importCsv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const ImportCsv = () => {
}
}
setLoading(false);
}, 2000); // Simulated loading time
}, 1000); // Simulated loading time
};

fetchData();
Expand All @@ -77,13 +77,12 @@ const ImportCsv = () => {
try {
setLoading(true);
const response = await getTargetedSolutions({
subject: 'Marathi',
class: '10',
subject: 'Assamese',
class: '6',
state: 'Maharashtra',
board: 'ISEB',
board: 'AAKR',
type: 'mainCourse',
role: 'Teacher',
medium: 'Hindi',
medium: 'Assamese',
});

const courseData = response.result.data[0];
Expand Down Expand Up @@ -116,13 +115,12 @@ const ImportCsv = () => {
});

const updatedResponse = await getTargetedSolutions({
subject: 'Marathi',
class: '10',
subject: 'Assamese',
class: '6',
state: 'Maharashtra',
board: 'ISEB',
board: 'AAKR',
type: 'mainCourse',
role: 'Teacher',
medium: 'Hindi',
medium: 'Assamese',
});
setLoading(false);
return updatedResponse.result.data[0]._id;
Expand Down Expand Up @@ -177,13 +175,12 @@ const ImportCsv = () => {
const handleUpload = async () => {
if (selectedFile) {
const metaData: CoursePlannerMetaData = {
subject: "Marathi",
class: "10",
state: "Maharashtra",
board: "ISEB",
type: "mainCourse",
role: "Teacher",
medium: "Hindi",
subject: 'Assamese',
class: '6',
state: 'Maharashtra',
board: 'AAKR',
type: 'mainCourse',
medium: 'Assamese',
};

const result = await uploadCoursePlanner(selectedFile, metaData)
Expand Down Expand Up @@ -321,7 +318,6 @@ const ImportCsv = () => {
showGradeMedium={false}
showFoundaitonCourse={false}
/>

<Box
sx={{
padding: "16px",
Expand Down
169 changes: 89 additions & 80 deletions src/pages/stateDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { CircularProgressbar, buildStyles } from "react-circular-progressbar";

const StateDetails = () => {
const router = useRouter();
const { cardId } = router.query;
const { boardId, cardId } = router.query;
const { t } = useTranslation();
const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm"));
Expand All @@ -35,14 +35,28 @@ const StateDetails = () => {
const [searchQuery, setSearchQuery] = useState("");
const [selectedOption, setSelectedOption] = useState("");
const [card, setCard] = useState<any>(null);
const [boards, setBoards] = useState<any>([]);

useEffect(() => {
const fetchData = async () => {
setTimeout(() => {
const foundCard = cardData.find((c) => c.id === cardId);
setCard(foundCard);


if (typeof window !== 'undefined') {
const channel = localStorage.getItem('channelDetails');

if (channel) {
const parsedBoards = JSON.parse(channel);
setBoards(parsedBoards);
} else {
console.error('No channel details found in localStorage.');
}
}

setLoading(false);
}, 2000);
}, 1000);
};

fetchData();
Expand Down Expand Up @@ -129,85 +143,80 @@ const StateDetails = () => {
</Box>
</Box>
<Grid spacing={2} container sx={{ marginTop: "16px" }}>
{card.boards?.map((board: string, index: number) => (
<Grid item xs={12} md={4}>
<Box
key={index}
sx={{

alignItems: "center",
cursor: "pointer",
border: "1px solid #0000001A",
boxShadow: "none",
transition: "background-color 0.3s",
"&:hover": {
backgroundColor: "#EAF2FF",
},
marginTop: "8px",
padding: "16px",
display:'flex',
justifyContent:'space-between'
}}
onClick={() => {
if (typeof board === "string") {
handleBoardClick(board);
}
}}
>
<Box>
<Box
sx={{
display: "flex",
alignItems: "center",
gap: "8px",
}}
>
<FolderOutlinedIcon />
<Typography variant="h6" sx={{ fontSize: "16px" }}>
{board}
</Typography>
</Box>
<Box
sx={{
display: "flex",
alignItems: "center",
gap: "16px",
}}
>
<Box sx={{ width: "40px", height: "40px" }}>
<CircularProgressbar
value={(card.boardsUploaded / card.totalBoards) * 100}
strokeWidth={10}
styles={buildStyles({
pathColor: "#06A816",
trailColor: "#E6E6E6",
strokeLinecap: "round",
})}
/>
</Box>
<Typography sx={{ fontSize: "14px" }}>
{card.boardsUploaded} / {card.totalBoards}{" "}
{t("COURSE_PLANNER.SUBJECTS_UPLOADED")}
</Typography>
</Box>
</Box>
<Box sx={{ display: "flex", justifyContent: "center" }}>
<Button
onClick={(e) => {
e.stopPropagation();
if (typeof board === "string") {
handleCopyLink(board);
}
}}
sx={{ minWidth: "auto", padding: 0 }}
>
<InsertLinkOutlinedIcon />
</Button>
</Box>
{boards.map((board: any, index: number) => (
<Grid item xs={12} md={4} key={index}>
<Box
sx={{
alignItems: "center",
cursor: "pointer",
border: "1px solid #0000001A",
boxShadow: "none",
transition: "background-color 0.3s",
"&:hover": {
backgroundColor: "#EAF2FF",
},
marginTop: "8px",
padding: "16px",
display: 'flex',
justifyContent: 'space-between'
}}
onClick={() => {
handleBoardClick(board?.identifier);
}}
>
<Box>
<Box
sx={{
display: "flex",
alignItems: "center",
gap: "8px",
}}
>
<FolderOutlinedIcon />
<Typography variant="h6" sx={{ fontSize: "16px" }}>
{board?.name}
</Typography>
</Box>
<Box
sx={{
display: "flex",
alignItems: "center",
gap: "16px",
}}
>
<Box sx={{ width: "40px", height: "40px" }}>
<CircularProgressbar
value={(card.boardsUploaded / card.totalBoards) * 100}
strokeWidth={10}
styles={buildStyles({
pathColor: "#06A816",
trailColor: "#E6E6E6",
strokeLinecap: "round",
})}
/>
</Box>
</Grid>
))}{" "}
</Grid>
<Typography sx={{ fontSize: "14px" }}>
{card.boardsUploaded} / {card.totalBoards}{" "}
{t("COURSE_PLANNER.SUBJECTS_UPLOADED")}
</Typography>
</Box>
</Box>
<Box sx={{ display: "flex", justifyContent: "center" }}>
<Button
onClick={(e) => {
e.stopPropagation();
handleCopyLink(board?.identifier);
}}
sx={{ minWidth: "auto", padding: 0 }}
>
<InsertLinkOutlinedIcon />
</Button>
</Box>
</Box>
</Grid>
))}
</Grid>

</Box>
);
};
Expand Down
Loading

0 comments on commit eb7647f

Please sign in to comment.