Skip to content

Commit

Permalink
Merge pull request #776 from AI4Bharat/dev2-s
Browse files Browse the repository at this point in the history
Dev2 s
  • Loading branch information
aparna-aa authored Aug 2, 2024
2 parents 40b98a3 + 0575006 commit 9202da1
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 63 deletions.
16 changes: 11 additions & 5 deletions src/common/CreateTaskDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const CreateTaskDialog = ({
(state) => state.getSupportedLanguages.voiceoverLanguage
);
const bulkTaskTypes = useSelector((state) => state.getBulkTaskTypes.data);

const[langLabel,setlabel] =useState("")
const [taskType, setTaskType] = useState("");
const [description, setDescription] = useState("");
const [user, setUser] = useState("");
Expand All @@ -72,7 +72,6 @@ const CreateTaskDialog = ({
const [allowedTaskType, setAllowedTaskType] = useState("");
const [showAllowedTaskList, setShowAllowedTaskList] = useState(false);
const [showLimitWarning, setShowLimitWarning] = useState(false);

useEffect(() => {
const taskObj = new FetchTaskTypeAPI();
dispatch(APITransport(taskObj));
Expand Down Expand Up @@ -147,8 +146,13 @@ const CreateTaskDialog = ({
const {
target: { value },
} = event;

const selectedLanguage = translationLanguage.find(
(lang) => lang.value === event.target.value
) || voiceoverLanguage.find(
(lang) => lang.value === event.target.value
);
setLanguage(value);
setlabel(selectedLanguage.label)

if (isBulk) {
const obj = new FetchProjectMembersAPI(projectId, taskType, "", value);
Expand Down Expand Up @@ -367,12 +371,14 @@ const CreateTaskDialog = ({
inputProps={{ "aria-label": "Without label" }}
disabled={isAssignUserDropdownDisabled()}
>
{projectMembers.map((item, index) => (
{projectMembers
.filter((member) => member.languages.includes(langLabel))
.map((item, index) => (
<MenuItem key={index} value={item}>
{`${item.first_name} ${item.last_name} (${item.email})`}
</MenuItem>
))}
</Select>
</Select>
</FormControl>
</Box>

Expand Down
24 changes: 17 additions & 7 deletions src/containers/Organization/MyOrganization.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const MyOrganization = () => {
const [orgOwnerId, setOrgOwnerId] = useState("");
const [openUploadBulkVideoDialog, setOpenUploadBulkVideoDialog] =
useState(false);
const [isUserOrgOwner, setIsUserOrgOwner] = useState(false);

const organizationDetails = useSelector(
(state) => state.getOrganizationDetails.data
Expand Down Expand Up @@ -135,10 +136,19 @@ const MyOrganization = () => {

if (userData && userData.id) {
const {
organization: { organization_owner },
organization: { organization_owners },
} = userData;

setOrgOwnerId(organization_owner.id);

if (organization_owners && organization_owners?.length > 0) {
const ownerIds = organization_owners.map(owner => owner.id);
setOrgOwnerId(ownerIds);

if (ownerIds.includes(userData.id)) {
setIsUserOrgOwner(true);
} else {
setIsUserOrgOwner(false);
}
}
}
// eslint-disable-next-line
}, [userData]);
Expand Down Expand Up @@ -195,11 +205,11 @@ const MyOrganization = () => {
<Tab label={"Members"} sx={{ fontSize: 16, fontWeight: "700" }} />
)}

{userData?.id === orgOwnerId && (
{isUserOrgOwner&& (
<Tab label={"Reports"} sx={{ fontSize: 16, fontWeight: "700" }} />
)}

{userData?.id === orgOwnerId && (
{isUserOrgOwner && (
<Tab
label={"Settings"}
sx={{ fontSize: 16, fontWeight: "700" }}
Expand All @@ -220,7 +230,7 @@ const MyOrganization = () => {
alignItems="center"
>
<Box display={"flex"} width={"100%"}>
{userData?.id === orgOwnerId && (
{isUserOrgOwner && (
<Fragment>
<Button
style={{ marginRight: "10px" }}
Expand Down Expand Up @@ -292,7 +302,7 @@ const MyOrganization = () => {
justifyContent="center"
alignItems="center"
>
{userData?.id === orgOwnerId && (
{isUserOrgOwner && (
<Button
className={classes.projectButton}
onClick={() => setAddUserDialog(true)}
Expand Down
40 changes: 25 additions & 15 deletions src/containers/Organization/Project/EditProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,24 @@ const EditProject = () => {
const [taskDescription, setTaskDescription] = useState("");
const [integrateVideo, setIntegrateVideo] = useState(false);
const [orgOwnerId, setOrgOwnerId] = useState("");
const [isUserOrgOwner, setIsUserOrgOwner] = useState(false);

useEffect(() => {
if (userData && userData.id) {
const {
organization: { organization_owner },
organization: { organization_owners },
} = userData;

setOrgOwnerId(organization_owner.id);

if (organization_owners && organization_owners.length > 0) {
const ownerIds = organization_owners.map(owner => owner.id);
setOrgOwnerId(ownerIds);

if (ownerIds.includes(userData.id)) {
setIsUserOrgOwner(true);
} else {
setIsUserOrgOwner(false);
}
}
}
}, [userData]);

Expand Down Expand Up @@ -327,7 +337,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
/>
Expand All @@ -348,7 +358,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
renderValue={(selected) => {
Expand Down Expand Up @@ -396,7 +406,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
>
Expand Down Expand Up @@ -427,7 +437,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) ||isUserOrgOwner
)
}
>
Expand Down Expand Up @@ -458,7 +468,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
>
Expand Down Expand Up @@ -502,7 +512,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
MenuProps={MenuProps}
Expand Down Expand Up @@ -589,7 +599,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) ||isUserOrgOwner
)
}
renderInput={(params) => <TextField {...params} />}
Expand All @@ -614,7 +624,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
renderValue={(selected) => {
Expand All @@ -639,7 +649,7 @@ const EditProject = () => {
{(projectDetails?.managers?.some(
(item) => item.id === userData.id
) ||
userData?.id === orgOwnerId) && (
isUserOrgOwner) && (
<Grid item xs={12} sm={12} md={6} lg={6} xl={6}>
<Button
fullWidth
Expand Down Expand Up @@ -680,7 +690,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
/>
Expand All @@ -703,7 +713,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
/>
Expand All @@ -724,7 +734,7 @@ const EditProject = () => {
!(
projectDetails?.managers?.some(
(item) => item.id === userData.id
) || userData?.id === orgOwnerId
) || isUserOrgOwner
)
}
/>
Expand Down
18 changes: 14 additions & 4 deletions src/containers/Organization/Project/Project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,24 @@ const Project = () => {
const userData = useSelector((state) => state.getLoggedInUserDetails.data);
const userList = useSelector((state) => state.getOrganizatioUsers.data);
const apiStatus = useSelector((state) => state.apiStatus);
const [isUserOrgOwner, setIsUserOrgOwner] = useState(false);

useEffect(() => {
if (userData && userData.id) {
const {
organization: { organization_owner },
organization: { organization_owners },
} = userData;

setOrgOwnerId(organization_owner.id);

if (organization_owners && organization_owners.length > 0) {
const ownerIds = organization_owners.map(owner => owner.id);
setOrgOwnerId(ownerIds);

if (ownerIds.includes(userData.id)) {
setIsUserOrgOwner(true);
} else {
setIsUserOrgOwner(false);
}
}
}
}, [userData]);

Expand Down Expand Up @@ -462,7 +472,7 @@ const Project = () => {
alignItems="center"
>
{(projectInfo?.managers?.some((item) => item.id === userData.id) ||
userData?.id === orgOwnerId) && (
isUserOrgOwner) && (
<Button
className={classes.projectButton}
onClick={() => setAddUserDialog(true)}
Expand Down
18 changes: 14 additions & 4 deletions src/containers/Organization/Project/ProjectMemberDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,24 @@ const ProjectMemberDetails = () => {
const apiStatus = useSelector((state) => state.apiStatus);
const userData = useSelector((state) => state.getLoggedInUserDetails.data);
const projectDetails = useSelector((state) => state.getProjectDetails.data);
const [isUserOrgOwner, setIsUserOrgOwner] = useState(false);

useEffect(() => {
if (userData && userData.id) {
const {
organization: { organization_owner },
organization: { organization_owners },
} = userData;

setOrgOwnerId(organization_owner.id);

if (organization_owners && organization_owners.length > 0) {
const ownerIds = organization_owners.map(owner => owner.id);
setOrgOwnerId(ownerIds);

if (ownerIds.includes(userData.id)) {
setIsUserOrgOwner(true);
} else {
setIsUserOrgOwner(false);
}
}
}
}, [userData]);

Expand Down Expand Up @@ -115,7 +125,7 @@ const ProjectMemberDetails = () => {
{(projectDetails?.managers?.some(
(item) => item.id === userData.id
) ||
userData?.id === orgOwnerId) && (
isUserOrgOwner) && (
<Tooltip title="Delete">
<IconButton
onClick={() => {
Expand Down
18 changes: 14 additions & 4 deletions src/containers/Organization/Project/VideoList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,24 @@ const VideoList = ({ data, removeVideo }) => {
const translationExportTypes = useSelector(
(state) => state.getTranslationExportTypes.data.export_types
);
const [isUserOrgOwner, setIsUserOrgOwner] = useState(false);

useEffect(() => {
if (userData && userData.id) {
const {
organization: { organization_owner },
organization: { organization_owners },
} = userData;

if (organization_owners && organization_owners?.length > 0) {
const ownerIds = organization_owners.map(owner => owner.id);
setOrgOwnerId(ownerIds);

setOrgOwnerId(organization_owner.id);
if (ownerIds.includes(userData.id)) {
setIsUserOrgOwner(true);
} else {
setIsUserOrgOwner(false);
}
}
}
}, [userData]);

Expand Down Expand Up @@ -181,7 +191,7 @@ const VideoList = ({ data, removeVideo }) => {
</Tooltip>

{(projectInfo?.managers?.some((item) => item.id === userData.id) ||
userData?.id === orgOwnerId) && (
isUserOrgOwner) && (
<Tooltip title="Create Task">
<IconButton
onClick={() => {
Expand All @@ -196,7 +206,7 @@ const VideoList = ({ data, removeVideo }) => {
)}

{(projectInfo.managers?.some((item) => item.id === userData.id) ||
userData?.id === orgOwnerId) && (
isUserOrgOwner) && (
<Tooltip title="Delete">
<IconButton onClick={() => handleDeleteVideo(item.id)}>
<DeleteIcon color="error" />
Expand Down
Loading

0 comments on commit 9202da1

Please sign in to comment.