diff --git a/src/apicalls/api-fetcher.tsx b/src/apicalls/api-fetcher.tsx index 9debca7..7d216d7 100644 --- a/src/apicalls/api-fetcher.tsx +++ b/src/apicalls/api-fetcher.tsx @@ -1,12 +1,18 @@ "use server"; -import { redirect } from "next/navigation"; - const defaultHeaders = { accept: "application/json", "Content-type": "application/json", }; +const DefaultResponse = { + completed: false, + error: "Hata tipi belirtilmedi", + message: "Hata oluştu, lütfen tekrar deneyin", + status: "500", + data: {}, +}; + interface HeadersObject { cache: string; method: string; @@ -14,6 +20,26 @@ interface HeadersObject { body?: string; } +const prepareResponse = async (response: any) => { + try { + const responseJson = await response.json(); + const statusResponse = response?.status; + const errorResponse = responseJson?.error || responseJson?.Error; + const messageResponse = (responseJson?.message || "").toString(); + const completeResponse = responseJson?.completed; + const preparedResponse = { + completed: completeResponse, + message: messageResponse, + status: statusResponse, + error: errorResponse || "", + ...responseJson, + }; + + return preparedResponse; + } catch (error) {} + return DefaultResponse; +}; + const fetchData = async ( endpoint: string, payload: any, @@ -31,18 +57,11 @@ const fetchData = async ( body: JSON.stringify(payload), }; } - try { const response = await fetch(endpoint, headersObject); - if (response.status === 200) { - return response; - } else if (response.status === 401) { - return { status: 401 }; - } else { - return { status: response.status }; - } + return await prepareResponse(response); } catch (error) {} - return { status: 500 }; + return DefaultResponse; }; const fetchDataWithToken = async ( @@ -68,15 +87,9 @@ const fetchDataWithToken = async ( } try { const response = await fetch(endpoint, headersObject); - if (response.status === 200) { - return response; - } else if (response.status === 401) { - redirect("/login/email"); - } else { - return { status: response.status }; - } + return await prepareResponse(response); } catch (error) {} - return { status: 500 }; + return DefaultResponse; }; export { fetchData, fetchDataWithToken }; diff --git a/src/apicalls/cookies/token.tsx b/src/apicalls/cookies/token.tsx index 4f59e02..34728b3 100644 --- a/src/apicalls/cookies/token.tsx +++ b/src/apicalls/cookies/token.tsx @@ -1,7 +1,7 @@ "use server"; import { fetchDataWithToken } from "../api-fetcher"; import { cookies } from "next/headers"; -import { baseUrl, tokenSecret } from "../basics"; +import { baseUrl, cookieObject, tokenSecret } from "@/apicalls/basics"; import NextCrypto from "next-crypto"; const checkToken = `${baseUrl}/authentication/valid`; @@ -20,6 +20,7 @@ async function check_access_token_is_valid() { "GET", false ); + console.log("response", response?.status); return response?.status === 200 ? true : false; } diff --git a/src/apicalls/login/login.tsx b/src/apicalls/login/login.tsx index 5f22159..71da6ed 100644 --- a/src/apicalls/login/login.tsx +++ b/src/apicalls/login/login.tsx @@ -1,7 +1,7 @@ "use server"; import { fetchData, fetchDataWithToken } from "../api-fetcher"; import { cookies } from "next/headers"; -import { baseUrl, cookieObject, tokenSecret } from "../basics"; +import { baseUrl, cookieObject, tokenSecret } from "@/apicalls/basics"; import NextCrypto from "next-crypto"; const loginEndpoint = `${baseUrl}/authentication/login`; @@ -29,7 +29,6 @@ async function login_via_access_keys(payload: LoginViaAccessKeys) { const cookieStore = await cookies(); const nextCrypto = new NextCrypto(tokenSecret); - let responseData: any = {}; const tokenResponse: any = await fetchData( loginEndpoint, { @@ -42,15 +41,14 @@ async function login_via_access_keys(payload: LoginViaAccessKeys) { false ); if (tokenResponse.status === 200) { - responseData = await tokenResponse?.json(); - const accessToken = await nextCrypto.encrypt(responseData.access_token); + const accessToken = await nextCrypto.encrypt(tokenResponse.access_token); const accessObject = await nextCrypto.encrypt( - JSON.stringify(responseData.access_object) + JSON.stringify(tokenResponse.access_object) ); const userProfile = await nextCrypto.encrypt( - JSON.stringify(responseData.user) + JSON.stringify(tokenResponse.user) ); - const refreshToken = await nextCrypto.encrypt(responseData.refresh_token); + const refreshToken = await nextCrypto.encrypt(tokenResponse.refresh_token); // const userType = await nextCrypto.encrypt(responseData.user_type); // cookieStore.set({ @@ -82,11 +80,10 @@ async function login_via_access_keys(payload: LoginViaAccessKeys) { // ...cookieObject, // }); } - return responseData; + return tokenResponse; } async function login_select_employee(payload: LoginSelectEmployee) { - let responseData = null; const cookieStore = await cookies(); const nextCrypto = new NextCrypto(tokenSecret); @@ -99,8 +96,8 @@ async function login_select_employee(payload: LoginSelectEmployee) { "POST", false ); + const responseData = selectResponse?.data; if (selectResponse.status === 200) { - responseData = await selectResponse?.json(); const usersSelection = await nextCrypto.encrypt( JSON.stringify({ company_uu_id: payload.company_uu_id, @@ -117,7 +114,6 @@ async function login_select_employee(payload: LoginSelectEmployee) { } async function login_select_occupant(payload: LoginSelectOccupant) { - let responseData = null; const cookieStore = await cookies(); const nextCrypto = new NextCrypto(tokenSecret); const selectResponse: any = await fetchDataWithToken( @@ -131,7 +127,6 @@ async function login_select_occupant(payload: LoginSelectOccupant) { false ); if (selectResponse.status === 200) { - responseData = await selectResponse?.json(); const usersSelection = await nextCrypto.encrypt( JSON.stringify({ company_uu_id: { @@ -147,7 +142,7 @@ async function login_select_occupant(payload: LoginSelectOccupant) { ...cookieObject, }); } - return responseData; + return selectResponse; } export { login_via_access_keys, login_select_employee, login_select_occupant }; diff --git a/src/apicalls/login/logout.tsx b/src/apicalls/login/logout.tsx new file mode 100644 index 0000000..eb8001d --- /dev/null +++ b/src/apicalls/login/logout.tsx @@ -0,0 +1,57 @@ +"use server"; +import { fetchDataWithToken } from "../api-fetcher"; +import { cookies } from "next/headers"; +import { baseUrl } from "@/apicalls/basics"; + +const logOutEndpoint = `${baseUrl}/authentication/logout`; +const logOutAllEndpoint = `${baseUrl}/authentication/disconnect`; + +interface LoginOutUser { + token: string; + domain: string; +} + +async function logout_active_session(payload: LoginOutUser) { + const cookieStore = await cookies(); + cookieStore.delete("accessToken"); + cookieStore.delete("accessObject"); + cookieStore.delete("userProfile"); + cookieStore.delete("userSelection"); + + const tokenResponse: any = await fetchDataWithToken( + logOutEndpoint, + payload.token, + { + domain: payload.domain, + }, + "POST", + false + ); + if (tokenResponse.status === 200) { + return true; + } + return false; +} + +async function logout_all_sessions(payload: LoginOutUser) { + const cookieStore = await cookies(); + cookieStore.delete("accessToken"); + cookieStore.delete("accessObject"); + cookieStore.delete("userProfile"); + cookieStore.delete("userSelection"); + const tokenResponse: any = await fetchDataWithToken( + logOutAllEndpoint, + payload.token, + { + domain: payload.domain, + }, + "POST", + false + ); + if (tokenResponse.status === 200) { + return true; + } + return false; +} + +export { logout_active_session, logout_all_sessions }; diff --git a/src/apicalls/login/password.tsx b/src/apicalls/login/password.tsx new file mode 100644 index 0000000..fd6ac4d --- /dev/null +++ b/src/apicalls/login/password.tsx @@ -0,0 +1,48 @@ +"use server"; +import { fetchData, fetchDataWithToken } from "../api-fetcher"; +import { baseUrl } from "@/apicalls/basics"; + +const createPasswordEndpoint = `${baseUrl}/authentication/create_password`; +const changePasswordEndpoint = `${baseUrl}/authentication/change_password`; + +interface createPasswordViaToken { + token: string; + password: string; + rePassword: string; +} + +interface changePasswordViaToken { + accessToken: string; + oldPassword: string; + newPassword: string; +} + +async function create_password_via_token(payload: createPasswordViaToken) { + const createPasswordResponse: any = await fetchData( + createPasswordEndpoint, + { + password_token: payload.token, + password: payload.password, + re_password: payload.rePassword, + }, + "POST", + false + ); + return createPasswordResponse; +} + +async function change_password_via_token(payload: changePasswordViaToken) { + const changePasswordResponse: any = await fetchDataWithToken( + changePasswordEndpoint, + payload.accessToken, + { + old_password: payload.oldPassword, + new_password: payload.newPassword, + }, + "POST", + false + ); + return changePasswordResponse; +} + +export { create_password_via_token, change_password_via_token }; diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx new file mode 100644 index 0000000..1cfb420 --- /dev/null +++ b/src/app/dashboard/page.tsx @@ -0,0 +1,24 @@ +"use server"; +import React from "react"; +import { redirect } from "next/navigation"; +import { + check_access_token_is_valid, + retrieve_access_token, +} from "@/apicalls/cookies/token"; +import DashboardPage from "@/components/Dashboards/DashboardPage"; + +const Dashboard: React.FC = async () => { + const accessToken = (await retrieve_access_token()) || ""; + const token_is_valid = await check_access_token_is_valid(); + if (!token_is_valid) { + redirect("/login/email"); + } + + return ( +
+ +
+ ); +}; + +export default Dashboard; diff --git a/src/app/login/phone/page.tsx b/src/app/login/phone/page.tsx index 72a071c..cf2b21f 100644 --- a/src/app/login/phone/page.tsx +++ b/src/app/login/phone/page.tsx @@ -11,30 +11,5 @@ export default async function MyForm() { redirect("/login/select"); } - return ( -
-
- Evyos -

- Telefon Numarası ile Giriş Yapın -

-
- -

- Üye değilmisiniz?{" "} - - Üye olmak için tıklayın - -

-
- ); + return ; } diff --git a/src/app/login/select/page.tsx b/src/app/login/select/page.tsx index 32ecf06..f4d9b7e 100644 --- a/src/app/login/select/page.tsx +++ b/src/app/login/select/page.tsx @@ -15,6 +15,7 @@ const SelectPage: React.FC = async () => { if (!userType || !token_is_valid) { redirect("/login/email"); } + return userType === "employee" ? (
diff --git a/src/app/password/change/page.tsx b/src/app/password/change/page.tsx new file mode 100644 index 0000000..2761a7d --- /dev/null +++ b/src/app/password/change/page.tsx @@ -0,0 +1,25 @@ +"use server"; +import React from "react"; + +import { + retrieve_access_token, + check_access_token_is_valid, +} from "@/apicalls/cookies/token"; +import ChangePassword from "@/components/password/ChangePassword"; +import { redirect } from "next/navigation"; + +const ChangePasswordPage: React.FC = async () => { + const token_is_valid = await check_access_token_is_valid(); + if (!token_is_valid) { + redirect("/login/email"); + } + const accessToken = (await retrieve_access_token()) || ""; + + return ( +
+ +
+ ); +}; + +export default ChangePasswordPage; diff --git a/src/app/password/create/page.tsx b/src/app/password/create/page.tsx new file mode 100644 index 0000000..7461ea7 --- /dev/null +++ b/src/app/password/create/page.tsx @@ -0,0 +1,13 @@ +"use server"; +import CreatePassword from "@/components/password/CreatePassword"; +import React from "react"; + +const ChangePasswordPage: React.FC = () => { + return ( +
+ +
+ ); +}; + +export default ChangePasswordPage; diff --git a/src/components/Dashboards/DashboardPage.tsx b/src/components/Dashboards/DashboardPage.tsx new file mode 100644 index 0000000..4d696ac --- /dev/null +++ b/src/components/Dashboards/DashboardPage.tsx @@ -0,0 +1,89 @@ +"use client"; +import React from "react"; +import Image from "next/image"; +import { Toaster } from "@/components/ui/toaster"; +import { useToast } from "@/hooks/use-toast"; +import { useRouter } from "next/navigation"; + +import { showToast } from "@/components/login/toaster"; +import { logout_active_session } from "@/apicalls/login/logout"; + +interface LoginSelectUser { + access_token: string; +} + +const DashboardPage: React.FC = ({ access_token }) => { + const { toast } = useToast(); + const router = useRouter(); + + const logoutActiveSession = () => { + logout_active_session({ + token: access_token, + domain: "evyos.com.tr", + }) + .then((responseData: any) => { + if (responseData?.completed) { + showToast(toast, "Çıkış", { + message: "Çıkış başarılı", + data: JSON.stringify(responseData), + }); + router.push("/login/email"); + } + }) + .catch((error) => { + console.error(error); + showToast(toast, "Çıkış", { + message: "Çıkış başarısız", + data: JSON.stringify(error), + }); + }); + }; + + return ( +
+

Dashboard

+ +

Welcome to the dashboard!

+
+ ); +}; + +export default DashboardPage; diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index a01c0cf..a43c531 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -57,12 +57,12 @@ const Header = (props: { {/* */} - Logo + /> */}
diff --git a/src/components/login/loginselectemployee.tsx b/src/components/login/loginselectemployee.tsx index 6500395..b6b8c81 100644 --- a/src/components/login/loginselectemployee.tsx +++ b/src/components/login/loginselectemployee.tsx @@ -46,8 +46,8 @@ const LoginSelectEmployee: React.FC = ({
- {companiesList.map((data: any, index: number) => ( -
+ {companiesList.map((data: any) => ( +
= ({
{`Evyos = ({ }) => { const { toast } = useToast(); const router = useRouter(); - const [activeBuildingList, setActiveBuildingList] = React.useState([]); + const [activeBuildingList, setActiveBuildingList] = React.useState([]); const [activeOccupantList, setactiveOccupantList] = React.useState([]); const [isBuildingSelected, setIsBuildingSelected] = React.useState(false); const [selectedBuilding, setselectedBuilding] = React.useState(""); @@ -35,6 +35,7 @@ const LoginSelectOccupant: React.FC = ({ token: access_token, }) .then((responseData: any) => { + console.log("occupant", responseData); if (responseData?.completed) { showToast(toast, "Şirket seçimi", { message: "Şirket seçimi başarılı", @@ -64,7 +65,7 @@ const LoginSelectOccupant: React.FC = ({ activeBuildingList || [].some((item) => JSON.stringify(item) === JSON.stringify(building)); if (!isNotInList) { - setActiveBuildingList(activeBuildingList.push(building)); + setActiveBuildingList([...activeBuildingList, building]); } else if (activeBuildingList.length === 0) { setActiveBuildingList([building]); } diff --git a/src/components/login/loginwithemail.tsx b/src/components/login/loginwithemail.tsx index d8ed259..57df77b 100644 --- a/src/components/login/loginwithemail.tsx +++ b/src/components/login/loginwithemail.tsx @@ -1,5 +1,5 @@ "use client"; - +import React from "react"; import { useToast } from "@/hooks/use-toast"; import { Toaster } from "@/components/ui/toaster"; import { set, useForm } from "react-hook-form"; @@ -14,16 +14,12 @@ import { FormLabel, FormMessage, } from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; import { Switch } from "@/components/ui/switch"; -import { Button } from "@/components/ui/button"; -import { PasswordInput } from "@/components/ui/password-input"; import { useRouter } from "next/navigation"; import { showToast } from "./toaster"; import { login_via_access_keys } from "@/apicalls/login/login"; import { Link } from "lucide-react"; -import Image from "next/image"; const formSchema = z.object({ loginEmailInput: z @@ -42,10 +38,16 @@ const LoginWithEmail: React.FC = () => { const { toast } = useToast(); const router = useRouter(); + const [showPassword, setShowPassword] = React.useState(false); + const form = useForm>({ resolver: zodResolver(formSchema), }); + function changePwd() { + setShowPassword(!showPassword); + } + function onSubmit(values: z.infer) { login_via_access_keys({ domain: "evyos.com.tr", @@ -62,6 +64,11 @@ const LoginWithEmail: React.FC = () => { setTimeout(() => { router.push("/login/select"); }, 3000); + } else { + showToast(toast, "Giriş başarısız", { + message: res?.message, + data: res, + }); } }) .catch((error) => { @@ -81,23 +88,6 @@ const LoginWithEmail: React.FC = () => {
- - Logo - Logo - -

Lorem ipsum dolor sit amet, consectetur adipiscing elit suspendisse. @@ -230,9 +220,6 @@ const LoginWithEmail: React.FC = () => {

- - Start for free -

Mail ile Giriş Yap

@@ -257,6 +244,7 @@ const LoginWithEmail: React.FC = () => { placeholder="example@example.net" className="w-full rounded-lg border border-stroke bg-transparent py-4 pl-6 pr-10 text-black outline-none focus:border-primary focus-visible:shadow-none dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary" {...field} + value={field.value || ""} /> @@ -281,54 +269,35 @@ const LoginWithEmail: React.FC = () => {
- -
- - - - - - - -
- ( - - - - - - Şifrenizi giriniz - - - - )} - />
- + ( + + + + + + + )} + /> + {
@@ -414,7 +383,7 @@ const LoginWithEmail: React.FC = () => {
- Sign in with Google + Google ile giriş yap diff --git a/src/components/login/loginwithephone.tsx b/src/components/login/loginwithephone.tsx index 65489f5..83d49bc 100644 --- a/src/components/login/loginwithephone.tsx +++ b/src/components/login/loginwithephone.tsx @@ -18,6 +18,8 @@ import { import { PhoneInput } from "@/components/ui/phone-input"; import { PasswordInput } from "@/components/ui/password-input"; import { Switch } from "@/components/ui/switch"; +import { Link } from "lucide-react"; +import Image from "next/image"; import { useRouter } from "next/navigation"; import { showToast } from "./toaster"; @@ -50,79 +52,335 @@ const LoginWithPhone: React.FC = () => { return ( <> -
- - ( - - Phone number - - - - - Telefonunuzu girerek giriş yapabilirsiniz - - - - )} - /> +
+
+
+
+
+
+ + {/* Logo + Logo */} + - ( - - Şifre - - - - Şifrenizi giriniz - - - )} - /> +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit + suspendisse. +

- ( - -
- Beni Hatırla + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - - -
- )} - /> - - - - +
+ +
+
+

+ Telefon ile Giriş Yap +

+
+ +
+ +
+ ( + + + + + + + )} + /> + + + +
+
+ +
+ +
+ ( + + + + + + + )} + /> + + + + + + + + +
+
+ ( + +
+ + Beni Hatırla + +
+ + + +
+ )} + /> + +
+ +
+ + + + +
+ +
+
+
+
+
+
+
); diff --git a/src/components/password/ChangePassword.tsx b/src/components/password/ChangePassword.tsx new file mode 100644 index 0000000..6ae1d99 --- /dev/null +++ b/src/components/password/ChangePassword.tsx @@ -0,0 +1,417 @@ +"use client"; +import React from "react"; +import { useSearchParams } from "next/navigation"; +import * as z from "zod"; +import { useToast } from "@/hooks/use-toast"; +import { Toaster } from "@/components/ui/toaster"; +import { set, useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; + +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; + +import { useRouter } from "next/navigation"; +import { showToast } from "@/components/login/toaster"; +import { change_password_via_token } from "@/apicalls/login/password"; + +const formSchema = z.object({ + oldPassword: z.string().min(5, { message: "Şifre 6 karakterden az olamaz" }), + loginPassword: z + .string() + .min(5, { message: "Şifre 6 karakterden az olamaz" }) + .default(""), + repeatLoginPassword: z + .string() + .min(5, { message: "Şifre 6 karakterden az olamaz" }) + .default(""), +}); + +interface ChangePasswordProps { + accessToken: string; +} + +const ChangePassword: React.FC = ({ accessToken }) => { + const { toast } = useToast(); + const searchParams = useSearchParams(); + const router = useRouter(); + + const [showPassword, setShowPassword] = React.useState(false); + const [showRePassword, setshowRePassword] = React.useState(false); + const [showOldPassword, setshowOldPassword] = React.useState(false); + + function changePwd() { + setShowPassword(!showPassword); + } + + function changeRePwd() { + setshowRePassword(!showRePassword); + } + + function changeOldPwd() { + setshowOldPassword(!showOldPassword); + } + + const form = useForm>({ + resolver: zodResolver(formSchema), + }); + + function onSubmit(values: z.infer) { + if (values.loginPassword !== values.repeatLoginPassword) { + showToast(toast, "Giriş başarısız", { + message: "Şifreler eşleşmiyor", + }); + } else { + change_password_via_token({ + accessToken: accessToken || "", + oldPassword: values.oldPassword, + newPassword: values.loginPassword, + }) + .then((res: any) => { + if (res.status === 200) { + showToast(toast, "Giriş başarılı", { + message: res?.message, + data: res, + }); + setTimeout(() => { + router.push("/login/select"); + }, 1000); + } + showToast(toast, "Giriş başarısız", { + message: res?.error, + data: res, + }); + }) + .catch((error) => { + console.error(error); + showToast(toast, "Giriş başarısız", { + message: "Kullanıcı adı veya şifre hatalı", + data: JSON.stringify(error.code), + }); + }); + } + } + + return ( +
+
+
+
+
+
+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit + suspendisse. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+

+ Şifrenizi Değiştirin +

+
+ +
+ +
+ ( + + + + + + + )} + /> + + + + + + + + +
+
+ +
+ +
+ ( + + + + + + + )} + /> + + + + + + + + +
+
+
+ +
+ ( + + + + + + + )} + /> + + + + + + + + +
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+ ); +}; + +export default ChangePassword; diff --git a/src/components/password/CreatePassword.tsx b/src/components/password/CreatePassword.tsx new file mode 100644 index 0000000..d65233c --- /dev/null +++ b/src/components/password/CreatePassword.tsx @@ -0,0 +1,509 @@ +"use client"; +import React from "react"; +import { useSearchParams } from "next/navigation"; +import * as z from "zod"; +import { useToast } from "@/hooks/use-toast"; +import { Toaster } from "@/components/ui/toaster"; +import { set, useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; + +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; + +import { useRouter } from "next/navigation"; +import { showToast } from "@/components/login/toaster"; +import { create_password_via_token } from "@/apicalls/login/password"; + +const formSchema = z.object({ + loginPassword: z + .string() + .min(5, { message: "Şifre 6 karakterden az olamaz" }) + .default(""), + repeatLoginPassword: z + .string() + .min(5, { message: "Şifre 6 karakterden az olamaz" }) + .default(""), +}); + +const ChangePassword: React.FC = () => { + const { toast } = useToast(); + const searchParams = useSearchParams(); + const token = searchParams.get("tokenUrl") || ""; + const router = useRouter(); + + const [showPassword, setShowPassword] = React.useState(false); + const [showRePassword, setshowRePassword] = React.useState(false); + const [showOldPassword, setshowOldPassword] = React.useState(false); + + function changePwd() { + setShowPassword(!showPassword); + } + + function changeRePwd() { + setshowRePassword(!showRePassword); + } + + function changeOldPwd() { + setshowOldPassword(!showOldPassword); + } + + const form = useForm>({ + resolver: zodResolver(formSchema), + }); + + function onSubmit(values: z.infer) { + if (values.loginPassword !== values.repeatLoginPassword) { + showToast(toast, "Giriş başarısız", { + message: "Şifreler eşleşmiyor", + }); + } else { + create_password_via_token({ + token: token || "", + password: values.loginPassword, + rePassword: values.repeatLoginPassword, + }) + .then((res: any) => { + if (res.status === 200) { + showToast(toast, "Giriş başarılı", { + message: res?.message, + data: res, + }); + setTimeout(() => { + router.push("/login/select"); + }, 1000); + } + showToast(toast, "Giriş başarısız", { + message: res?.error, + data: res, + }); + }) + .catch((error) => { + console.error(error); + showToast(toast, "Giriş başarısız", { + message: "Kullanıcı adı veya şifre hatalı", + data: JSON.stringify(error.code), + }); + }); + } + } + + return ( +
+ {token ? ( +
+
+
+
+
+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit + suspendisse. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+

+ Şifrenizi Değiştirin +

+
+ +
+ +
+ ( + + + + + + + )} + /> + + + + + + + + +
+
+
+ +
+ ( + + + + + + + )} + /> + + + + + + + + +
+
+
+ +
+
+ +
+
+
+
+
+
+ ) : ( +
+
+
+
+
+
+

+ Şifre değiştirme tokeniniz geçersiz veya süresi dolmuş + olabilir. Lütfen tekrar şifre değiştirme talebinde + bulunun. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ )} + + +
+ ); +}; + +export default ChangePassword;