Skip to content

Commit

Permalink
made changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav-Gaikwad-1 committed Jan 17, 2024
1 parent 3bc15f7 commit fbafe75
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
52 changes: 45 additions & 7 deletions frontend/app/src/pages/tickets/TicketModalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ export const TicketModalPage = observer(({ setConnectPerson }: Props) => {
const [activeBounty, setActiveBounty] = useState<PersonBounty[]>([]);
const [visible, setVisible] = useState(false);
const [isDeleted, setisDeleted] = useState(false);
const [isOrgBounties, setIsOrgBounties] = useState(false);
const [orgBounties, setOrgBounties] = useState<any>({});

const { state } = location;

type OrgTicketModalState = {
uuid?: string;
};

const uuid = (state as OrgTicketModalState)?.uuid || '';

useEffect(() => {
(async () => {
if (uuid) {
const res = await main.getOrganizationBounties(uuid, { page: 1, resetPage: true });
setOrgBounties(res);
setIsOrgBounties(true);
}
console.log(orgBounties, 'as');
})();
}, [main, uuid]);

const isMobile = useIsMobile();

Expand Down Expand Up @@ -89,22 +110,39 @@ export const TicketModalPage = observer(({ setConnectPerson }: Props) => {

const getBountyIndex = () => {
const id = parseInt(bountyId, 10);
const index = main.peopleBounties.findIndex((bounty: any) => id === bounty.body.id);
let index;
if (isOrgBounties) {
index = orgBounties.findIndex((bounty: any) => id === bounty.body.id);
} else {
index = main.peopleBounties.findIndex((bounty: any) => id === bounty.body.id);
}
return index;
};

const prevArrHandler = () => {
const index = getBountyIndex();
if (index <= 0 || index >= main.peopleBounties.length) return;
const { person, body } = main.peopleBounties[index - 1];
directionHandler(person, body);
if (isOrgBounties) {
if (index <= 0 || index >= orgBounties.length) return;
const { person, body } = orgBounties[index - 1];
directionHandler(person, body);
} else {
if (index <= 0 || index >= main.peopleBounties.length) return;
const { person, body } = main.peopleBounties[index - 1];
directionHandler(person, body);
}
};

const nextArrHandler = () => {
const index = getBountyIndex();
if (index + 1 >= main.peopleBounties?.length) return;
const { person, body } = main.peopleBounties[index + 1];
directionHandler(person, body);
if (isOrgBounties) {
if (index + 1 >= orgBounties?.length) return;
const { person, body } = orgBounties[index + 1];
directionHandler(person, body);
} else {
if (index + 1 >= main.peopleBounties?.length) return;
const { person, body } = main.peopleBounties[index + 1];
directionHandler(person, body);
}
};

if (isMobile) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/pages/tickets/org/OrgTickets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function OrgBodyComponent() {
};

const onPanelClick = (person: any, item: any) => {
history.push(`/bounty/${item.id}`);
history.push(`/bounty/${item.id}`, { uuid });
};

if (loading) {
Expand Down

0 comments on commit fbafe75

Please sign in to comment.