Skip to content

Commit

Permalink
fixed can't edit error
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Nov 10, 2023
1 parent a4bb587 commit 86443cc
Showing 1 changed file with 68 additions and 55 deletions.
123 changes: 68 additions & 55 deletions frontend/app/src/pages/tickets/TicketModalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useIsMobile } from 'hooks';
import { observer } from 'mobx-react-lite';
import FocusedView from 'people/main/FocusView';
import { widgetConfigs } from 'people/utils/Constants';
import React, { useEffect, useState, useMemo, useCallback } from 'react';
import React, { useEffect, useState, useMemo, useCallback, useRef } from 'react';
import { useHistory, useLocation, useParams } from 'react-router-dom';
import { useStores } from 'store';
import { PersonBounty } from 'store/main';
Expand All @@ -30,6 +30,8 @@ export const TicketModalPage = observer(({ setConnectPerson }: Props) => {
const [activeBounty, setActiveBounty] = useState<PersonBounty[]>([]);
const [visible, setVisible] = useState(false);

const isVisible = useRef(false);

const isMobile = useIsMobile();

const search = useMemo(() => {
Expand All @@ -50,24 +52,26 @@ export const TicketModalPage = observer(({ setConnectPerson }: Props) => {
}

const activeIndex = bounty && bounty.length ? bounty[0].body.id : 0;
const connectPerson = (main.peopleBounties ?? [])[activeIndex];
const connectPerson = bounty && bounty.length ? bounty[0].person : [];

setPublicFocusIndex(activeIndex);
setActiveListIndex(activeIndex);
setConnectPersonBody(connectPerson?.person);
setConnectPersonBody(connectPerson);

const visible = bounty && bounty.length > 0;
isVisible.current = visible;

setActiveBounty(bounty);
setVisible(visible);
}, [bountyId, search, main.peopleBountiesj]);
}, [bountyId, search, main.peopleBounties, visible]);

useEffect(() => {
getBounty();
}, [getBounty]);

const goBack = async () => {
setVisible(false);
isVisible.current = false;
await main.getPeopleBounties({ page: 1, resetPage: true });
history.push('/bounties');
};
Expand Down Expand Up @@ -112,60 +116,69 @@ export const TicketModalPage = observer(({ setConnectPerson }: Props) => {

if (isMobile) {
return (
<Modal visible={visible} fill={true}>
<FocusedView
person={connectPersonBody}
personBody={connectPersonBody}
canEdit={false}
selectedIndex={publicFocusIndex}
config={widgetConfigs.wanted}
goBack={goBack}
/>
</Modal>
<>
{visible && (
<Modal visible={visible} fill={true}>
<FocusedView
person={connectPersonBody}
personBody={connectPersonBody}
canEdit={false}
selectedIndex={publicFocusIndex}
config={widgetConfigs.wanted}
bounty={activeBounty}
goBack={goBack}
/>
</Modal>
)}
</>
);
}

return (
<Modal
visible={visible}
envStyle={{
background: color.pureWhite,
...focusedDesktopModalStyles,
maxHeight: '100vh',
zIndex: 20
}}
style={{
background: 'rgba( 0 0 0 /75% )'
}}
overlayClick={goBack}
bigCloseImage={goBack}
bigCloseImageStyle={{
top: '18px',
right: '-50px',
borderRadius: '50%'
}}
prevArrowNew={removeNextAndPrev ? undefined : prevArrHandler}
nextArrowNew={removeNextAndPrev ? undefined : nextArrHandler}
>
<FocusedView
setRemoveNextAndPrev={setRemoveNextAndPrev}
person={connectPersonBody}
personBody={connectPersonBody}
canEdit={false}
selectedIndex={publicFocusIndex}
config={widgetConfigs.wanted}
goBack={goBack}
bounty={activeBounty}
fromBountyPage={true}
extraModalFunction={() => {
goBack();
if (ui.meInfo) {
setConnectPerson(connectPersonBody);
} else {
modals.setStartupModal(true);
}
}}
/>
</Modal>
<>
{visible && (
<Modal
visible={visible}
envStyle={{
background: color.pureWhite,
...focusedDesktopModalStyles,
maxHeight: '100vh',
zIndex: 20
}}
style={{
background: 'rgba( 0 0 0 /75% )'
}}
overlayClick={goBack}
bigCloseImage={goBack}
bigCloseImageStyle={{
top: '18px',
right: '-50px',
borderRadius: '50%'
}}
prevArrowNew={removeNextAndPrev ? undefined : prevArrHandler}
nextArrowNew={removeNextAndPrev ? undefined : nextArrHandler}
>
<FocusedView
setRemoveNextAndPrev={setRemoveNextAndPrev}
person={connectPersonBody}
personBody={connectPersonBody}
canEdit={false}
selectedIndex={publicFocusIndex}
config={widgetConfigs.wanted}
goBack={goBack}
bounty={activeBounty}
fromBountyPage={true}
extraModalFunction={() => {
goBack();
if (ui.meInfo) {
setConnectPerson(connectPersonBody);
} else {
modals.setStartupModal(true);
}
}}
/>
</Modal>
)}
</>
);
});

0 comments on commit 86443cc

Please sign in to comment.