Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/components/common/validation/validation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export const isValidEmail = (email: string) => {
};

export const validatePassword = (pwd :string) => {
if (!isvalidpassword(pwd)) return 'At least 6 characters including a number, uppercase, and lowercase letter';
if (!isvalidpassword(pwd)) return 'At least 6 characters including a number, and lowercase letter';
return '';
};

const isvalidpassword = (newPassword: string) => {
const passwordregex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,}$/;
const passwordregex = /^(?=.*[a-z])(?=.*\d)[a-zA-Z\d]{6,}$/;
return passwordregex.test(newPassword);
};
6 changes: 3 additions & 3 deletions src/components/global/navbar/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ function User() {
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
const {data: sessions} = useSession()
const { data: sessions } = useSession()
const router = useRouter();

const {id_token, idToken} = sessions?.user as { id_token?: string, idToken?: string } || {};
const { id_token, idToken } = sessions?.user as { id_token?: string, idToken?: string} || {};
const handleClose = (url?: string) => {
setAnchorEl(null);
url && router.push(url)
};

const dropdown = [
["My Profile", "/my-profile", "/images/icon-container (2).svg"],
["API Plans", "/apiplans", "/images/API.svg"],
["API Plans", "https://adityaagarwal.notion.site/Products-Services-c3633ff3f9ea4aeeb1892ae1303439ba#4b87ad9fa7a346548e1c7cd71803821d", "/images/API.svg"],
["API Keys", "/apiKeys", "images/shield-key.svg"],
]
const propsConfig = {
Expand Down
22 changes: 22 additions & 0 deletions src/pages/resetPassword.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import SEO from '@/components/common/SEO'
import React, { ReactElement, useEffect } from 'react';
import Layout from '@/components/global/Layout';
import Recovery from "../views/recover/recover"
import ReactGA from 'react-ga4';


function Recover () {
useEffect(() => {
ReactGA.send({ hitType: 'Recover', page: window.location.pathname });
}, []);
return (
<div>
<SEO/>
<Recovery />
</div>
)
}

export default Recover;

Recover.getLayout = (page: ReactElement) => <Layout>{page}</Layout>;
42 changes: 24 additions & 18 deletions src/views/ApiKeys/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useEffect, useState } from 'react';
import { useSession } from "next-auth/react"
import Table, { tableDataT } from '@/components/common/table/Table';
import table_data from './table_data.json';
import { useRouter } from "next/router";
import moment from 'moment';
import { ToastContainer , toast} from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
Expand All @@ -16,25 +17,26 @@ function APIKeys() {
const [tableLoading] = useState(false);
const [captionText, setCaptionText] = useState('');
const { data: sessions } = useSession()
const { id_token, sub } = sessions?.user as { id_token: string; sub: string } || {};
const { id_token, sub, idToken } = sessions?.user as { id_token: string; idToken: string; sub: string } || {};
const router = useRouter();

useEffect(() => {
const fetchData = async () => {
if (!sub) return;
try {
const { data } = await fetchAPIKeyList(id_token, sub);
if (Array.isArray(data.data.apiKeys)) {
const newRows = data.data.apiKeys.map((item :any) => ({
keys: item.value,
created: moment(item.createdDate).format('MM/DD/yyyy'),
}));
setApiKeysTable((prevState) => ({ ...prevState, rows: newRows }));
}
} catch (error) {
console.error(error);
const fetchData = async () => {
if (!sub) return;
try {
const { data } = await fetchAPIKeyList(id_token || idToken, sub);
if (Array.isArray(data.data.apiKeys)) {
const newRows = data.data.apiKeys.map((item :any) => ({
keys: item.value,
created: moment(item.createdDate).format('MM/DD/yyyy'),
}));
setApiKeysTable((prevState) => ({ ...prevState, rows: newRows }));
}
};
} catch (error) {
console.error(error);
}
};

useEffect(() => {
fetchData();
}, [sub]);

Expand All @@ -43,8 +45,11 @@ function APIKeys() {
}, [apiKeysTable]);

const handleCreateApiKey = () => {
createAPIKey(id_token, toast);
createAPIKey(id_token || idToken, toast).then(()=>{
fetchData();
});
}
const apiPlanUrl = "https://adityaagarwal.notion.site/Products-Services-c3633ff3f9ea4aeeb1892ae1303439ba#4b87ad9fa7a346548e1c7cd71803821d"

return (
<div className="">
Expand All @@ -66,10 +71,11 @@ function APIKeys() {
</button>
<button
className="text-sm border border-dark-200 text-md gap-2 inline-flex tracking-[1.25px] pt-[9px] pb-[9px] px-4 uppercase rounded bg-white"
onClick={()=> router.push(apiPlanUrl)}
style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}
>
<img className="-translate-y-[1px]" src="/images/api.svg" alt="" />
<span>Check Api Plan</span>
<span>CHECK API PLANS</span>
</button>
</div>
</div>
Expand Down
18 changes: 17 additions & 1 deletion src/views/Profile/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import UserInfo from './userInfo'
import { isValidEmail, validateEmail, validatePassword } from '@/components/common/validation/validation';
import { Divider } from '@mui/material';
import Footer from '@/components/global/footer/Footer';
import { useSession } from "next-auth/react";
interface User {
name?: string | null | undefined;
'custom:designation'?: string | null | undefined;
'custom:companyName'?: string | null | undefined;
'custom:receiveUpdates'?: string | null | undefined;
}

const Profile = () => {
const validationOdj = {
Expand All @@ -16,6 +23,15 @@ const Profile = () => {
'new password' : { error:false, fb: false, msg:'' },
'password' : { error:false, fb: false, msg:'' }
}
const { data: sessions } = useSession()
const { user }:{ user?: User } = sessions || {};

const initUser = {
name: user?.name ,
designation: user && user['custom:designation'],
companyName: user && user['custom:companyName'],
receiveUpdates: user && user['custom:receiveUpdates'],
}
const [newEmail, setNewEmail] = useState('');
const [password, setPassword] = useState('');
const [nameError, setNameError] = useState<any>('');
Expand Down Expand Up @@ -87,7 +103,7 @@ const Profile = () => {
<ProfileSection title="Account" buttonText="SAVE CHANGES" onClick={nameValue}>
<div className="flex-col w-2/4">
<div className="xl:w-11/12 md:w-5/6 lg:w-4/5 w-11/12">
<UserInfo handleInfo={nameValue} />
<UserInfo handleInfo={nameValue} data={initUser} />
</div>
</div>
<Divider orientation="vertical" flexItem />
Expand Down
5 changes: 3 additions & 2 deletions src/views/Profile/userInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import { FormControl, InputLabel, FormControlLabel, Checkbox, NativeSelect } fro
import TextField from '@mui/material/TextField';
import { validateName } from "@/components/common/validation/validation";

function UserInfo({handleInfo} :any) {
function UserInfo({handleInfo, data} :any) {
const validationOdj = {
name: { error:false, fb: false, msg:'' },
designation: { error:false, fb: false, msg:'' },
companyName: { error:false, fb: false, msg:'' },
}
const [isValid, setValidate] = useState(validationOdj);
const [user, setUser] = useState({
const [user, setUser] = useState( {
name: '',
designation: '',
companyName: '',
receiveUpdates: false,
...data
});

const designations = [{ name: '' , value: 'Select' }, { name: 'Founder', value:'Founder' }, { name: 'Engineer', value:'Engineer' }, { name: 'Other', value:'Other' }]
Expand Down
13 changes: 7 additions & 6 deletions src/views/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {signIn, useSession} from 'next-auth/react';
import {useRouter} from 'next/router';
import Spinner from '@/components/common/Spinner';
import {mockProviders} from 'next-auth/client/__tests__/helpers/mocks';
import callbackUrl = mockProviders.github.callbackUrl;
import {TextField} from '@mui/material';

const LoginComponent = () => {
Expand All @@ -23,7 +22,6 @@ const LoginComponent = () => {
const handleLoginWithGoogle = async () => {
try {
setLoading(true);

const googleSignInResponse = await signIn('cognito_google', {
redirect: false,
callbackUrl: `http://localhost:3000${query?.callBack}`,
Expand Down Expand Up @@ -130,10 +128,13 @@ const LoginComponent = () => {
>
LOGIN
</button>
<p className="text-xl text-center text-black font-weight-bold mt-9"
style={{color: '#1976D2', fontSize: '14px'}}>
Reset Password
</p>

<Link href={`/resetPassword`}>
<p className="mt-5 text-xl text-center text-black font-weight-bold" style={{fontSize: '14px', color: '#1976D2'}}>
Reset Password
</p>
</Link>

<Link href={`/register?callBack=${router.query.callBack ? router.query.callBack : '/'}`}>
<p className="mt-5 text-xl text-center text-black font-weight-bold" style={{fontSize: '14px'}}>
No account? <span style={{color: '#1976D2'}}>Create one</span>
Expand Down
Loading