Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 66x 10x 10x 10x 5x 5x 10x 3x 3x 10x | import React, { ReactElement, useEffect, useState } from "react"; import { Tag } from "antd"; import { capitalizeFirstLetter } from "@utils/StringUtils"; import { fetchCurrentValues } from "@utils/FetchUtils"; const RolesCell = (props: { value: string }): ReactElement => { const { value } = props; const [displayVals, setDisplayVals] = useState<Array<string>>([]); useEffect(() => { Iif (value != null && Array.isArray(value)) { if (value.length > 0) { fetchCurrentValues('roles', value).then(roles => { setDisplayVals(roles.map(role => role.authority)); }); } } else { setDisplayVals(value?.split(",")); } }, [value]); const tags = (value == null || value.length === 0) ? (<span />) : displayVals?.map((t: string) => { const val = capitalizeFirstLetter(t.replace("ROLE_", "").toLowerCase()); return ( <Tag className="role-tag" key={t}>{val}</Tag>); }); return (<span>{tags}</span>); }; export default RolesCell; |