@campxdev/campx-web-utils 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/export.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './src/config/axios';
2
2
  export * from './src/context/export';
3
3
  export * from './src/hooks/export';
4
+ export * from './src/layout/AppLayout';
5
+ export * from './src/selectors/export';
4
6
  export * from './src/utils/export';
5
- export * from './src/Layout/AppLayout';
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@campxdev/campx-web-utils",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
7
- "@campxdev/react-blueprint": "^1.2.3",
7
+ "@campxdev/react-blueprint": "1.3.3",
8
8
  "@hookform/resolvers": "^3.9.0",
9
9
  "@mui/x-date-pickers": "7.16.0",
10
10
  "@testing-library/jest-dom": "^5.14.1",
@@ -15,10 +15,10 @@
15
15
  "@types/react": "^18.0.0",
16
16
  "@types/react-dom": "^18.0.0",
17
17
  "axios": "^1.7.2",
18
- "framer-motion": "^11.3.21",
19
18
  "cookie-js": "^0.0.1",
20
19
  "date-fns": "^3.6.0",
21
20
  "device-detector-js": "^3.0.3",
21
+ "framer-motion": "^11.3.21",
22
22
  "pullstate": "^1.25.0",
23
23
  "react": "^18.3.1",
24
24
  "react-dom": "^18.3.1",
@@ -26,7 +26,7 @@
26
26
  "react-query": "^3.39.3",
27
27
  "react-scripts": "5.0.1",
28
28
  "react-toastify": "^9.0.1",
29
- "typescript": "^4.4.2",
29
+ "typescript": "^5.5.2",
30
30
  "uuid": "^10.0.0",
31
31
  "web-vitals": "^2.1.0",
32
32
  "yup": "^1.4.0"
package/src/App.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useRoutes } from 'react-router-dom';
2
2
 
3
- import { mainRoutes } from './Pages/main';
4
3
  import { Providers } from './context/export';
4
+ import { mainRoutes } from './routes/main';
5
5
 
