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

chore: close registration #110

Merged
merged 1 commit into from
Nov 1, 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
1 change: 1 addition & 0 deletions src/components/Payment/styles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const PaymentCardContainer = styled.div`
p-9
bg-background-dark
text-center
rounded-xl
`}
`;

Expand Down
111 changes: 68 additions & 43 deletions src/components/Registration/RegistrationForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useEffect } from 'react';
import { navigate } from 'gatsby';
import { toast } from 'react-toastify';
import { RegistrationContext } from './RegistrationContext';
import { Body2, ButtonText, Heading2, Input } from '../shared';
import { Body1, Body2, ButtonText, Heading2, Heading4, Input } from '../shared';
import { InputContainer, RegistrationCard, RegistrationCardTitle } from './styles';
import Button from '../shared/Button';
import { SHOW, verify, verifyAll } from './utils';
Expand Down Expand Up @@ -59,52 +59,77 @@ export const RegistrationForm = () => {
return (
<RegistrationCard>
<RegistrationCardTitle>
<Heading2 style={{ textTransform: 'none' }}>Registration form</Heading2>
<Body2 style={{ display: 'flex', gap: '16px' }}>
{isNITR ? 'Student from NIT Rourkela' : 'Student from other college'}
<ButtonText onClick={() => setIsNITR((prev) => !prev)} className='cursor-pointer' outline>
Change
</ButtonText>
</Body2>
<Heading2 style={{ textTransform: 'none' }}>
{isNITR ? 'Registration form' : 'Registration has been closed'}
</Heading2>
{isNITR && (
<Body2 style={{ display: 'flex', gap: '16px' }}>
Student from NIT Rourkela
<ButtonText
onClick={() => setIsNITR((prev) => !prev)}
className='cursor-pointer'
outline
>
Change
</ButtonText>
</Body2>
)}
</RegistrationCardTitle>

<InputContainer>
{Object.entries(inputData)
.filter(([, value]) =>
isNITR ? SHOW.NITR.includes(value.show) : SHOW.NON_NITR.includes(value.show),
)
.map(([key, value], index, array) => {
let gridCols;
if (array.length <= 4) {
gridCols = 'span 4';
} else if (index === array.length - 1 && index % 2 === 0) {
gridCols = '2 / 4';
} else {
gridCols = 'span 2';
}
{isNITR ? (
<>
<InputContainer>
{Object.entries(inputData)
.filter(([, value]) =>
isNITR ? SHOW.NITR.includes(value.show) : SHOW.NON_NITR.includes(value.show),
Shurtu-gal marked this conversation as resolved.
Show resolved Hide resolved
)
.map(([key, value], index, array) => {
let gridCols;
if (array.length <= 4) {
gridCols = 'span 4';
} else if (index === array.length - 1 && index % 2 === 0) {
gridCols = '2 / 4';
} else {
gridCols = 'span 2';
}

return (
<div key={key} style={{ gridColumn: gridCols }}>
<Input
data={value}
key={key}
onChange={(e) => setInputValue(key, e.target.value)}
onBlur={onBlur}
/>
</div>
);
})}
</InputContainer>
return (
<div key={key} style={{ gridColumn: gridCols }}>
<Input
data={value}
key={key}
onChange={(e) => setInputValue(key, e.target.value)}
onBlur={onBlur}
/>
</div>
);
})}
</InputContainer>

<Button
type='submit'
variant='filled'
text='Register'
width='350px'
disabled={!verified && isNITR}
tooltip={verified ? '' : 'Verify your credentials'}
onClick={registerUser}
/>
<Button
type='submit'
variant='filled'
text='Register'
width='350px'
disabled={!verified && isNITR}
tooltip={verified ? '' : 'Verify your credentials'}
onClick={registerUser}
/>
</>
) : (
<>
<Heading4 font='Inter' style={{ textAlign: 'center', maxWidth: '500px' }}>
Registration for non-NITR students has been closed for this year. Please come back next
Shurtu-gal marked this conversation as resolved.
Show resolved Hide resolved
year.
</Heading4>
<Body1 style={{ display: 'flex', gap: '16px' }}>
Are you a student from NIT Rourkela?{' '}
<ButtonText onClick={() => setIsNITR(true)} className='cursor-pointer' outline>
Change
</ButtonText>
</Body1>
</>
)}
</RegistrationCard>
);
};
2 changes: 2 additions & 0 deletions src/components/shared/Typography/Heading4.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ export default styled.h4`
sm:text-xl
text-color-primary
`};
${(props) => props.font && `font-family: ${props.font};`};
`;
41 changes: 24 additions & 17 deletions src/pages/payment.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { useContext, useEffect, useState } from 'react';
import React, { useContext, useEffect } from 'react';
import { toast } from 'react-toastify';
import { navigate } from 'gatsby';
import { PaymentCard, PrivateRoute, SuccessCard } from '../components';
// import { Body1, ButtonText, PaymentCard, PrivateRoute, SuccessCard } from '../components';
import { AuthContext } from '../utils/Auth';
import { PaymentCardContainer } from '../components/Payment/styles';
import { Heading4, PrivateRoute } from '../components/shared';

const PaymentPage = () => {
const [paymentStatus, setPaymentStatus] = useState(false);
// const [paymentStatus, setPaymentStatus] = useState(false);
const { userData } = useContext(AuthContext);

useEffect(() => {
Expand All @@ -15,20 +17,20 @@ const PaymentPage = () => {
}
}, [userData]);

useEffect(() => {
const params = new URLSearchParams(window.location.search);
const currPaymentStatus = params.get('payment_status');
const paymentId = params.get('payment_id');
const paymentRequestId = params.get('payment_request_id');
// useEffect(() => {
// const params = new URLSearchParams(window.location.search);
// const currPaymentStatus = params.get('payment_status');
// const paymentId = params.get('payment_id');
// const paymentRequestId = params.get('payment_request_id');

if (currPaymentStatus === 'Credit' && paymentId && paymentRequestId) {
toast.success('Payment Successful');
setPaymentStatus(true);
} else if (currPaymentStatus === 'Failed') {
toast.error('Payment Failed');
setPaymentStatus(false);
}
}, []);
// if (currPaymentStatus === 'Credit' && paymentId && paymentRequestId) {
// toast.success('Payment Successful');
// setPaymentStatus(true);
// } else if (currPaymentStatus === 'Failed') {
// toast.error('Payment Failed');
// setPaymentStatus(false);
// }
// }, []);

return (
<PrivateRoute>
Expand All @@ -43,7 +45,12 @@ const PaymentPage = () => {
marginTop: '7rem',
}}
>
{paymentStatus ? <SuccessCard /> : <PaymentCard />}
<PaymentCardContainer>
<Heading4 font='Inter' style={{ textAlign: 'center', maxWidth: '500px' }}>
Registration for non-NITR students has been closed for this year. Please come back
next year.
Shurtu-gal marked this conversation as resolved.
Show resolved Hide resolved
</Heading4>
</PaymentCardContainer>
</div>
)}
</PrivateRoute>
Expand Down
Loading