Skip to content

Commit

Permalink
Merge pull request #1640 from Ansanjohny/dev
Browse files Browse the repository at this point in the history
feat: Add category in ig dashboard
  • Loading branch information
nashnsulthan authored Oct 7, 2024
2 parents ced8ca6 + c808608 commit acc41d8
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
18 changes: 8 additions & 10 deletions src/modules/Dashboard/modules/InterestGroup/InterestGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@ import THead from "@/MuLearnComponents/Table/THead";
import TableTop from "@/MuLearnComponents/TableTop/TableTop";
import { deleteInterestGroups, getInterestGroups } from "./apis";
import { useNavigate } from "react-router-dom";
import {
MuButton,
PowerfulButton
} from "@/MuLearnComponents/MuButtons/MuButton";
import { PowerfulButton } from "@/MuLearnComponents/MuButtons/MuButton";
import { AiOutlinePlusCircle } from "react-icons/ai";
import styles from "./InterestGroup.module.css";
import { dashboardRoutes } from "@/MuLearnServices/urls";
import { Blank } from "@/MuLearnComponents/Table/Blank";
import CreateOrUpdateModal from "./CreateOrUpdateModal";
import MuModal from "@/MuLearnComponents/MuModal/MuModal";
import InterestGroupForm from "./InterestGroupForm";
import { Label } from "recharts";

interface IgDetails {
igName: string;
igCode: string;
igIcon: string;
}
// interface IgDetails {
// igName: string;
// igCode: string;
// igIcon: string;
// }

export type modalTypes = "edit" | "create" | null;

Expand All @@ -38,6 +35,7 @@ function InterestGroup() {
const columnOrder = [
{ column: "name", Label: "Name", isSortable: true },
{ column: "members", Label: "Members", isSortable: true },
{ column: "category", Label: "Category", isSortable: true },
{ column: "updated_at", Label: "Updated On", isSortable: true },
{ column: "updated_by", Label: "Updated By", isSortable: true },
{ column: "created_by", Label: "Created By", isSortable: true },
Expand Down
36 changes: 33 additions & 3 deletions src/modules/Dashboard/modules/InterestGroup/InterestGroupForm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
import styles from "../../utils/modalForm.module.css";
import toast from "react-hot-toast";
import { customReactSelectStyles } from "../../utils/common";
import { createInterestGroups, editInterestGroups, getIGDetails } from "./apis";
import ReactSelect from "react-select";
import styles2 from "./InterestGroupFrom.module.css";

type Props = { id: string; isEditMode: boolean };

Expand All @@ -11,8 +12,19 @@ const IntrestGroupForm = forwardRef(
const [data, setData] = useState<IGData>({
name: "",
icon: "",
code: ""
code: "",
category: "others"
});
const interestGroup = [
{ label: "Software", value: "software" },
{ label: "Maker", value: "maker" },
{
label: "Management",
value: "management"
},
{ label: "Creative", value: "creative" },
{ label: "Others", value: "others" }
];

const [errors, setErrors] = useState<OrgFormErrors>({});

Expand All @@ -23,7 +35,8 @@ const IntrestGroupForm = forwardRef(
setData({
name: data.name,
icon: data.icon,
code: data.code
code: data.code,
category: data.category
});
});
}
Expand Down Expand Up @@ -142,6 +155,23 @@ const IntrestGroupForm = forwardRef(
<div style={{ color: "red" }}>{errors.icon}</div>
)}
</div>
<ReactSelect
required={true}
className={styles2.inputBox}
options={interestGroup}
onChange={e => {
setData(prevData => ({
...prevData,
category: e?.value as string
}));
}}
value={
interestGroup.filter(e => {
console.log(e.value, data.category);
return e.value === data.category;
})[0]
}
/>
</form>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.inputBox {
width: 45%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ interface IGData {
name: string;
code: string;
icon: string;
category: string;
}

0 comments on commit acc41d8

Please sign in to comment.