6
6
  export default function App() {
7
7
  return (
@@ -1,26 +1,26 @@
1
- import { Button } from '@campxdev/react-blueprint';
2
- import useConfirm from './hooks/useConfirm';
1
+ import { Button, TextField } from '@campxdev/react-blueprint';
2
+ import { useState } from 'react';
3
+ import { EmployeesSelector } from './selectors/EmployeesSelector';
3
4
 
4
5
  function AppContent() {
5
- const isConfirm = useConfirm();
6
+ const [value, setValue] = useState('63b810ee995d6d64f4a248de');
7
+ return (
8
+ <>
9
+ <Button variant="contained" onClick={() => {}}>
10
+ Confirm
11
+ </Button>
12
+ <EmployeesSelector
13
+ fullWidth
14
+ value={value}
15
+ onChange={(value: any) => {
16
+ setValue(value);
17
+ }}
18
+ />
19
+ <div style={{ height: '300px' }}></div>
6
20
 
7
- const handleConfirm = async () => {
8
- const confirm = await isConfirm({
9
- type: 'delete',
10
- title: 'Are you sure?',
11
- message: 'Please confirm before submission to action description',
12
- });
13
-
14
- // If user cancel the action
15
- if (!confirm) {
16
- console.log('User cancelled the action');
17
- return;
18
- }
19
- // If user confirm the action
20
- console.log('User confirmed the action');
21
- };
22
-
23
- return <Button onClick={handleConfirm}>Confirm</Button>;
21
+ <TextField />
22
+ </>
23
+ );
24
24
  }
25
25
 
26
26
  export default AppContent;
@@ -0,0 +1,33 @@
1
+ import { Icons } from '@campxdev/react-blueprint';
2
+ import { Navigate, Outlet } from 'react-router-dom';
3
+ import AppContent from '../AppContent';
4
+ import { AppLayout } from '../layout/AppLayout';
5
+
6
+ export const mainRoutes = [
7
+ {
8
+ path: '/',
9
+ element: (
10
+ <AppLayout
11
+ menu={[
12
+ {
13
+ name: 'App Content',
14
+ path: '/app-content',
15
+ icon: <Icons.AdminIcon size={20} />,
16
+ },
17
+ ]}
18
+ >
19
+ <Outlet />
20
+ </AppLayout>
21
+ ),
22
+ children: [
23
+ {
24
+ index: true,
25
+ element: <Navigate to={'app-content'} />,
26
+ },
27
+ {
28
+ path: 'app-content',
29
+ element: <AppContent />,
30
+ },
31
+ ],
32
+ },
33
+ ];
@@ -0,0 +1,14 @@
1
+ import { SingleSelect, SingleSelectProps } from '@campxdev/react-blueprint';
2
+
3
+ export const CourseSelector = (props: SingleSelectProps) => {
4
+ return (
5
+ <SingleSelect
6
+ dbLabelProps={{
7
+ labelKey: 'courseName',
8
+ subLabelKey: 'level',
9
+ }}
10
+ {...props}
11
+ optionsApiEndPoint="/dropdowns/courses"
12
+ />
13
+ );
14
+ };
@@ -0,0 +1,18 @@
1
+ import { SingleSelect, SingleSelectProps } from '@campxdev/react-blueprint';
2
+
3
+ export const EmployeesSelector = (props: SingleSelectProps) => {
4
+ return (
5
+ <SingleSelect
6
+ dbValueProps={{
7
+ valueKey: '_id',
8
+ isObjectId: true,
9
+ }}
10
+ dbLabelProps={{
11
+ labelKey: 'fullName',
12
+ subLabelKey: 'employeeId',
13
+ }}
14
+ {...props}
15
+ optionsApiEndPoint="/dropdowns/employees"
16
+ />
17
+ );
18
+ };
@@ -0,0 +1,15 @@
1
+ import { SingleSelect, SingleSelectProps } from '@campxdev/react-blueprint';
2
+ import { FeeTypes } from './utils';
3
+
4
+ export const FeeTypeSelector = (props: SingleSelectProps) => {
5
+ return (
6
+ <SingleSelect
7
+ label="Fee Type"
8
+ options={FeeTypes?.map((item: { label: string; value: string }) => ({
9
+ label: item.label,
10
+ value: item.value,
11
+ }))}
12
+ {...props}
13
+ />
14
+ );
15
+ };
@@ -0,0 +1,18 @@
1
+ import { SingleSelect, SingleSelectProps } from '@campxdev/react-blueprint';
2
+ import { years } from './utils';
3
+
4
+ export const HostelFloorSelector = (props: SingleSelectProps) => {
5
+ return (
6
+ <SingleSelect
7
+ label="Hostel Room No."
8
+ dbValueProps={{
9
+ valueKey: 'floor',
10
+ }}
11
+ dbLabelProps={{
12
+ labelKey: 'floor',
13
+ }}
14
+ optionsApiEndPoint="dropdowns/floors"
15
+ {...props}
16
+ />
17
+ );
18
+ };
@@ -0,0 +1,19 @@
1
+ import { SingleSelect, SingleSelectProps } from '@campxdev/react-blueprint';
2
+ import { years } from './utils';
3
+
4
+ export const HostelRoomSelector = (props: SingleSelectProps) => {
5
+ return (
6
+ <SingleSelect
7
+ label="Hostel Room No."
8
+ dbValueProps={{
9
+ valueKey: 'id',
10
+ }}
11
+ dbLabelProps={{
12
+ labelKey: 'room_number',
13
+ subLabelKey: 'floor',
14
+ }}
15
+ optionsApiEndPoint="dropdowns/hostel-rooms"
16
+ {...props}
17
+ />
18
+ );
19
+ };
@@ -0,0 +1,14 @@
1
+ import { SingleSelect, SingleSelectProps } from '@campxdev/react-blueprint';
2
+
3
+ export const SemesterSelector = (props: SingleSelectProps) => {
4
+ return (
5
+ <SingleSelect
6
+ dbLabelProps={{
7
+ labelKey: 'name',
8
+ subLabelKey: 'year',
9
+ }}
10
+ {...props}
11
+ optionsApiEndPoint="/dropdowns/semesters"
12
+ />
13
+ );
14
+ };
@@ -0,0 +1,26 @@
1
+ import { SingleSelect, SingleSelectProps } from '@campxdev/react-blueprint';
2
+ import { years } from './utils';
3
+
4
+ interface YearRangeSelectorProps extends SingleSelectProps {
5
+ suffix?: string | null;
6
+ valueKey?: 'yearRange' | 'year';
7
+ }
8
+
9
+ export const YearRangeSelector = ({
10
+ suffix = null,
11
+ valueKey = 'yearRange',
12
+ ...props
13
+ }: YearRangeSelectorProps) => {
14
+ return (
15
+ <SingleSelect
16
+ label="Year Range"
17
+ options={years?.map((year: number) => ({
18
+ label: suffix
19
+ ? `${suffix} ${year} - ${year + 1}`
20
+ : `${year} - ${year + 1}`,
21
+ value: valueKey === 'yearRange' ? `${year} - ${year + 1}` : year,
22
+ }))}
23
+ {...props}
24
+ />
25
+ );
26
+ };
@@ -0,0 +1,7 @@
1
+ export * from './CourseSelector';
2
+ export * from './EmployeesSelector';
3
+ export * from './SemesterSelector';
4
+ export * from './FeeTypeSelector';
5
+ export * from './HostelFloorSelector';
6
+ export * from './HostelRoomSelector';
7
+ export * from './YearRangeSelector';
@@ -0,0 +1,34 @@
1
+ export const FeeTypes: {
2
+ label: string;
3
+ value: string;
4
+ }[] = [
5
+ {
6
+ label: 'Tuition Fee',
7
+ value: 'tuition_fee',
8
+ },
9
+
10
+ {
11
+ label: 'Admission Fee',
12
+ value: 'admission_fee',
13
+ },
14
+ {
15
+ label: 'Hostel Fee',
16
+ value: 'hostel_fee',
17
+ },
18
+ {
19
+ label: 'Transport Fee',
20
+ value: 'transport_fee',
21
+ },
22
+ {
23
+ label: 'Exam Fee',
24
+ value: 'exam_fee',
25
+ },
26
+ {
27
+ label: 'Other Fee',
28
+ value: 'other_fee',
29
+ },
30
+ ];
31
+
32
+ export const years = Array.from({ length: 6 }, (_, i) => {
33
+ return new Date().getFullYear() - i;
34
+ });
package/types/theme.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import "@mui/material/styles";
1
+ import '@mui/material/styles';
2
2
 
3
- declare module "@mui/material/styles" {
3
+ declare module '@mui/material/styles' {
4
4
  interface Theme {
5
5
  palette: {
6
6
  [x: string]: any;
@@ -21,6 +21,9 @@ declare module "@mui/material/styles" {
21
21
  primary: string;
22
22
  secondary: string;
23
23
  tertiary: string;
24
+ black: string;
25
+ white: string;
26
+ primaryContrast: string;
24
27
  };
25
28
  surface: {
26
29
  defaultBackground: string;
@@ -29,6 +32,7 @@ declare module "@mui/material/styles" {
29
32
  };
30
33
  border: {
31
34
  primary: string;
35
+ secondary: string;
32
36
  };
33
37
  highlight: {
34
38
  highlightGreen: string;
@@ -49,7 +53,7 @@ declare module "@mui/material/styles" {
49
53
  export function createTheme(options?: CustomThemeOptions): CustomTheme;
50
54
  }
51
55
 
52
- declare module "@mui/material/Typography" {
56
+ declare module '@mui/material/Typography' {
53
57
  interface TypographyPropsVariantOverrides {
54
58
  label1: true;
55
59
  label2: true;
package/.env DELETED
@@ -1,2 +0,0 @@
1
- REACT_APP_API_HOST=https://api.campx.dev
2
- PORT=3082
@@ -1,20 +0,0 @@
1
- import { Navigate } from 'react-router-dom';
2
- import AppContent from '../AppContent';
3
- import { AppLayout } from '../Layout/AppLayout';
4
-
5
- export const mainRoutes = [
6
- {
7
- path: '/',
8
- element: <AppLayout menu={[]} />,
9
- children: [
10
- {
11
- index: true,
12
- element: <Navigate to={'app-content'} />,
13
- },
14
- {
15
- path: 'app-content',
16
- element: <AppContent />,
17
- },
18
- ],
19
- },
20
- ];
File without changes