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

Zp06/feat/settings notification and invite friends #1478

Merged
merged 6 commits into from
Oct 22, 2023
Merged
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
40 changes: 25 additions & 15 deletions modules/portfolio/component/portfolioSettingsComponents/2fa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,30 @@ const Handling2FA = (props: close) => {
if (email) {
const resendResponse = await resend2FACode({ email });
console.log(resendResponse);
setToken(resendResponse?.response?.token);
setLoading(false);
setOpen2Fa(false);
setContinue2Fa(true);
notify({
message: 'code sent check your mail',
type: 'success',
});
setTimeout(() => {
if (inputRefs.length > 0) {
inputRefs[0]?.current?.focus();
}
}, 500);
setFill(false);
if (resendResponse?.statues === 200) {
setToken(resendResponse?.response?.token);
setLoading(false);
setOpen2Fa(false);
setContinue2Fa(true);

notify({
message: 'code sent check your mail',
type: 'success',
});
setTimeout(() => {
if (inputRefs.length > 0) {
inputRefs[0]?.current?.focus();
}
}, 500);
setFill(false);
} else {
setLoading(false);
setOpen2Fa(false);
notify({
message: `${resendResponse?.message}`,
type: 'error',
});
}
} else {
setLoading(false);
notify({
Expand Down Expand Up @@ -352,7 +362,7 @@ const Handling2FA = (props: close) => {
<div className="hidden md:block">
<Modal isOpen={open2Fa} closeModal={toggleModal} size={'sm'} isCloseIconPresent={false}>
<div className=" relative max-w-[440px] px-5 text-[14px] py-[40px]">
<button onClick={toggleModal} className="absolute right-0 top-0">
<button onClick={toggleModal} className="absolute right-0 top-3">
{' '}
<CloseCircle size="20" color="#009254" />
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import Social1 from '../../../../public/assets/inviteAssets/Social1.svg';
import Share from '../../../../public/assets/inviteAssets/share-01.svg';
import { useAuth } from '../../../../context/AuthContext';
import { ToastContainer, toast } from 'react-toastify';
import Profile from '../landing/avatars';

export default function InviteLink() {
const { auth } = useAuth();
const websiteURL = window.location.origin;
const profileUrl = `${websiteURL}/portfolio`;
const profileUrl = `${websiteURL}/portfolio/${auth?.user.slug}`;
const copyInvite = useRef<any>(null);
const handleCopyToClipboard = () => {
if (copyInvite.current) {
Expand All @@ -38,14 +37,16 @@ export default function InviteLink() {

const toggleModal = () => {
setOPenModal((prev: boolean) => !prev);
console.log(`${websiteURL}/portfolio/${auth?.user.id}`);
console.log(`${websiteURL}/portfolio/${auth?.user.slug}`);
};

return (
<div className={` space-y-4 font-manropeB container mx-auto `}>
<p className=" text-dark-110 font-manropeB text-sm md:text-[22px]">Invite your friends! </p>
<h3 className="font-manropeL text-[1rem] sm:text-[22px] text-[#2E3130] leading-[1.75rem]">
Invite your friends!
</h3>
<p className="text-white-650 leading-[20px] font-manropeL text-sm">
Share the website link to help us grow the community and get rewards.{' '}
Share your Profile link to help us grow the community and get rewards.{' '}
</p>
<div className="w-full flex ">
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
name="emailSummary"
id="emailSummary"
onChange={() => handleLabelClick('emailSummary')}
checked={checkboxState.emailSummary}
checked={checkboxState?.emailSummary}
className="appearance-none hidden"
/>
<label
Expand All @@ -65,11 +65,11 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
>
<div className="border-[1.6px] rounded-md relative flex items-center justify-center border-white-650">
<p
className={` flex justify-center relative ${checkboxState.emailSummary && 'block'} w-[16px]
className={` flex justify-center relative ${checkboxState?.emailSummary && 'block'} w-[16px]
h-[16px]`}
>
{' '}
{checkboxState.emailSummary && (
{checkboxState?.emailSummary && (
<MdCheck
className={`text-brand-green-primary
`}
Expand All @@ -86,7 +86,7 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
name="specialOffers"
id="specialOffers"
onChange={() => handleLabelClick('specialOffers')}
checked={checkboxState.specialOffers}
checked={checkboxState?.specialOffers}
className="appearance-none hidden"
/>
<label
Expand All @@ -96,11 +96,11 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
>
<div className="border-[1.6px] rounded-md relative flex items-center justify-center border-white-650">
<p
className={` flex justify-center relative ${checkboxState.specialOffers && 'block'} w-[16px]
className={` flex justify-center relative ${checkboxState?.specialOffers && 'block'} w-[16px]
h-[16px]`}
>
{' '}
{checkboxState.specialOffers && (
{checkboxState?.specialOffers && (
<MdCheck
className={`text-brand-green-primary
`}
Expand All @@ -117,7 +117,7 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
name="communityUpdate"
id="communityUpdate"
onChange={() => handleLabelClick('communityUpdate')}
checked={checkboxState.communityUpdate}
checked={checkboxState?.communityUpdate}
className="appearance-none hidden"
/>
<label
Expand All @@ -127,11 +127,11 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
>
<div className="border-[1.6px] rounded-md relative flex items-center justify-center border-white-650">
<p
className={` flex justify-center relative ${checkboxState.communityUpdate && 'block'} w-[16px]
className={` flex justify-center relative ${checkboxState?.communityUpdate && 'block'} w-[16px]
h-[16px]`}
>
{' '}
{checkboxState.communityUpdate && (
{checkboxState?.communityUpdate && (
<MdCheck
className={`text-brand-green-primary
`}
Expand All @@ -148,7 +148,7 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
name="followUpdate"
id="followUpdate"
onChange={() => handleLabelClick('followUpdate')}
checked={checkboxState.followUpdate}
checked={checkboxState?.followUpdate}
className="appearance-none hidden"
/>
<label
Expand All @@ -162,7 +162,7 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
h-[16px]`}
>
{' '}
{checkboxState.followUpdate && <MdCheck className={`text-brand-green-primary`} />}
{checkboxState?.followUpdate && <MdCheck className={`text-brand-green-primary`} />}
</p>
</div>
Notify when someone follows you
Expand All @@ -174,7 +174,7 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
name="newMessages"
id="newMessages"
onChange={() => handleLabelClick('newMessages')}
checked={checkboxState.newMessages}
checked={checkboxState?.newMessages}
className="appearance-none hidden"
/>
<label
Expand All @@ -184,11 +184,11 @@ const NotificationsSettings: React.FC<Props> = ({ checkboxState, setCheckboxStat
>
<div className="border-[1.6px] rounded-md relative flex items-center justify-center border-white-650">
<p
className={` flex justify-center relative ${checkboxState.newMessages && 'block'} w-[16px]
className={` flex justify-center relative ${checkboxState?.newMessages && 'block'} w-[16px]
h-[16px]`}
>
{' '}
{checkboxState.newMessages && (
{checkboxState?.newMessages && (
<MdCheck
className={`text-brand-green-primary
`}
Expand Down
1 change: 1 addition & 0 deletions pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const SettingPage = () => {
});
const baseUrl = 'https://hng6-r5y3.onrender.com/api/v1/';
const handleNotificationUpdate = async () => {
// const anyCheckboxChecked = Object.values(checkboxState).some(value => value === true);
setLoading(true);
try {
const url = `${baseUrl}set-notification-settings/${auth?.user.id}`;
Expand Down
Loading