diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..32350a8d --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,37 @@ +name: CI/CD check + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run prettier test + run: yarn format:check + + # - name: Run the tests and generate coverage report + # run: yarn test + + - name: Build + run: yarn build \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 216dc2b4..bab89244 100644 --- a/.prettierignore +++ b/.prettierignore @@ -10,7 +10,8 @@ package-lock.json # production /build - +/**/build +/prod-build .github/ /public .min.js diff --git a/README.md b/README.md index 6ff1ce4b..476a1663 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,9 @@ lerna run start --scope=[module-name] core: 'core@[window.appModules.core.url]/remoteEntry.js', }, ``` -* Add entry to `modules.json` + +- Add entry to `modules.json` + ``` # e.g. core module is runninig on localhost:3001 then diff --git a/packages/attendance/src/App.js b/packages/attendance/src/App.js index 738f4115..7d826438 100644 --- a/packages/attendance/src/App.js +++ b/packages/attendance/src/App.js @@ -9,7 +9,7 @@ import ReportDetail from "pages/reports/ReportDetail"; import CompareReport from "pages/reports/CompareReport"; import MessageHistory from "pages/sms/MessageHistory"; import SendSMS from "pages/sms/SendSMS"; -import {navigationRoute} from './services/routes'; +import { navigationRoute } from "./services/routes"; function App() { const theme = extendTheme(DEFAULT_THEME); diff --git a/packages/attendance/src/atoms/ButtonHOC.js b/packages/attendance/src/atoms/ButtonHOC.js index f5c7bf33..83cfe121 100644 --- a/packages/attendance/src/atoms/ButtonHOC.js +++ b/packages/attendance/src/atoms/ButtonHOC.js @@ -1,9 +1,8 @@ -import React from 'react' +import React from "react"; import { Button } from "native-base"; -const ButtonHOC = ({children, ...rest}) => { +const ButtonHOC = ({ children, ...rest }) => { + return ; +}; - return -} - -export default ButtonHOC \ No newline at end of file +export default ButtonHOC; diff --git a/packages/attendance/src/atoms/FourOFour.js b/packages/attendance/src/atoms/FourOFour.js index 74601484..149ca374 100644 --- a/packages/attendance/src/atoms/FourOFour.js +++ b/packages/attendance/src/atoms/FourOFour.js @@ -1,20 +1,20 @@ -import React from 'react' +import React from "react"; import { Center } from "native-base"; const FourOFour = () => { return (
-
- 404 +
+ 404 +
-
- ) -} + ); +}; -export default FourOFour \ No newline at end of file +export default FourOFour; diff --git a/packages/attendance/src/atoms/GetIcon.js b/packages/attendance/src/atoms/GetIcon.js index 7954a384..8827745a 100644 --- a/packages/attendance/src/atoms/GetIcon.js +++ b/packages/attendance/src/atoms/GetIcon.js @@ -1,70 +1,69 @@ -import React from 'react' +import React from "react"; import { Box } from "native-base"; import { IconByName } from "@shiksha/common-lib"; export const GetIcon = ({ status, _box, color, _icon, type }) => { - let icon = <>; - let iconProps = { fontSize: "xl", isDisabled: true, ..._icon }; - switch (status) { - case "Present": - icon = ( - - - - ); - break; - case "Absent": - icon = ( - - - - ); - break; - case "Holiday": - icon = ( - - - - ); - break; - case "Unmarked": - icon = ( - - - - ); - break; - case "Today": - icon = ( - - - - ); - break; - default: - icon = ( - - - - ); - break; - } - return icon; - }; - + let icon = <>; + let iconProps = { fontSize: "xl", isDisabled: true, ..._icon }; + switch (status) { + case "Present": + icon = ( + + + + ); + break; + case "Absent": + icon = ( + + + + ); + break; + case "Holiday": + icon = ( + + + + ); + break; + case "Unmarked": + icon = ( + + + + ); + break; + case "Today": + icon = ( + + + + ); + break; + default: + icon = ( + + + + ); + break; + } + return icon; +}; -export default GetIcon \ No newline at end of file +export default GetIcon; diff --git a/packages/attendance/src/atoms/LinkHOC.js b/packages/attendance/src/atoms/LinkHOC.js index 332b7a06..04be8816 100644 --- a/packages/attendance/src/atoms/LinkHOC.js +++ b/packages/attendance/src/atoms/LinkHOC.js @@ -1,9 +1,8 @@ -import React from 'react' +import React from "react"; import { Link, useParams } from "react-router-dom"; -const LinkHOC = ({children, ...rest}) => { - - return {children} -} +const LinkHOC = ({ children, ...rest }) => { + return {children}; +}; -export default LinkHOC \ No newline at end of file +export default LinkHOC; diff --git a/packages/attendance/src/atoms/Loader.js b/packages/attendance/src/atoms/Loader.js index 8a993721..b5aa906b 100644 --- a/packages/attendance/src/atoms/Loader.js +++ b/packages/attendance/src/atoms/Loader.js @@ -1,45 +1,33 @@ -import React from 'react' -import { - Center, - Heading, - HStack, - Spinner, - Text, - VStack, -} from "native-base"; +import React from "react"; +import { Center, Heading, HStack, Spinner, Text, VStack } from "native-base"; - -const Loader = ({success, fail}) => { +const Loader = ({ success, fail }) => { return (
-
- - - {success ? success : ""} - - - {fail ? fail : ""} - - - - - Loading - - - +
+ + {success ? success : ""} + {fail ? fail : ""} + + + + Loading + + + +
-
- ) -} + ); +}; -export default Loader \ No newline at end of file +export default Loader; diff --git a/packages/attendance/src/pages/Attendance.js b/packages/attendance/src/pages/Attendance.js index 28590d23..bbd9adea 100644 --- a/packages/attendance/src/pages/Attendance.js +++ b/packages/attendance/src/pages/Attendance.js @@ -3,14 +3,7 @@ import { useTranslation } from "react-i18next"; import manifest from "../manifest.json"; import { useState, useEffect } from "react"; import { useParams } from "react-router-dom"; -import { - Box, - FlatList, - HStack, - Stack, - Text, - VStack, -} from "native-base"; +import { Box, FlatList, HStack, Stack, Text, VStack } from "native-base"; import { WeekWiesBar } from "components/CalendarBar"; import AttendanceComponent, { GetAttendance, @@ -93,14 +86,16 @@ export default function Attendance({ footerLinks }) { }; if (!classObject && !classObject?.name) { - return ; + return ; } if (loding) { - return + return ( + + ); } return ( @@ -111,11 +106,11 @@ export default function Attendance({ footerLinks }) { setSearch: setSearch, subHeading: t("ATTENDANCE_REGISTER"), iconComponent: ( - - - - - } - _text={{ fontWeight: "400" }} - onPress={(e) => setIsEditDisabled(!isEditDisabled)} + + + } + _text={{ fontWeight: "400" }} + onPress={(e) => setIsEditDisabled(!isEditDisabled)} > {isEditDisabled ? t("EDIT") : t("CANCEL")} - diff --git a/packages/attendance/src/pages/sms/MessageHistory/Molecule/CalendarComponent.js b/packages/attendance/src/pages/sms/MessageHistory/Molecule/CalendarComponent.js index 44e10419..c8a945d7 100644 --- a/packages/attendance/src/pages/sms/MessageHistory/Molecule/CalendarComponent.js +++ b/packages/attendance/src/pages/sms/MessageHistory/Molecule/CalendarComponent.js @@ -1,150 +1,141 @@ -import React from 'react' +import React from "react"; import moment from "moment"; -import { - Box, - HStack, - Pressable, - Text, - VStack, -} from "native-base"; +import { Box, HStack, Pressable, Text, VStack } from "native-base"; import { TouchableHighlight } from "react-native-web"; -import GetIcon from 'atoms/GetIcon'; - +import GetIcon from "atoms/GetIcon"; const CalendarComponent = ({ - monthDays, - type, - isIconSizeSmall, - sms, - setSmsObject, - student, - loding, - _weekBox, - }) => { - if (type === "month") { - return monthDays.map((week, index) => ( - 1 && monthDays.length - 1 !== index ? "1" : "0" + monthDays, + type, + isIconSizeSmall, + sms, + setSmsObject, + student, + loding, + _weekBox, +}) => { + if (type === "month") { + return monthDays.map((week, index) => ( + 1 && monthDays.length - 1 !== index ? "1" : "0" + } + borderBottomColor={"coolGray.300"} + p={"2"} + {...(_weekBox?.[index] ? _weekBox[index] : {})} + > + {week.map((day, subIndex) => { + let isToday = moment().format("Y-MM-DD") === day.format("Y-MM-DD"); + let dateValue = day.format("Y-MM-DD"); + let smsItem = sms + .slice() + .reverse() + .find((e) => e.date === dateValue); + let smsIconProp = !isIconSizeSmall + ? { + _box: { py: 2, minW: "46px", alignItems: "center" }, + status: "CheckboxBlankCircleLineIcon", + } + : {}; + if (smsItem?.type && smsItem?.type === "Present") { + smsIconProp = { + ...smsIconProp, + status: smsItem?.type, + type: smsItem?.status, + }; + } else if (smsItem?.type && smsItem?.type === "Absent") { + smsIconProp = { + ...smsIconProp, + status: smsItem?.type, + type: smsItem?.status, + }; + } else if (day.day() === 0) { + smsIconProp = { ...smsIconProp, status: "Holiday" }; + } else if (isToday) { + smsIconProp = { ...smsIconProp, status: "Today" }; + } else if (moment().diff(day, "days") > 0) { + smsIconProp = { ...smsIconProp, status: "Unmarked" }; } - borderBottomColor={"coolGray.300"} - p={"2"} - {...(_weekBox?.[index] ? _weekBox[index] : {})} - > - {week.map((day, subIndex) => { - let isToday = moment().format("Y-MM-DD") === day.format("Y-MM-DD"); - let dateValue = day.format("Y-MM-DD"); - let smsItem = sms - .slice() - .reverse() - .find((e) => e.date === dateValue); - let smsIconProp = !isIconSizeSmall - ? { - _box: { py: 2, minW: "46px", alignItems: "center" }, - status: "CheckboxBlankCircleLineIcon", - } - : {}; - if (smsItem?.type && smsItem?.type === "Present") { - smsIconProp = { - ...smsIconProp, - status: smsItem?.type, - type: smsItem?.status, - }; - } else if (smsItem?.type && smsItem?.type === "Absent") { - smsIconProp = { - ...smsIconProp, - status: smsItem?.type, - type: smsItem?.status, - }; - } else if (day.day() === 0) { - smsIconProp = { ...smsIconProp, status: "Holiday" }; - } else if (isToday) { - smsIconProp = { ...smsIconProp, status: "Today" }; - } else if (moment().diff(day, "days") > 0) { - smsIconProp = { ...smsIconProp, status: "Unmarked" }; - } - - return ( - + 1 && index ? 0 : !isIconSizeSmall ? 2 : 0 } + textAlign="center" > - 1 && index ? 0 : !isIconSizeSmall ? 2 : 0 - } - textAlign="center" - > - {!isIconSizeSmall ? ( - - {index === 0 ? ( - - {day.format("ddd")} - - ) : ( - "" - )} - - {day.format("DD")} + {!isIconSizeSmall ? ( + + {index === 0 ? ( + + {day.format("ddd")} - - ) : ( - - {day.format("dd")} - {day.format("D")} - - )} - - setSmsObject(smsItem)} - // onLongPress={(e) => { - // console.log({ e }); - // }} - > - - {loding && loding[dateValue + student.id] ? ( - ) : ( - + "" )} - - - - ); - })} - - )); - } else { - return sms.map((item, index) => ( - setSmsObject(item)}> - - - )); - } - }; - - + + {day.format("DD")} + + + ) : ( + + {day.format("dd")} + {day.format("D")} + + )} + + setSmsObject(smsItem)} + // onLongPress={(e) => { + // console.log({ e }); + // }} + > + + {loding && loding[dateValue + student.id] ? ( + + ) : ( + + )} + + + + ); + })} + + )); + } else { + return sms.map((item, index) => ( + setSmsObject(item)}> + + + )); + } +}; -export default CalendarComponent \ No newline at end of file +export default CalendarComponent; diff --git a/packages/attendance/src/pages/sms/MessageHistory/Molecule/Message.js b/packages/attendance/src/pages/sms/MessageHistory/Molecule/Message.js index 8b92c847..c04390a2 100644 --- a/packages/attendance/src/pages/sms/MessageHistory/Molecule/Message.js +++ b/packages/attendance/src/pages/sms/MessageHistory/Molecule/Message.js @@ -1,50 +1,45 @@ -import React from 'react' +import React from "react"; import moment from "moment"; -import { - Box, - HStack, - Text, - VStack, -} from "native-base"; +import { Box, HStack, Text, VStack } from "native-base"; import { useTranslation } from "react-i18next"; import { IconByName } from "@shiksha/common-lib"; -import ButtonHOC from 'atoms/ButtonHOC'; +import ButtonHOC from "atoms/ButtonHOC"; const Message = ({ item, isDisableRetry }) => { - const { t } = useTranslation(); - return ( - - - - - - - {item.status === "Send" ? t("SENT") : t("FAILED")} - - - {item.status !== "Send" && !isDisableRetry ? ( - - {t("RETRY")} - - ) : ( - "" - )} + const { t } = useTranslation(); + return ( + + + + + + + {item.status === "Send" ? t("SENT") : t("FAILED")} + - - {moment(item.date).format("Do MMM, hh:ssa")} - - - {item.message} - - - - ); - }; + {item.status !== "Send" && !isDisableRetry ? ( + + {t("RETRY")} + + ) : ( + "" + )} + + + {moment(item.date).format("Do MMM, hh:ssa")} + + + {item.message} + + + + ); +}; -export default Message \ No newline at end of file +export default Message; diff --git a/packages/attendance/src/pages/sms/MessageHistory/assets.js b/packages/attendance/src/pages/sms/MessageHistory/assets.js index 1d193800..c2eff798 100644 --- a/packages/attendance/src/pages/sms/MessageHistory/assets.js +++ b/packages/attendance/src/pages/sms/MessageHistory/assets.js @@ -1,6 +1,5 @@ import moment from "moment"; - export const sms = (student) => { return [ { @@ -47,5 +46,5 @@ export const sms = (student) => { student.firstName + " is present in school on Wednesday, 12th of January 2022.", }, - ] -} \ No newline at end of file + ]; +}; diff --git a/packages/attendance/src/pages/sms/MessageHistory/index.js b/packages/attendance/src/pages/sms/MessageHistory/index.js index bdebd156..e85c7aa6 100644 --- a/packages/attendance/src/pages/sms/MessageHistory/index.js +++ b/packages/attendance/src/pages/sms/MessageHistory/index.js @@ -225,6 +225,3 @@ export default function MessageHistory({ footerLinks }) { ); } - - - diff --git a/packages/attendance/src/services/routes/index.js b/packages/attendance/src/services/routes/index.js index f788b4c4..e971091d 100644 --- a/packages/attendance/src/services/routes/index.js +++ b/packages/attendance/src/services/routes/index.js @@ -1,10 +1,9 @@ export const navigationRoute = { - attendance: "attendance", - report: "attendance/report", - attendanceReport: "attendance/report/:classId/:view", - reportCompare: "attendance/reportCompare/:classId", - sendSms: "students/sendSms/:studentId", - sendSmsStudentId: "attendance/sendSms/:studentId", - fourOfour: "*", - }; - \ No newline at end of file + attendance: "attendance", + report: "attendance/report", + attendanceReport: "attendance/report/:classId/:view", + reportCompare: "attendance/reportCompare/:classId", + sendSms: "students/sendSms/:studentId", + sendSmsStudentId: "attendance/sendSms/:studentId", + fourOfour: "*", +}; diff --git a/packages/classes/src/atoms/ButtonHOC.js b/packages/classes/src/atoms/ButtonHOC.js index f5c7bf33..83cfe121 100644 --- a/packages/classes/src/atoms/ButtonHOC.js +++ b/packages/classes/src/atoms/ButtonHOC.js @@ -1,9 +1,8 @@ -import React from 'react' +import React from "react"; import { Button } from "native-base"; -const ButtonHOC = ({children, ...rest}) => { +const ButtonHOC = ({ children, ...rest }) => { + return ; +}; - return -} - -export default ButtonHOC \ No newline at end of file +export default ButtonHOC; diff --git a/packages/classes/src/atoms/LinkHOC.js b/packages/classes/src/atoms/LinkHOC.js index 332b7a06..04be8816 100644 --- a/packages/classes/src/atoms/LinkHOC.js +++ b/packages/classes/src/atoms/LinkHOC.js @@ -1,9 +1,8 @@ -import React from 'react' +import React from "react"; import { Link, useParams } from "react-router-dom"; -const LinkHOC = ({children, ...rest}) => { - - return {children} -} +const LinkHOC = ({ children, ...rest }) => { + return {children}; +}; -export default LinkHOC \ No newline at end of file +export default LinkHOC; diff --git a/packages/classes/src/pages/ClassDetails/Molecules/ClassAttendanceCard.js b/packages/classes/src/pages/ClassDetails/Molecules/ClassAttendanceCard.js index 9215522a..593d89f8 100644 --- a/packages/classes/src/pages/ClassDetails/Molecules/ClassAttendanceCard.js +++ b/packages/classes/src/pages/ClassDetails/Molecules/ClassAttendanceCard.js @@ -1,87 +1,80 @@ import React from "react"; import { Collapsible, IconByName } from "@shiksha/common-lib"; - import { - HStack, - Text, - VStack, - Stack, - Box, - Progress, - } from "native-base"; +import { HStack, Text, VStack, Stack, Box, Progress } from "native-base"; import { useTranslation } from "react-i18next"; import LinkHOC from "atoms/LinkHOC"; -const ClassAttendanceCard = ({ classId }) => { - const { t } = useTranslation(); - - return ( - - - - - - {t("STATUS")} - - - - 17 {t("PRESENT")} - - - {/* {t("GRADE") + ": " + t("GOOD")} */} - {t("TOTAL") + ": 24 " + t("STUDENTS")} - - - - - { + const { t } = useTranslation(); + + return ( + + + + + + {t("STATUS")} + + + - {t("ATTENDANCE_REGISTER")} - - - + 17 {t("PRESENT")} + + + {/* {t("GRADE") + ": " + t("GOOD")} */} + {t("TOTAL") + ": 24 " + t("STUDENTS")} + + + + - - - + {t("ATTENDANCE_REGISTER")} - - - - - - - - - ); - } - -export default ClassAttendanceCard; \ No newline at end of file + + + + + + + + + + + + + + + + ); +}; + +export default ClassAttendanceCard; diff --git a/packages/classes/src/pages/ClassDetails/Molecules/ClassDetailsPanel.js b/packages/classes/src/pages/ClassDetails/Molecules/ClassDetailsPanel.js index 06a26626..8bc8f14b 100644 --- a/packages/classes/src/pages/ClassDetails/Molecules/ClassDetailsPanel.js +++ b/packages/classes/src/pages/ClassDetails/Molecules/ClassDetailsPanel.js @@ -1,104 +1,93 @@ import React from "react"; -import { - Collapsible, - IconByName, - } from "@shiksha/common-lib"; - import { - HStack, - Text, - VStack, - Box, - Progress, - } from "native-base"; +import { Collapsible, IconByName } from "@shiksha/common-lib"; +import { HStack, Text, VStack, Box, Progress } from "native-base"; import { useTranslation } from "react-i18next"; - const ClassDetailsPanel = ({ students }) => { - const { t } = useTranslation(); - const fullName = localStorage.getItem("fullName"); - - return ( - - - - - - - {t("CLASS_TEACHER")} - - - {fullName} - - students - - - - - {t("CLASS_STRENGTH")} - - - - - - - {t("GIRLS")}: - - {students.filter((e) => e.gender === "Female").length} - - - - - {t("BOYS")}: - - {students.filter((e) => e.gender === "Male").length} - - + const { t } = useTranslation(); + const fullName = localStorage.getItem("fullName"); + + return ( + + + + + + + {t("CLASS_TEACHER")} + + + {fullName} + + students + + + + + {t("CLASS_STRENGTH")} + + + + + + + {t("GIRLS")}: + + {students.filter((e) => e.gender === "Female").length} + + + + + {t("BOYS")}: - {t("TOTAL")}: - {students.length} {t("STUDENTS")} + {students.filter((e) => e.gender === "Male").length} - - e.gender === "Male").length} - max={students.length} - size={"20"} - colorScheme="purple" - bg="info.400" - /> - - - - - - - - - - - {t("DETAILS")} - - - - {t("MATHS")}: - {fullName} - - - {t("ENGLISH")}: - {fullName} - - - {t("SCIENCE")}: - {fullName} - - - - - - - + + + {t("TOTAL")}: + {students.length} {t("STUDENTS")} + + + e.gender === "Male").length} + max={students.length} + size={"20"} + colorScheme="purple" + bg="info.400" + /> + + + + - ); - } - + + + + + + {t("DETAILS")} + + + + {t("MATHS")}: + {fullName} + + + {t("ENGLISH")}: + {fullName} + + + {t("SCIENCE")}: + {fullName} + + + + + + + + + ); +}; - export default ClassDetailsPanel; \ No newline at end of file +export default ClassDetailsPanel; diff --git a/packages/classes/src/pages/ClassDetails/Molecules/ClassStudentsPanel.js b/packages/classes/src/pages/ClassDetails/Molecules/ClassStudentsPanel.js index 45e9f4e9..359240ce 100644 --- a/packages/classes/src/pages/ClassDetails/Molecules/ClassStudentsPanel.js +++ b/packages/classes/src/pages/ClassDetails/Molecules/ClassStudentsPanel.js @@ -6,46 +6,46 @@ import ButtonHOC from "atoms/ButtonHOC"; import LinkHOC from "atoms/LinkHOC"; const ClassStudentsPanel = ({ classObject, students }) => { - const { t } = useTranslation(); - const Card = React.lazy(() => import("students/Card")); - - return ( - - - - ( - - - - - - )} - keyExtractor={(item) => item.id} - /> - - - - {t("SHOW_ALL_STUDENTS")} - - - - - ); - } - - export default ClassStudentsPanel; \ No newline at end of file + const { t } = useTranslation(); + const Card = React.lazy(() => import("students/Card")); + + return ( + + + + ( + + + + + + )} + keyExtractor={(item) => item.id} + /> + + + + {t("SHOW_ALL_STUDENTS")} + + + + + ); +}; + +export default ClassStudentsPanel; diff --git a/packages/classes/src/pages/ClassDetails/Molecules/ClassSubjectsPanel.js b/packages/classes/src/pages/ClassDetails/Molecules/ClassSubjectsPanel.js index a4f67af3..2e725fe6 100644 --- a/packages/classes/src/pages/ClassDetails/Molecules/ClassSubjectsPanel.js +++ b/packages/classes/src/pages/ClassDetails/Molecules/ClassSubjectsPanel.js @@ -1,22 +1,20 @@ import React from "react"; import { Collapsible, Tab } from "@shiksha/common-lib"; -import {VStack , Box } from "native-base"; - import { useTranslation } from "react-i18next"; +import { VStack, Box } from "native-base"; +import { useTranslation } from "react-i18next"; import { routes } from "../assets"; -const ClassSubjectsPanel = () => { - const { t } = useTranslation(); - return ( - - - - - - - - ); - } - - export default ClassSubjectsPanel; \ No newline at end of file +const ClassSubjectsPanel = () => { + const { t } = useTranslation(); + return ( + + + + + + + + ); +}; + +export default ClassSubjectsPanel; diff --git a/packages/classes/src/pages/ClassDetails/assets.js b/packages/classes/src/pages/ClassDetails/assets.js index 53a00409..e1ab1aca 100644 --- a/packages/classes/src/pages/ClassDetails/assets.js +++ b/packages/classes/src/pages/ClassDetails/assets.js @@ -1,116 +1,107 @@ import { useTranslation } from "react-i18next"; import { Collapsible } from "@shiksha/common-lib"; - import { - Stack, - Box, - Center, - Text, - VStack, - } from "native-base"; - +import { Stack, Box, Center, Text, VStack } from "native-base"; export const routes = () => { - const { t } = useTranslation(); - return ( - [ - { - title: t("SCIENCE"), - component: ( - - - - - - - - - - - - - - - - - - ), - }, - { - title: t("MATHS"), - component: ( -
- This is Tab {t("MATHS")} -
- ), - }, - { - title: t("ENGLISH"), - component: ( -
- This is Tab {t("ENGLISH")} -
- ), - }, - { - title: t("HISTORY"), - component: ( -
- This is Tab {t("HISTORY")} -
- ), - }, - { - title: t("GEOGRAPHY"), - component: ( -
- This is Tab {t("GEOGRAPHY")} -
- ), - }, - ] - ) -} + const { t } = useTranslation(); + return [ + { + title: t("SCIENCE"), + component: ( + + + + + + + + + + + + + + + + + + ), + }, + { + title: t("MATHS"), + component: ( +
+ This is Tab {t("MATHS")} +
+ ), + }, + { + title: t("ENGLISH"), + component: ( +
+ This is Tab {t("ENGLISH")} +
+ ), + }, + { + title: t("HISTORY"), + component: ( +
+ This is Tab {t("HISTORY")} +
+ ), + }, + { + title: t("GEOGRAPHY"), + component: ( +
+ This is Tab {t("GEOGRAPHY")} +
+ ), + }, + ]; +}; export const _header = (name) => { - const { t } = useTranslation(); - return { - title: t("MY_CLASSES"), - fullRightComponent: ( - - - - - {name} - + const { t } = useTranslation(); + return { + title: t("MY_CLASSES"), + fullRightComponent: ( + + + + + {name} + - - {t("CLASS_DETAILS")} - - - - - ) - } -} \ No newline at end of file + + {t("CLASS_DETAILS")} + + + + + ), + }; +}; diff --git a/packages/classes/src/pages/ClassDetails/index.js b/packages/classes/src/pages/ClassDetails/index.js index 13e47f36..735961da 100644 --- a/packages/classes/src/pages/ClassDetails/index.js +++ b/packages/classes/src/pages/ClassDetails/index.js @@ -6,69 +6,67 @@ import { useParams } from "react-router-dom"; import * as classServiceRegistry from "../../services/classServiceRegistry"; import * as studentServiceRegistry from "../../services/studentServiceRegistry"; import manifest from "../../manifest.json"; -import ClassStudentsPanel from './Molecules/ClassStudentsPanel'; -import ClassSubjectsPanel from './Molecules/ClassSubjectsPanel' -import ClassAttendanceCard from './Molecules/ClassAttendanceCard'; +import ClassStudentsPanel from "./Molecules/ClassStudentsPanel"; +import ClassSubjectsPanel from "./Molecules/ClassSubjectsPanel"; +import ClassAttendanceCard from "./Molecules/ClassAttendanceCard"; import ClassDetailsPanel from "./Molecules/ClassDetailsPanel"; import { _header } from "./assets"; - const ClassDetails = ({ footerLinks }) => { - const { t } = useTranslation(); - const [students, setStudents] = useState([]); - const [classObject, setClassObject] = useState({}); - const { classId } = useParams(); - - useEffect(() => { - let ignore = false; - const getData = async () => { - setStudents(await studentServiceRegistry.getAll({ classId })); - - let classObj = await classServiceRegistry.getOne({ id: classId }); - if (!ignore) setClassObject(classObj); - }; - getData(); - }, [classId]); - - return ( - - } - _subHeader={{ - bottom: "15px", - bg: "classCard.500", - }} - _footer={footerLinks} - > - - - - - - - - ); - } - +const ClassDetails = ({ footerLinks }) => { + const { t } = useTranslation(); + const [students, setStudents] = useState([]); + const [classObject, setClassObject] = useState({}); + const { classId } = useParams(); - - export default ClassDetails; \ No newline at end of file + useEffect(() => { + let ignore = false; + const getData = async () => { + setStudents(await studentServiceRegistry.getAll({ classId })); + + let classObj = await classServiceRegistry.getOne({ id: classId }); + if (!ignore) setClassObject(classObj); + }; + getData(); + }, [classId]); + + return ( + + } + _subHeader={{ + bottom: "15px", + bg: "classCard.500", + }} + _footer={footerLinks} + > + + + + + + + + ); +}; + +export default ClassDetails; diff --git a/packages/classes/src/pages/MyClassRoute/Molecules/ChooseClassActionSheet.js b/packages/classes/src/pages/MyClassRoute/Molecules/ChooseClassActionSheet.js index abf5cc33..bf285e6e 100644 --- a/packages/classes/src/pages/MyClassRoute/Molecules/ChooseClassActionSheet.js +++ b/packages/classes/src/pages/MyClassRoute/Molecules/ChooseClassActionSheet.js @@ -1,41 +1,36 @@ import React from "react"; -import { - Box, - useDisclose, - Actionsheet, - Link, -} from "native-base"; +import { Box, useDisclose, Actionsheet, Link } from "native-base"; import { useTranslation } from "react-i18next"; const ChooseClassActionSheet = () => { - const { t } = useTranslation(); - - const { isOpen, onOpen, onClose } = useDisclose(); - return ( - <> - - - {t("CHOOSE_ANOTHER_CLASS")} - - - - - - Option 1 - Option 2 - Option 3 - - - - ); - }; + const { t } = useTranslation(); - export default ChooseClassActionSheet; \ No newline at end of file + const { isOpen, onOpen, onClose } = useDisclose(); + return ( + <> + + + {t("CHOOSE_ANOTHER_CLASS")} + + + + + + Option 1 + Option 2 + Option 3 + + + + ); +}; + +export default ChooseClassActionSheet; diff --git a/packages/classes/src/pages/MyClassRoute/index.js b/packages/classes/src/pages/MyClassRoute/index.js index d87067e8..bab4d986 100644 --- a/packages/classes/src/pages/MyClassRoute/index.js +++ b/packages/classes/src/pages/MyClassRoute/index.js @@ -1,9 +1,5 @@ import React, { useEffect, useState } from "react"; -import { - Box, - HStack, - VStack, -} from "native-base"; +import { Box, HStack, VStack } from "native-base"; import { useTranslation } from "react-i18next"; import { generatePath } from "react-router-dom"; import { Widget } from "@shiksha/common-lib"; @@ -81,6 +77,4 @@ const MyClassRoute = () => { ); }; - - export default MyClassRoute; diff --git a/packages/classes/src/services/routes/index.js b/packages/classes/src/services/routes/index.js index cb80ee58..282c3897 100644 --- a/packages/classes/src/services/routes/index.js +++ b/packages/classes/src/services/routes/index.js @@ -1,4 +1,4 @@ export const navigationRoutes = { - myClasses:'my-classes/:classId', - fourOfour:'*' -} \ No newline at end of file + myClasses: "my-classes/:classId", + fourOfour: "*", +}; diff --git a/packages/common-lib/src/services/i18n.ts b/packages/common-lib/src/services/i18n.ts index 9b54e503..093aeb64 100644 --- a/packages/common-lib/src/services/i18n.ts +++ b/packages/common-lib/src/services/i18n.ts @@ -21,9 +21,11 @@ const languageDetector: any = { } } -const initializeI18n = (namespaces: string[]) => { - // console.log(namespaces) - +const initializeI18n = ( + namespaces: string[], + basePath = '/locales/{{lng}}/{{ns}}.json' +) => { + // console.log(`${process.env.PUBLIC_URL}/locales/{{lng}}/{{ns}}.json`) i18n // load translation using http -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales) // learn more: https://github.com/i18next/i18next-http-backend @@ -42,7 +44,7 @@ const initializeI18n = (namespaces: string[]) => { ns: namespaces, fallbackNS: 'translation', backend: { - loadPath: '/locales/{{lng}}/{{ns}}.json' // http://module-base-url/locales/ + loadPath: basePath // http://module-base-url/locales/ }, interpolation: { escapeValue: false // not needed for react as it escapes by default diff --git a/packages/core/src/App.js b/packages/core/src/App.js index 6a5ea9d0..70dd1795 100644 --- a/packages/core/src/App.js +++ b/packages/core/src/App.js @@ -15,7 +15,7 @@ const theme = extendTheme(DEFAULT_THEME); function App() { return ( - + } /> diff --git a/packages/student/public/locales/en/student.json b/packages/student/public/locales/en/student.json new file mode 100644 index 00000000..253fae2b --- /dev/null +++ b/packages/student/public/locales/en/student.json @@ -0,0 +1,32 @@ +{ + "STUDENTS_DETAIL": "Student details", + "VIEW_ALL_STUDENTS": "View all students", + "STUDENTS_LIST": "Students List", + "TOTAL": "Total", + "SEE_ALL_STUDENTS": "See All Students", + "ABOUT": "About", + "ACADEMIC": "Academic", + "CLASS": "Class", + "ATTENDANCE": "Attendance", + "FULL_CLASS_ATTENDANCE": "Attendance Register", + "MESSAGE_HISTORY": "Message history", + "LEARNING": "Learning", + "EDIT": "Edit", + "RESULTS": "Results", + "COMPETENCY": "Competency", + "AWARDS": "Awards", + "NOTES_FEEDBACK_ON_STUDENT": "Notes and Feedback", + "NOTES": "Notes", + "NOT_ENTERED": "not entered", + "PHONE_NUMBER": "Phone Number", + "FIRST_NAME": "First name", + "LAST_NAME": "Last name", + "EMAIL": "Email", + "ADDRESS": "Address", + "FATHERS_NAME": "Father's Name", + "DETAILS": "Details", + "SAVE": "Save", + "ROLL_NUMBER": "Roll No", + "STUDENT_IS_GOOD_NEED": "Student is... good at... has issues... has special needs", + "SEE_MORE": "See more" +} diff --git a/packages/student/public/locales/hi/student.json b/packages/student/public/locales/hi/student.json new file mode 100644 index 00000000..ceb43e77 --- /dev/null +++ b/packages/student/public/locales/hi/student.json @@ -0,0 +1,33 @@ +{ + "STUDENTS_DETAIL": "विद्यार्थी का विवरण", + "VIEW_ALL_STUDENTS": "सभी छात्र देखें", + "STUDENTS_LIST": "विद्यार्थियों की सूची", + "TOTAL": "कुल", + "SEE_ALL_STUDENTS": "सभी छात्र देखें", + "ABOUT": "जानकारी", + "ACADEMIC": "शैक्षिक विवरण", + "CLASS": "कक्षा", + "ATTENDANCE": "उपस्थिति", + "FULL_CLASS_ATTENDANCE": "कक्षा की उपस्थिति", + "MESSAGE_HISTORY": "पिछले संदेश", + "LEARNING": "अधिगम का विवरण", + "EDIT": "संपादित करें", + "RESULTS": "परिणाम", + "COMPETENCY": "योग्यता", + "AWARDS": "पुरस्कार", + "NOTES_FEEDBACK_ON_STUDENT": "विद्यार्थी पर नोट्स एवं प्रतिक्रिया", + "NOTES": "नोट्स", + "NOT_ENTERED": "प्रवेश नहीं", + "PHONE_NUMBER": "फ़ोन नंबर", + "FIRST_NAME": "पहला नाम", + "LAST_NAME": "अंतिम नाम", + "EMAIL": "ईमेल", + "ADDRESS": "पता", + "FATHERS_NAME": "पिता का नाम", + "GENDER": "लिंग", + "DETAILS": "विवरण", + "SAVE": "जमा करें", + "ROLL_NUMBER": "रोल नं", + "STUDENT_IS_GOOD_NEED": "विद्यार्थी है... अच्छा है... समस्याएँ हैं... विशेष आवश्यकताएँ हैं", + "SEE_MORE": "और देखें" +} diff --git a/packages/student/src/App.js b/packages/student/src/App.js index fd1285ac..feb34506 100644 --- a/packages/student/src/App.js +++ b/packages/student/src/App.js @@ -1,12 +1,16 @@ import React from "react"; import "./App.css"; import { extendTheme } from "native-base"; -import { DEFAULT_THEME, AppShell } from "@shiksha/common-lib"; +import { DEFAULT_THEME, initializeI18n, AppShell } from "@shiksha/common-lib"; import StudentDetails from "./pages/students/StudentDetails"; import Student from "./pages/students/Student"; function App() { const theme = extendTheme(DEFAULT_THEME); + initializeI18n( + ["student"], + `${process.env.PUBLIC_URL}/locales/{{lng}}/{{ns}}.json` + ); const routes = [ { path: "class/students/:classId", diff --git a/packages/student/src/components/students/Card.js b/packages/student/src/components/students/Card.js index 1bf536e9..022373b7 100644 --- a/packages/student/src/components/students/Card.js +++ b/packages/student/src/components/students/Card.js @@ -31,7 +31,7 @@ const SubCard = ({ _textTitle, _textSubTitle, }) => { - const { t } = useTranslation(); + const { t } = useTranslation("student"); return type === "veritical" ? ( {typeof img === "undefined" || img === true ? ( @@ -176,7 +176,7 @@ export default function Card({ _textSubTitle, _arrow, }) { - const { t } = useTranslation(); + const { t } = useTranslation("student"); const [open, setOpen] = useState(false); const [studentObject, setStudentObject] = useState(item); diff --git a/packages/student/src/components/students/StudentEdit.js b/packages/student/src/components/students/StudentEdit.js index c4f842b1..e7cad4d1 100644 --- a/packages/student/src/components/students/StudentEdit.js +++ b/packages/student/src/components/students/StudentEdit.js @@ -20,7 +20,7 @@ export default function StudentEdit({ setStudentObject, onlyParameterProp, }) { - const { t } = useTranslation(); + const { t } = useTranslation("student"); const [editState, setEditState] = useState(false); const [editChangeState, setEditChangeState] = useState(false); const [errors, setErrors] = React.useState({}); diff --git a/packages/student/src/pages/students/Student.js b/packages/student/src/pages/students/Student.js index 6eaea68e..1b3a708c 100644 --- a/packages/student/src/pages/students/Student.js +++ b/packages/student/src/pages/students/Student.js @@ -20,7 +20,7 @@ import manifest from "../../manifest.json"; // Start editing here, save and see your changes. export default function Student({ footerLinks }) { - const { t } = useTranslation(); + const { t } = useTranslation("student"); const [students, setStudents] = useState([]); const [classObject, setClassObject] = useState({}); const { classId } = useParams(); diff --git a/packages/student/src/pages/students/StudentDetails.js b/packages/student/src/pages/students/StudentDetails.js index f12757e2..4f83d6b8 100644 --- a/packages/student/src/pages/students/StudentDetails.js +++ b/packages/student/src/pages/students/StudentDetails.js @@ -12,7 +12,7 @@ import manifest from "../../manifest.json"; // Start editing here, save and see your changes. export default function StudentDetails({ footerLinks }) { - const { t } = useTranslation(); + const { t } = useTranslation("student"); const [studentObject, setStudentObject] = useState({}); const [classObject, setClassObject] = useState({}); const { studentId } = useParams(); @@ -233,7 +233,7 @@ export default function StudentDetails({ footerLinks }) { } const InfoSection = ({ items, isLastBorderEnable }) => { - const { t } = useTranslation(); + const { t } = useTranslation("student"); return items.map((item, index) => (