Added a "Linked Corporate" column to the Groups list
This commit is contained in:
@@ -13,10 +13,25 @@ import Select from "react-select";
|
|||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
import readXlsxFile from "read-excel-file";
|
import readXlsxFile from "read-excel-file";
|
||||||
import {useFilePicker} from "use-file-picker";
|
import {useFilePicker} from "use-file-picker";
|
||||||
|
import {getUserCorporate} from "@/utils/groups";
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<Group>();
|
const columnHelper = createColumnHelper<Group>();
|
||||||
const EMAIL_REGEX = new RegExp(/^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*@[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*$/);
|
const EMAIL_REGEX = new RegExp(/^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*@[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*$/);
|
||||||
|
|
||||||
|
const LinkedCorporate = ({userId}: {userId: string}) => {
|
||||||
|
const [companyName, setCompanyName] = useState("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsLoading(true);
|
||||||
|
getUserCorporate(userId)
|
||||||
|
.then((result) => setCompanyName(result?.corporateInformation?.companyInformation?.name || ""))
|
||||||
|
.finally(() => setIsLoading(false));
|
||||||
|
}, [userId]);
|
||||||
|
|
||||||
|
return isLoading ? <span className="animate-pulse">Loading...</span> : <>{companyName}</>;
|
||||||
|
};
|
||||||
|
|
||||||
interface CreateDialogProps {
|
interface CreateDialogProps {
|
||||||
user: User;
|
user: User;
|
||||||
users: User[];
|
users: User[];
|
||||||
@@ -209,6 +224,10 @@ export default function GroupList({user}: {user: User}) {
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
columnHelper.accessor("admin", {
|
||||||
|
header: "Linked Corporate",
|
||||||
|
cell: (info) => <LinkedCorporate userId={info.getValue()} />,
|
||||||
|
}),
|
||||||
columnHelper.accessor("participants", {
|
columnHelper.accessor("participants", {
|
||||||
header: "Participants",
|
header: "Participants",
|
||||||
cell: (info) =>
|
cell: (info) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user