Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled Scrolling for Organization Bounties page #1391

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading