Skip to content

Commit

Permalink
Add api for creation connected to worker
Browse files Browse the repository at this point in the history
  • Loading branch information
h0i5 committed May 27, 2024
1 parent 026dc13 commit 078ca2a
Show file tree
Hide file tree
Showing 6 changed files with 812 additions and 679 deletions.
2 changes: 1 addition & 1 deletion app/register/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { changeEmail } from "@/app/redux/email/emailActions";
import { updateData } from "@/app/redux/formData/formDataActions";

type FormData = {
export type FormData = {
course: string;
year: string;
rollNumber: string;
Expand Down
8 changes: 4 additions & 4 deletions app/register/components/Forms/CollegeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const CollegeForm = ({
value={course}
className={
dark
? "text-white bg-slate-800 my-2 border-gray-600 p-2 rounded-lg flex flex-row items-center w-24 hover:border-white-600 mb-5"
: "p-2 rounded-lg my-2 flex flex-row items-center bg-white hover:border-gray-600 mb-5"
? "text-white bg-slate-800 border-gray-600 p-2 rounded-lg flex flex-row items-center w-24 hover:border-white-600 mb-5"
: "p-2 rounded-lg flex flex-row items-center bg-white hover:border-gray-600 mb-5"
}
style={{ width: "100%" }}
>
Expand Down Expand Up @@ -85,8 +85,8 @@ const CollegeForm = ({
onChange={(e) => updateFields({ batch: e.target.value })}
className={
dark
? "text-white bg-slate-800 border-gray-600 p-2 rounded-lg mt-5 mb-2 hover:border-white-600"
: "bg-white p-2 rounded-lg mt-5 hover:border-gray-600 mb-2"
? "text-white bg-slate-800 border-gray-600 p-2 rounded-lg mb-2 hover:border-white-600"
: "bg-white p-2 rounded-lg hover:border-gray-600 mb-2"
}
>
<option value="batch1">Batch 1</option>
Expand Down
39 changes: 36 additions & 3 deletions app/verify/OTPForm.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
import DarkModeStatus from "../redux/status/darkModeStatus";
import { FormEvent } from "react";
import FormDataStatus from "../redux/status/formDataStatus";
import axios from "axios";
import { useSelector } from "react-redux";
import { RootState } from "../redux/store";
const { convertToAES } = require("@harshiyer/json-crypto");
// var jwt = require("jsonwebtoken");

const OTPForm = () => {
const dark = DarkModeStatus();
const data = FormDataStatus();
const handleSubmit = (event: FormEvent) => {
const data = useSelector((state: RootState) => state.formData);
const handleSubmit = async (event: FormEvent) => {
event.preventDefault();
console.log(data);

console.log(data.FormData.collegeEmail);
const password = data.FormData.port0Password;
const email: string = data.FormData.collegeEmail;
const convertedData = new convertToAES(data, password);
const salt = (convertedData as any).salt;
const aes256Bit = (convertedData as any).aes256Bit;
const keyHash = (convertedData as any).sha256key;

// var token = jwt.sign({ email: data.FormData.collegeEmail }, "testToken", {
// expiresIn: "1h",
// });
var token = "TOKEN"; //add token here
const payload: any = {
token: token,
email: email,
salt: salt,
aes256Bit: "aes256Bit", //will work on ts types for npm package
keyHash: keyHash,
};
const url = "http://localhost:XXXXX/auth/create"; //add local db hosted url here
try {
axios.post(url, payload).then((res) => {
console.log(res);
});
} catch (error) {
console.error("Error:", error);
}
};
return (
<div>
Expand Down
5 changes: 2 additions & 3 deletions app/verify/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import OTPForm from "./OTPForm";
const Verify = () => {
const email = useSelector((state: RootState) => state.email.email);
const dark = DarkModeStatus();

useEffect(() => {
document.title = "Verify";
}, []);
Expand Down Expand Up @@ -39,8 +39,7 @@ const Verify = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
window.location.href = "/register";
}
);
});
return (
<div>
<p>Redirecting to register page...</p>
Expand Down
Loading

0 comments on commit 078ca2a

Please sign in to comment.