-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Feat/issue 4612 #4626
Feat/issue 4612 #4626
Changes from all commits
5447b2d
b71d951
ed9b57f
e8ef914
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import React from 'react'; | ||
import { | ||
brandColors, | ||
Button, | ||
IconAlertTriangleFilled32, | ||
Lead, | ||
neutralColors, | ||
} from '@giveth/ui-design-system'; | ||
import styled from 'styled-components'; | ||
import { useIntl } from 'react-intl'; | ||
import { useRouter } from 'next/router'; | ||
import { Modal } from '@/components/modals/Modal'; | ||
import Routes from '@/lib/constants/Routes'; | ||
import { mediaQueries } from '@/lib/constants/constants'; | ||
import { useModalAnimation } from '@/hooks/useModalAnimation'; | ||
|
||
// Define the props interface | ||
interface DonationByProjectOwnerProps { | ||
setShowDonationByProjectOwner: ( | ||
showDonationByProjectOwner: boolean, | ||
) => void; | ||
} | ||
|
||
export const DonationByProjectOwner: React.FC<DonationByProjectOwnerProps> = ({ | ||
setShowDonationByProjectOwner, | ||
}) => { | ||
const { formatMessage } = useIntl(); | ||
const router = useRouter(); | ||
const { closeModal } = useModalAnimation(setShowDonationByProjectOwner); | ||
|
||
const navigateToAllProjects = () => { | ||
router.push(Routes.AllProjects); | ||
closeModal(); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
closeModal={closeModal} | ||
isAnimating={false} | ||
headerTitle={formatMessage({ | ||
id: 'label.project_owner_address_detected', | ||
})} | ||
headerTitlePosition='left' | ||
hiddenClose={true} | ||
headerIcon={<IconAlertTriangleFilled32 size={32} />} | ||
doNotCloseOnClickOutside | ||
> | ||
<ModalContainer> | ||
<ModalBox> | ||
<Lead> | ||
{formatMessage({ | ||
id: 'label.project_owner_cant_donate_to_own_project', | ||
})} | ||
</Lead> | ||
</ModalBox> | ||
<Buttons> | ||
<ModalButton | ||
buttonType='primary' | ||
disabled={false} | ||
label={formatMessage({ | ||
id: 'label.view_all_projects', | ||
})} | ||
onClick={navigateToAllProjects} // Navigate to the All Projects route | ||
/> | ||
</Buttons> | ||
</ModalContainer> | ||
</Modal> | ||
); | ||
}; | ||
|
||
const ModalContainer = styled.div` | ||
background: white; | ||
color: black; | ||
padding: 24px 24px 38px; | ||
margin: 0; | ||
width: 100%; | ||
|
||
${mediaQueries.tablet} { | ||
width: 494px; | ||
} | ||
`; | ||
|
||
const ModalBox = styled.div` | ||
color: ${brandColors.deep[900]}; | ||
|
||
> :first-child { | ||
margin-bottom: 8px; | ||
} | ||
|
||
h3 { | ||
margin-top: -5px; | ||
} | ||
|
||
h6 { | ||
color: ${neutralColors.gray[700]}; | ||
margin-top: -5px; | ||
} | ||
|
||
> :last-child { | ||
margin: 12px 0 32px 0; | ||
|
||
> span { | ||
font-weight: 500; | ||
} | ||
} | ||
`; | ||
|
||
const ModalButton = styled(Button)` | ||
background: ${props => | ||
props.disabled ? brandColors.giv[200] : brandColors.giv[500]}; | ||
|
||
&:hover:enabled { | ||
background: ${brandColors.giv[700]}; | ||
} | ||
|
||
:disabled { | ||
cursor: not-allowed; | ||
} | ||
|
||
> :first-child > div { | ||
border-top: 3px solid ${brandColors.giv[200]}; | ||
animation-timing-function: linear; | ||
} | ||
|
||
text-transform: uppercase; | ||
`; | ||
|
||
const Buttons = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
|
||
> :first-child { | ||
margin: 15px 0; | ||
} | ||
`; | ||
|
||
export default DonationByProjectOwner; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||||||||||||||
import React, { FC, useEffect } from 'react'; | ||||||||||||||||||||||
import React, { FC, useEffect, useState } from 'react'; | ||||||||||||||||||||||
import styled from 'styled-components'; | ||||||||||||||||||||||
import { | ||||||||||||||||||||||
Col, | ||||||||||||||||||||||
|
@@ -45,6 +45,7 @@ import { useQRCodeDonation } from '@/hooks/useQRCodeDonation'; | |||||||||||||||||||||
import EndaomentProjectsInfo from '@/components/views/project/EndaomentProjectsInfo'; | ||||||||||||||||||||||
import { IDraftDonation } from '@/apollo/types/gqlTypes'; | ||||||||||||||||||||||
import StorageLabel from '@/lib/localStorage'; | ||||||||||||||||||||||
import DonationByProjectOwner from '@/components/modals/DonationByProjectOwner'; | ||||||||||||||||||||||
|
||||||||||||||||||||||
const DonateIndex: FC = () => { | ||||||||||||||||||||||
const { formatMessage } = useIntl(); | ||||||||||||||||||||||
|
@@ -66,12 +67,14 @@ const DonateIndex: FC = () => { | |||||||||||||||||||||
const { isSignedIn, isEnabled } = useAppSelector(state => state.user); | ||||||||||||||||||||||
|
||||||||||||||||||||||
const alreadyDonated = useAlreadyDonatedToProject(project); | ||||||||||||||||||||||
const { userData } = useAppSelector(state => state.user); | ||||||||||||||||||||||
const [showDonationByProjectOwner, setShowDonationByProjectOwner] = | ||||||||||||||||||||||
useState<boolean | undefined>(false); | ||||||||||||||||||||||
const dispatch = useAppDispatch(); | ||||||||||||||||||||||
Comment on lines
+70
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify state initialization. The Apply this diff to simplify the state initialization: - const [showDonationByProjectOwner, setShowDonationByProjectOwner] =
- useState<boolean | undefined>(false);
+ const [showDonationByProjectOwner, setShowDonationByProjectOwner] = useState(false); Committable suggestion
Suggested change
|
||||||||||||||||||||||
const isSafeEnv = useIsSafeEnvironment(); | ||||||||||||||||||||||
const { isOnSolana } = useGeneralWallet(); | ||||||||||||||||||||||
const router = useRouter(); | ||||||||||||||||||||||
const { chainId } = useAccount(); | ||||||||||||||||||||||
|
||||||||||||||||||||||
const [showQRCode, setShowQRCode] = React.useState( | ||||||||||||||||||||||
!!router.query.draft_donation, | ||||||||||||||||||||||
); | ||||||||||||||||||||||
|
@@ -84,6 +87,12 @@ const DonateIndex: FC = () => { | |||||||||||||||||||||
}; | ||||||||||||||||||||||
}, [dispatch]); | ||||||||||||||||||||||
|
||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||
setShowDonationByProjectOwner( | ||||||||||||||||||||||
userData?.id !== undefined && userData?.id === project.adminUser.id, | ||||||||||||||||||||||
); | ||||||||||||||||||||||
}, [userData?.id, project.adminUser]); | ||||||||||||||||||||||
|
||||||||||||||||||||||
Comment on lines
+90
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimize the The Apply this diff to optimize the useEffect(() => {
setShowDonationByProjectOwner(
- userData?.id !== undefined && userData?.id === project.adminUser.id,
+ userData?.id === project.adminUser.id,
);
}, [userData?.id, project.adminUser]); Committable suggestion
Suggested change
|
||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||
const fetchDonation = async () => { | ||||||||||||||||||||||
if (qrDonationStatus === 'success') { | ||||||||||||||||||||||
|
@@ -212,6 +221,13 @@ const DonateIndex: FC = () => { | |||||||||||||||||||||
<> | ||||||||||||||||||||||
<DonateHeader /> | ||||||||||||||||||||||
<DonateContainer> | ||||||||||||||||||||||
{showDonationByProjectOwner && ( | ||||||||||||||||||||||
<DonationByProjectOwner | ||||||||||||||||||||||
setShowDonationByProjectOwner={ | ||||||||||||||||||||||
setShowDonationByProjectOwner | ||||||||||||||||||||||
} | ||||||||||||||||||||||
/> | ||||||||||||||||||||||
)} | ||||||||||||||||||||||
{alreadyDonated && ( | ||||||||||||||||||||||
<AlreadyDonatedWrapper> | ||||||||||||||||||||||
<IconDonation24 /> | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making the
isAnimating
prop dynamic.The
isAnimating
prop is hardcoded tofalse
. Consider making it dynamic to reflect the actual animation state.Apply this diff to make the
isAnimating
prop dynamic: