Skip to content

Commit

Permalink
fix: resolve issues with assign hunter button and bounty list inconsi…
Browse files Browse the repository at this point in the history
…stencies
  • Loading branch information
aliraza556 committed Dec 20, 2024
1 parent e7fdb07 commit d6c4dc4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
19 changes: 8 additions & 11 deletions src/people/utils/AssignedUnassignedBounties.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useState } from 'react';
import React, { useMemo, useState } from 'react';
import styled from 'styled-components';
import { observer } from 'mobx-react-lite';
import { BountiesProps } from 'people/interfaces';
Expand Down Expand Up @@ -137,22 +137,19 @@ const Bounties = (props: BountiesProps) => {
const [openConnectModal, setConnectModal] = useState<boolean>(false);
const closeConnectModal = () => setConnectModal(false);
const showConnectModal = () => setConnectModal(true);
const [canAssignHunter, setCanAssignHunter] = useState(false);

const { ui, main } = useStores();
const userPubkey = ui.meInfo?.owner_pubkey;

const checkUserRoles = useCallback(async () => {
const canAssignHunter = await userCanManageBounty(org_uuid, userPubkey, main);
const bountyOwner = ui.meInfo?.owner_pubkey === person.owner_pubkey;
const canAssignHunter = useMemo(() => {
if (!org_uuid || !userPubkey) return false;

const canAssign = canAssignHunter || bountyOwner;
setCanAssignHunter(canAssign);
}, [main, org_uuid, userPubkey]);
const isBountyOwner = ui.meInfo?.owner_pubkey === person.owner_pubkey;

useEffect(() => {
checkUserRoles();
}, [checkUserRoles]);
const canManage = userCanManageBounty(org_uuid, userPubkey, main);

return isBountyOwner || canManage;
}, [org_uuid, userPubkey, person.owner_pubkey, main]);

return (
<>
Expand Down
21 changes: 13 additions & 8 deletions src/people/widgetViews/workspace/WorkspacePhase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => {
setIsPostBountyModalOpen(true);
};

const onPanelClick = () => {
history.push(`/feature/${props.workspace_uuid}`);
const onPanelClick = (activeWorkspace?: string, bounty?: any) => {
if (bounty?.id) {
history.push(`/bounty/${bounty.id}`);
} else {
history.push(`/feature/${props.workspace_uuid}`);
}
};

const handlePhasePlannerClick = () => {
Expand Down Expand Up @@ -260,12 +264,10 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => {
);

useEffect(() => {
getTotalBounties(checkboxIdToSelectedMap);
}, [getTotalBounties, checkboxIdToSelectedMap]);

useEffect(() => {
if (page === 1 && phases[selectedIndex]) {
if (phases[selectedIndex]) {
(async () => {
setLoading(true);

await main.getPhaseBounties(
phases[selectedIndex].feature_uuid,
phases[selectedIndex].uuid,
Expand All @@ -276,10 +278,13 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => {
languages: languageString
}
);

await getTotalBounties(checkboxIdToSelectedMap);

setLoading(false);
})();
}
}, [languageString, phases, selectedIndex, main, page, checkboxIdToSelectedMap]);
}, [phases, selectedIndex, main, checkboxIdToSelectedMap, languageString, getTotalBounties]);

useEffect(() => {
const checkUserPermissions = async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ export class MainStore {
sortBy: 'created',
search: uiStore.searchText ?? '',
page: 1,
resetPage: false,
resetPage: true,
...params
};

Expand All @@ -752,7 +752,7 @@ export class MainStore {
const query2 = this.appendQueryParams(
`features/${feature_uuid}/phase/${phase_uuid}/bounty`,
queryLimit,
params ? queryParams : this.getWantedsPrevParams
queryParams
);

try {
Expand Down

0 comments on commit d6c4dc4

Please sign in to comment.