Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
Abh1noob committed Mar 12, 2024
1 parent d9351d0 commit 9a6693c
Show file tree
Hide file tree
Showing 34 changed files with 91 additions and 269 deletions.
9 changes: 3 additions & 6 deletions devsoc24-portal-fe/src/app/edit-idea/edit-idea-form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm, Controller } from "react-hook-form";
import { type z } from "zod";
import {
Form,
FormControl,
Expand All @@ -13,10 +12,8 @@ import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { Button } from "@/components/ui/button";
import { ideaSchema } from "@/schemas/idea";
import toast, { Toaster } from "react-hot-toast";

import toast from "react-hot-toast";
import axios from "axios";
import { useRouter } from "next/navigation";

interface FormValues {
title: string;
Expand Down Expand Up @@ -55,7 +52,7 @@ export default function EditIdeaForm() {
withCredentials: true,
},
);
console.log(res.data.data);
// console.log(res.data.data);
form.reset(res.data.data);
} catch (error) {
console.log("Error getting idea submission:", error);
Expand All @@ -79,7 +76,7 @@ export default function EditIdeaForm() {

async function onSubmit(data: FormValues) {
const handleSubmit = async () => {
const res = await axios.patch<SubmitProjectResponse>(
await axios.patch<SubmitProjectResponse>(
`${process.env.NEXT_PUBLIC_API_URL}/idea/update`,
data,
{
Expand Down
2 changes: 0 additions & 2 deletions devsoc24-portal-fe/src/app/edit-idea/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import Image from "next/image";
import Logo from "@/components/logo";
import Dashtitle from "@/assets/images/titleDashboard.svg";
import toast, { Toaster } from 'react-hot-toast';

import { ArrowLeft } from "lucide-react";
import Link from "next/link";
import EditIdeaForm from "./edit-idea-form";
Expand Down
9 changes: 3 additions & 6 deletions devsoc24-portal-fe/src/app/edit-project/edit-subject-form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm, Controller } from "react-hook-form";
import { type z } from "zod";
import {
Form,
FormControl,
Expand All @@ -13,10 +12,8 @@ import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { Button } from "@/components/ui/button";
import { ideaSchema } from "@/schemas/idea";
import toast, { Toaster } from "react-hot-toast";

import toast from "react-hot-toast";
import axios from "axios";
import { useRouter } from "next/navigation";

interface FormValues {
title: string;
Expand Down Expand Up @@ -55,7 +52,7 @@ export default function EditProjectForm() {
withCredentials: true,
},
);
console.log(res.data.data);
// console.log(res.data.data);
form.reset(res.data.data);
} catch (error) {
console.log("Error getting idea submission:", error);
Expand All @@ -79,7 +76,7 @@ export default function EditProjectForm() {

async function onSubmit(data: FormValues) {
const handleSubmit = async () => {
const res = await axios.patch<SubmitProjectResponse>(
await axios.patch<SubmitProjectResponse>(
`${process.env.NEXT_PUBLIC_API_URL}/project/update`,
data,
{
Expand Down
7 changes: 3 additions & 4 deletions devsoc24-portal-fe/src/app/forgot/forgot-pass-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import {
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import toast, { Toaster } from "react-hot-toast";
import toast from "react-hot-toast";
import { useRouter } from "next/navigation";
import { MailIcon } from "lucide-react";
import Link from "next/link";
import { type APIResponse } from "@/schemas/api";
import axios, { type AxiosError } from "axios";
import { BadRequest, ServerError } from "@/components/toast";
import ToastContainer from "@/components/ToastContainer";

type ForgotFormValues = z.infer<typeof forgotSchema>;
Expand All @@ -34,7 +33,7 @@ export default function ForgotForm() {
});

async function onSubmit(form: ForgotFormValues) {
console.log(form);
// console.log(form);
const handleSubmit = async () => {
await axios.post<APIResponse>(
`${process.env.NEXT_PUBLIC_API_URL}/reset-password`,
Expand All @@ -46,7 +45,7 @@ export default function ForgotForm() {
};
void toast.promise(handleSubmit(), {
loading: "Cooking...",
success: (temp) => {
success: () => {
setTimeout(() => {
void router.push("/reset?email=" + form.email);
}, 1500);
Expand Down
36 changes: 13 additions & 23 deletions devsoc24-portal-fe/src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import {
useUserStore,
showModalStore,
} from "@/store/store";
import Loading from "../loading";
import TrackComponent from "@/components/track/TrackComponent";
import toast, { Toaster } from "react-hot-toast";
import toast from "react-hot-toast";
import { refresh, type userProps } from "@/interfaces";
import { type APIResponse } from "@/schemas/api";
import {
Expand All @@ -27,7 +26,6 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Button } from "@/components/ui/button";
import { User } from "lucide-react";
import ToastContainer from "@/components/ToastContainer";
import Link from "next/link";
Expand All @@ -48,14 +46,6 @@ interface ideaProps {
};
}

interface teamProps {
data: {
token_expired?: boolean;
};
message: string;
status: string;
}

export default function HomePage() {
const router = useRouter();
const { idea, setIdea } = useIdeaStore();
Expand All @@ -67,7 +57,7 @@ export default function HomePage() {
const { showModal, setShowModal } = showModalStore();
const logout = async () => {
try {
const response = await axios.post(
await axios.post(
`${process.env.NEXT_PUBLIC_API_URL}/logout`,
{
nallaData: "",
Expand All @@ -83,7 +73,7 @@ export default function HomePage() {
switch (e.response?.status) {
case 401:
await refresh();
console.log("401");
// console.log("401");
break;
default:
console.log(e);
Expand All @@ -110,20 +100,20 @@ export default function HomePage() {
withCredentials: true,
},
);
console.log(response.data.data.is_leader);
// console.log(response.data.data.is_leader);
setIsLeader(response.data.data.is_leader);
console.log(isLeader);
// console.log(isLeader);
} catch (e) {
if (axios.isAxiosError(e)) {
switch (e.response?.status) {
case 401:
void router.push("/");
break;
case 404:
console.log("no team");
// console.log("no team");
break;
case 409:
console.log("Not in team");
// console.log("Not in team");
break;
default:
console.log(e);
Expand Down Expand Up @@ -156,7 +146,7 @@ export default function HomePage() {
break;
case 417:
setTeam(true);
console.log("no team");
// console.log("no team");
break;
case 200:
setTeam(true);
Expand All @@ -178,7 +168,7 @@ export default function HomePage() {
},
);
SetIdea("idea found");
console.log("FETCH IDEA: ", response);
// console.log("FETCH IDEA: ", response);
} catch (e) {
if (axios.isAxiosError(e)) {
const axiosError = e as AxiosError<APIResponse>;
Expand All @@ -190,10 +180,10 @@ export default function HomePage() {
if (axiosError.response?.data.message === "user does not exist") {
router.push("/");
}
console.log("no team");
// console.log("no team");
break;
case 417:
console.log("team no idea");
// console.log("team no idea");
break;
case 409:
setIdea(409);
Expand All @@ -217,13 +207,13 @@ export default function HomePage() {

useEffect(() => {
if (user.data.team_id === "00000000-0000-0000-0000-000000000000") {
console.log("Loner saala");
// console.log("Loner saala");
setTeam(true);
} else {
void fetchTeam();
}
if (user.data.is_leader) {
console.log("Leader saala");
// console.log("Leader saala");
setIsLeader(true);
}
if (user.data.is_leader)
Expand Down
3 changes: 1 addition & 2 deletions devsoc24-portal-fe/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default function RootLayout({
}) {
useEffect(() => {
setInterval(() => {
const a = "s";
axios
.post(
`${process.env.NEXT_PUBLIC_API_URL}/refresh`,
Expand All @@ -29,7 +28,7 @@ export default function RootLayout({
},
)
.then((res) => {
console.log(res);
// console.log(res);
})
.catch((e) => {
console.log(e);
Expand Down
8 changes: 3 additions & 5 deletions devsoc24-portal-fe/src/app/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import {
import { Input } from "@/components/ui/input";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import toast, { Toaster } from "react-hot-toast";
import toast from "react-hot-toast";
import { useRouter } from "next/navigation";
import { EyeIcon, EyeOffIcon, LockKeyholeIcon, MailIcon } from "lucide-react";
import Link from "next/link";
import { type LoginResponse } from "@/schemas/api";
import axios, { type AxiosError } from "axios";
import { BadRequest, ServerError } from "@/components/toast";
import ToastContainer from "@/components/ToastContainer";

type LoginFormValues = z.infer<typeof loginSchema>;
Expand All @@ -44,7 +42,7 @@ export default function LoginForm() {
}
async function onSubmit(formVal: LoginFormValues) {
const submitForm = async () => {
const { data } = await axios.post<APIResponse>(
await axios.post<APIResponse>(
`${process.env.NEXT_PUBLIC_API_URL}/login`,
{ email: formVal.email, password: formVal.password },
{
Expand All @@ -55,7 +53,7 @@ export default function LoginForm() {

void toast.promise(submitForm(), {
loading: "Cooking...",
success: (temp) => {
success: () => {
void router.push("/home");
return `Logged in successfully!`;
},
Expand Down
1 change: 0 additions & 1 deletion devsoc24-portal-fe/src/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import Image from "next/image";
import Logo from "@/components/logo";
import Dashtitle from "@/assets/images/titleDashboard.svg";
import toast, { Toaster } from 'react-hot-toast';
import Profile from "./profile-form";
import { ArrowLeft } from "lucide-react";
import Link from "next/link";
Expand Down
11 changes: 5 additions & 6 deletions devsoc24-portal-fe/src/app/profile/profile-form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm, Controller } from "react-hook-form";
import { type z } from "zod";

import {
Form,
FormControl,
Expand All @@ -12,7 +12,7 @@ import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { profileSchema } from "@/schemas/profile";
import toast, { Toaster } from "react-hot-toast";
import toast from "react-hot-toast";
import blocks from "@/../public/hostels.json";
import axios, { type AxiosResponse } from "axios";
import { type userProps } from "@/interfaces";
Expand Down Expand Up @@ -42,7 +42,6 @@ interface SubmitProjectResponse {
import send from "@/assets/images/Send.svg";
import Image from "next/image";
import { useEffect } from "react";
const tracks = ["Track 1", "Track 2", "Track 3"];

export default function Profile() {
useEffect(() => {
Expand All @@ -54,7 +53,7 @@ export default function Profile() {
withCredentials: true,
},
);
console.log(response.data.data);
// console.log(response.data.data);
form.reset(response.data.data);
} catch (error) {
console.log("Error getting idea submission:", error);
Expand All @@ -78,7 +77,7 @@ export default function Profile() {
});

async function onSubmit(data: FormValues) {
console.log(data);
// console.log(data);
const handleSubmit = async () => {
const res = await axios.patch<SubmitProjectResponse>(
`${process.env.NEXT_PUBLIC_API_URL}/user/update`,
Expand All @@ -87,7 +86,7 @@ export default function Profile() {
withCredentials: true,
},
);
console.log(res.data);
// console.log(res.data);
};
void toast.promise(handleSubmit(), {
loading: `Cooking...`,
Expand Down
7 changes: 3 additions & 4 deletions devsoc24-portal-fe/src/app/reset/reset-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import { Button } from "@/components/ui/button";
import { useRouter, useSearchParams } from "next/navigation";
import { EyeIcon, EyeOffIcon, KeyRoundIcon, LockKeyhole } from "lucide-react";
import Link from "next/link";
import toast, { Toaster } from "react-hot-toast";
import toast from "react-hot-toast";
import axios, { type AxiosError } from "axios";
import { type APIResponse } from "@/schemas/api";
import { BadRequest, ServerError } from "@/components/toast";
import ToastContainer from "@/components/ToastContainer";

type ResetFormValues = z.infer<typeof resetSchema>;
Expand All @@ -41,7 +40,7 @@ export default function ResetForm() {
});

async function onSubmit(form: ResetFormValues) {
console.log(form);
// console.log(form);
// const toastId = toast.loading("Reseting...", { autoClose: false });
const handleSubmit = async () => {
await axios.patch<APIResponse>(
Expand All @@ -58,7 +57,7 @@ export default function ResetForm() {
};
void toast.promise(handleSubmit(), {
loading: "Cooking...",
success: (temp) => {
success: () => {
setTimeout(() => {
void router.push("/");
}, 1500);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use client";

import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import React, { useState } from "react";
import VitianForm from "@/components/forms/vitian-form";
import ExternalForm from "@/components/forms/external-form";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function PersonalDetails({
gender as "Male" | "Female" | "Others" | "Prefer Not to Say",
);
setGender(form.getValues("gender"));
console.log("Form Values:", form.getValues());
// console.log("Form Values:", form.getValues());
}, [gender]);

async function onSubmit(data: PersonalDetailsFormValues) {
Expand Down
Loading

0 comments on commit 9a6693c

Please sign in to comment.