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

Feature/refreshtoken #272

Draft
wants to merge 19 commits into
base: dev
Choose a base branch
from
Draft
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 .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "import", "no-relative-import-paths"],
"plugins": [/*"@typescript-eslint" */ "import", "no-relative-import-paths"],
"extends": [
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
// "plugin:@typescript-eslint/recommended-requiring-type-checking",
"next/core-web-vitals",
"prettier",
"plugin:tailwindcss/recommended",
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
"@heroicons/react": "^2.0.18",
"@hookform/resolvers": "^3.3.1",
"@reduxjs/toolkit": "^1.9.5",
"axios": "^1.7.7",
"class-variance-authority": "^0.7.0",
"date-fns": "^3.6.0",
"date-fns-tz": "^3.1.3",
"framer-motion": "^10.16.4",
"lottie-react": "^2.4.0",
"next": "^14.0.3",
"next": "^14.2.6",
"next-themes": "^0.2.1",
"react": "^18.2.0",
"react": "^18.3.1",
"react-datepicker": "^6.1.0",
"react-dom": "^18.2.0",
"react-dom": "^18.3.1",
"react-hook-form": "^7.46.2",
"react-redux": "^8.1.2",
"redux-persist": "^6.0.0",
Expand Down Expand Up @@ -58,7 +59,7 @@
"autoprefixer": "10.4.14",
"cypress": "^12.17.3",
"eslint": "8.46.0",
"eslint-config-next": "^14.0.3",
"eslint-config-next": "^14.2.6",
"eslint-config-prettier": "^8.10.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.28.0",
Expand Down
4 changes: 2 additions & 2 deletions src/app/(auth)/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { type AppError } from "@/types/types";
import { currentDate } from "@/utils/getCurrentSprint";

interface AuthProviderProps {
user: User | null;
error: AppError | null;
user?: User | null;
error?: AppError | null;
}

export default function AuthProvider({ user, error }: AuthProviderProps) {
Expand Down
17 changes: 17 additions & 0 deletions src/app/(auth)/login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { axiosInstance } from "@/utils/axiosInstance";

export async function login(email: string, password: string) {
try {
const response = await axiosInstance.post("/api/v1/auth/login", {
email,
password,
});

return response.data;
} catch (error: any) {
throw Error(error);
}
}
38 changes: 26 additions & 12 deletions src/app/(auth)/sign-in/components/SignInFormContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as z from "zod";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand All @@ -14,7 +17,8 @@ import { useAppDispatch } from "@/store/hooks";
import routePaths from "@/utils/routePaths";

import useServerAction from "@/hooks/useServerAction";
import Spinner from "@/components/Spinner";
// import Spinner from "@/components/Spinner";
import { login } from "@/app/(auth)/login";

const validationSchema = z.object({
email: validateTextInput({
Expand Down Expand Up @@ -43,9 +47,9 @@ function SignInFormContainer({
const dispatch = useAppDispatch();

const {
runAction: serverSignInAction,
// runAction: serverSignInAction,
isLoading: serverSignInLoading,
setIsLoading: setServerSignInLoading,
// setIsLoading: setServerSignInLoading,
} = useServerAction(serverSignIn);

const {
Expand All @@ -59,25 +63,35 @@ function SignInFormContainer({

const onSubmit: SubmitHandler<ValidationSchema> = async (data) => {
const { email, password } = data;
const [res, error] = await serverSignInAction({ email, password });

if (res) {
try {
await login(email, password);
dispatch(clientSignIn());
router.replace(routePaths.dashboardPage());
}

if (error) {
} catch (error: any) {
dispatch(
onOpenModal({ type: "error", content: { message: error.message } }),
);
setServerSignInLoading(false);
}
// const [res, error] = await serverSignInAction({ email, password });

// if (res) {
// dispatch(clientSignIn());
// router.replace(routePaths.dashboardPage());
// }

// if (error) {
// dispatch(
// onOpenModal({ type: "error", content: { message: error.message } }),
// );
// setServerSignInLoading(false);
// }
};

function renderButtonContent() {
if (serverSignInLoading) {
return <Spinner />;
}
// if (serverSignInLoading) {
// return <Spinner />;
// }
return "Sign In";
}

Expand Down
1 change: 1 addition & 0 deletions src/app/(main)/dashboard/[teamId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { redirect } from "next/navigation";
import VoyageDashboardPage from "@/app/(main)/dashboard/components/voyage-dashboard/VoyageDashboardPage";
import PreVoyageDashboard from "@/app/(main)/dashboard/components/pre-voyage-dashboard/PreVoyageDashboard";
Expand Down
Loading
Loading