events updated
This commit is contained in:
parent
0631ec3961
commit
e653685161
|
|
@ -1,5 +1,7 @@
|
||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
|
import { retrieveAccessToken } from "@/(apicalls)/cookies/token";
|
||||||
|
|
||||||
const defaultHeaders = {
|
const defaultHeaders = {
|
||||||
accept: "application/json",
|
accept: "application/json",
|
||||||
"Content-type": "application/json",
|
"Content-type": "application/json",
|
||||||
|
|
@ -20,6 +22,8 @@ interface HeadersObject {
|
||||||
body?: string;
|
body?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cacheList = ["no-cache", "no-store", "force-cache", "only-if-cached"];
|
||||||
|
|
||||||
const prepareResponse = async (response: any) => {
|
const prepareResponse = async (response: any) => {
|
||||||
try {
|
try {
|
||||||
const responseJson = await response.json();
|
const responseJson = await response.json();
|
||||||
|
|
@ -27,7 +31,7 @@ const prepareResponse = async (response: any) => {
|
||||||
const errorResponse = responseJson?.error || responseJson?.Error;
|
const errorResponse = responseJson?.error || responseJson?.Error;
|
||||||
const messageResponse = (responseJson?.message || "").toString();
|
const messageResponse = (responseJson?.message || "").toString();
|
||||||
const completeResponse = responseJson?.completed;
|
const completeResponse = responseJson?.completed;
|
||||||
|
|
||||||
const preparedResponse = {
|
const preparedResponse = {
|
||||||
completed: completeResponse,
|
completed: completeResponse,
|
||||||
message: messageResponse,
|
message: messageResponse,
|
||||||
|
|
@ -48,7 +52,7 @@ const fetchData = async (
|
||||||
cache: boolean = false
|
cache: boolean = false
|
||||||
) => {
|
) => {
|
||||||
let headersObject: any = {
|
let headersObject: any = {
|
||||||
cache: cache ? "force-cache" : "no-store",
|
cache: cache ? "force-cache" : "no-cache",
|
||||||
method: method,
|
method: method,
|
||||||
headers: defaultHeaders,
|
headers: defaultHeaders,
|
||||||
};
|
};
|
||||||
|
|
@ -67,17 +71,17 @@ const fetchData = async (
|
||||||
|
|
||||||
const fetchDataWithToken = async (
|
const fetchDataWithToken = async (
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
token: string,
|
|
||||||
payload: any,
|
payload: any,
|
||||||
method: string = "POST",
|
method: string = "POST",
|
||||||
cache: boolean = false
|
cache: boolean = false
|
||||||
) => {
|
) => {
|
||||||
|
const accessToken = (await retrieveAccessToken()) || "";
|
||||||
let headersObject: any = {
|
let headersObject: any = {
|
||||||
cache: cache ? "force-cache" : "no-store",
|
cache: cache ? "force-cache" : "no-cache",
|
||||||
method: method,
|
method: method,
|
||||||
headers: {
|
headers: {
|
||||||
...defaultHeaders,
|
...defaultHeaders,
|
||||||
"evyos-session-key": token,
|
"evyos-session-key": accessToken,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (method !== "GET") {
|
if (method !== "GET") {
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
export const baseUrl = "http://0.0.0.0:41575";
|
||||||
|
export const tokenSecret =
|
||||||
|
"SyIkoYIK5JLD2cuRB0hnB-1zcj5FB5oxbB73ph-Oe3Kn0WWeSOjnWAuzzi6ZUX_5TpFF0-KGpKDZepaUhVEmmdaY5E-_sI3b9UwfN_eg-KgtpCiiWiHADSu9bRSBez_ZI4AFkeNK0LSRWpqq9El6V3pauvgsKJU_ZXwplIW49Y8";
|
||||||
|
export const cookieObject: any = {
|
||||||
|
httpOnly: true,
|
||||||
|
path: "/",
|
||||||
|
secure: true,
|
||||||
|
sameSite: "strict",
|
||||||
|
// maxAge: 3600,
|
||||||
|
};
|
||||||
|
|
||||||
|
interface FilterListInterface {
|
||||||
|
page?: number;
|
||||||
|
size?: number;
|
||||||
|
order_field?: string;
|
||||||
|
order_type?: string;
|
||||||
|
include_joins?: any[];
|
||||||
|
query?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
class FilterList {
|
||||||
|
page?: number = 1;
|
||||||
|
size?: number = 5;
|
||||||
|
order_field?: string = "id";
|
||||||
|
order_type?: string = "asc";
|
||||||
|
include_joins?: any[] = [];
|
||||||
|
|
||||||
|
query?: any;
|
||||||
|
constructor({
|
||||||
|
page,
|
||||||
|
size,
|
||||||
|
order_field,
|
||||||
|
order_type,
|
||||||
|
include_joins,
|
||||||
|
query,
|
||||||
|
}: FilterListInterface) {
|
||||||
|
this.page = page || 1;
|
||||||
|
this.size = size || 5;
|
||||||
|
this.order_field = order_field || "id";
|
||||||
|
this.order_type = order_type || "asc";
|
||||||
|
this.include_joins = include_joins || [];
|
||||||
|
this.query = query || {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { FilterList };
|
||||||
|
export type { FilterListInterface };
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
"use server";
|
||||||
|
import { fetchData, fetchDataWithToken } from "../api-fetcher";
|
||||||
|
import { baseUrl, FilterList, FilterListInterface } from "../basics";
|
||||||
|
|
||||||
|
const buildListEndpoint = `${baseUrl}/building/build/list`;
|
||||||
|
|
||||||
|
async function retrieveBuildList(payload: FilterListInterface) {
|
||||||
|
const feedObject = new FilterList(payload);
|
||||||
|
const tokenResponse: any = await fetchDataWithToken(
|
||||||
|
buildListEndpoint,
|
||||||
|
feedObject,
|
||||||
|
"POST",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
return tokenResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { retrieveBuildList };
|
||||||
|
|
@ -1,29 +1,18 @@
|
||||||
"use server";
|
"use server";
|
||||||
import { fetchDataWithToken } from "../api-fetcher";
|
import { fetchDataWithToken } from "../api-fetcher";
|
||||||
|
import { baseUrl, tokenSecret } from "../basics";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { baseUrl, cookieObject, tokenSecret } from "@/apicalls/basics";
|
|
||||||
import NextCrypto from "next-crypto";
|
import NextCrypto from "next-crypto";
|
||||||
|
|
||||||
const checkToken = `${baseUrl}/authentication/valid`;
|
const checkToken = `${baseUrl}/authentication/valid`;
|
||||||
const nextCrypto = new NextCrypto(tokenSecret);
|
const nextCrypto = new NextCrypto(tokenSecret);
|
||||||
|
|
||||||
async function check_access_token_is_valid() {
|
async function checkAccessTokenIsValid() {
|
||||||
const cookieStore = await cookies();
|
const response = await fetchDataWithToken(checkToken, {}, "GET", false);
|
||||||
const encrpytAccessToken = cookieStore.get("accessToken")?.value || "";
|
|
||||||
const decryptedAccessToken =
|
|
||||||
(await nextCrypto.decrypt(encrpytAccessToken)) || "";
|
|
||||||
|
|
||||||
const response = await fetchDataWithToken(
|
|
||||||
checkToken,
|
|
||||||
decryptedAccessToken,
|
|
||||||
{},
|
|
||||||
"GET",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
return response?.status === 200 ? true : false;
|
return response?.status === 200 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retrieve_access_token() {
|
async function retrieveAccessToken() {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const encrpytAccessToken = cookieStore.get("accessToken")?.value || "";
|
const encrpytAccessToken = cookieStore.get("accessToken")?.value || "";
|
||||||
return encrpytAccessToken
|
return encrpytAccessToken
|
||||||
|
|
@ -31,7 +20,7 @@ async function retrieve_access_token() {
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retrieve_user_type() {
|
async function retrieveUserType() {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const encrpytaccessObject = cookieStore.get("accessObject")?.value || "{}";
|
const encrpytaccessObject = cookieStore.get("accessObject")?.value || "{}";
|
||||||
const decrpytUserType = JSON.parse(
|
const decrpytUserType = JSON.parse(
|
||||||
|
|
@ -40,14 +29,14 @@ async function retrieve_user_type() {
|
||||||
return decrpytUserType ? decrpytUserType?.user_type : null;
|
return decrpytUserType ? decrpytUserType?.user_type : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retrieve_access_objects() {
|
async function retrieveAccessObjects() {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const encrpytAccessObject = cookieStore.get("accessObject")?.value || "";
|
const encrpytAccessObject = cookieStore.get("accessObject")?.value || "";
|
||||||
const decrpytAccessObject = await nextCrypto.decrypt(encrpytAccessObject);
|
const decrpytAccessObject = await nextCrypto.decrypt(encrpytAccessObject);
|
||||||
return decrpytAccessObject ? JSON.parse(decrpytAccessObject) : null;
|
return decrpytAccessObject ? JSON.parse(decrpytAccessObject) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retrieve_available_events() {
|
async function retrieveAvailableEvents() {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const encrpytAccessObject = cookieStore.get("availableEvents")?.value || "";
|
const encrpytAccessObject = cookieStore.get("availableEvents")?.value || "";
|
||||||
const decrpytAccessObject = await nextCrypto.decrypt(encrpytAccessObject);
|
const decrpytAccessObject = await nextCrypto.decrypt(encrpytAccessObject);
|
||||||
|
|
@ -55,9 +44,9 @@ async function retrieve_available_events() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
check_access_token_is_valid,
|
checkAccessTokenIsValid,
|
||||||
retrieve_access_token,
|
retrieveAccessToken,
|
||||||
retrieve_user_type,
|
retrieveUserType,
|
||||||
retrieve_access_objects,
|
retrieveAccessObjects,
|
||||||
retrieve_available_events,
|
retrieveAvailableEvents,
|
||||||
};
|
};
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
"use server";
|
||||||
|
import { fetchDataWithToken } from "../api-fetcher";
|
||||||
|
import { baseUrl } from "../basics";
|
||||||
|
|
||||||
|
const eventList = `${baseUrl}/event/list`;
|
||||||
|
|
||||||
|
async function retrieveEventList() {
|
||||||
|
return await fetchDataWithToken(eventList, {}, "GET", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { retrieveEventList };
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
"use server";
|
"use server";
|
||||||
import { fetchDataWithToken } from "../api-fetcher";
|
import { fetchDataWithToken } from "../api-fetcher";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { baseUrl, cookieObject, tokenSecret } from "@/apicalls/basics";
|
import { baseUrl, cookieObject, tokenSecret } from "../basics";
|
||||||
import NextCrypto from "next-crypto";
|
import NextCrypto from "next-crypto";
|
||||||
|
|
||||||
const availableEventsURL = `${baseUrl}/access/endpoints/available`;
|
const availableEventsURL = `${baseUrl}/access/endpoints/available`;
|
||||||
|
|
||||||
async function setAvailableEvents(accessToken: string) {
|
async function setAvailableEvents() {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const nextCrypto = new NextCrypto(tokenSecret);
|
const nextCrypto = new NextCrypto(tokenSecret);
|
||||||
|
|
||||||
const availableResponse: any = await fetchDataWithToken(
|
const availableResponse: any = await fetchDataWithToken(
|
||||||
availableEventsURL,
|
availableEventsURL,
|
||||||
accessToken,
|
|
||||||
{},
|
{},
|
||||||
"POST",
|
"POST",
|
||||||
false
|
false
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
"use server";
|
"use server";
|
||||||
import { fetchData, fetchDataWithToken } from "../api-fetcher";
|
import { fetchData, fetchDataWithToken } from "../api-fetcher";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { baseUrl, cookieObject, tokenSecret } from "@/apicalls/basics";
|
import { baseUrl, cookieObject, tokenSecret } from "../basics";
|
||||||
import NextCrypto from "next-crypto";
|
import NextCrypto from "next-crypto";
|
||||||
|
import { setAvailableEvents } from "../events/available";
|
||||||
|
|
||||||
const loginEndpoint = `${baseUrl}/authentication/login`;
|
const loginEndpoint = `${baseUrl}/authentication/login`;
|
||||||
const loginSelectEndpoint = `${baseUrl}/authentication/select`;
|
const loginSelectEndpoint = `${baseUrl}/authentication/select`;
|
||||||
|
|
@ -15,17 +16,15 @@ interface LoginViaAccessKeys {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LoginSelectEmployee {
|
interface LoginSelectEmployee {
|
||||||
token: string;
|
|
||||||
company_uu_id: string;
|
company_uu_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LoginSelectOccupant {
|
interface LoginSelectOccupant {
|
||||||
token: string;
|
|
||||||
build_part_uu_id: string;
|
build_part_uu_id: string;
|
||||||
occupant_uu_id: string;
|
occupant_uu_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function login_via_access_keys(payload: LoginViaAccessKeys) {
|
async function loginViaAccessKeys(payload: LoginViaAccessKeys) {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const nextCrypto = new NextCrypto(tokenSecret);
|
const nextCrypto = new NextCrypto(tokenSecret);
|
||||||
|
|
||||||
|
|
@ -83,13 +82,12 @@ async function login_via_access_keys(payload: LoginViaAccessKeys) {
|
||||||
return tokenResponse;
|
return tokenResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function login_select_employee(payload: LoginSelectEmployee) {
|
async function loginSelectEmployee(payload: LoginSelectEmployee) {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const nextCrypto = new NextCrypto(tokenSecret);
|
const nextCrypto = new NextCrypto(tokenSecret);
|
||||||
|
|
||||||
const selectResponse: any = await fetchDataWithToken(
|
const selectResponse: any = await fetchDataWithToken(
|
||||||
loginSelectEndpoint,
|
loginSelectEndpoint,
|
||||||
payload.token,
|
|
||||||
{
|
{
|
||||||
company_uu_id: payload.company_uu_id,
|
company_uu_id: payload.company_uu_id,
|
||||||
},
|
},
|
||||||
|
|
@ -108,16 +106,16 @@ async function login_select_employee(payload: LoginSelectEmployee) {
|
||||||
value: usersSelection,
|
value: usersSelection,
|
||||||
...cookieObject,
|
...cookieObject,
|
||||||
});
|
});
|
||||||
|
await setAvailableEvents();
|
||||||
}
|
}
|
||||||
return selectResponse;
|
return selectResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function login_select_occupant(payload: LoginSelectOccupant) {
|
async function loginSelectOccupant(payload: LoginSelectOccupant) {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const nextCrypto = new NextCrypto(tokenSecret);
|
const nextCrypto = new NextCrypto(tokenSecret);
|
||||||
const selectResponse: any = await fetchDataWithToken(
|
const selectResponse: any = await fetchDataWithToken(
|
||||||
loginSelectEndpoint,
|
loginSelectEndpoint,
|
||||||
payload.token,
|
|
||||||
{
|
{
|
||||||
build_part_uu_id: payload.build_part_uu_id,
|
build_part_uu_id: payload.build_part_uu_id,
|
||||||
occupant_uu_id: payload.occupant_uu_id,
|
occupant_uu_id: payload.occupant_uu_id,
|
||||||
|
|
@ -140,8 +138,9 @@ async function login_select_occupant(payload: LoginSelectOccupant) {
|
||||||
value: usersSelection,
|
value: usersSelection,
|
||||||
...cookieObject,
|
...cookieObject,
|
||||||
});
|
});
|
||||||
|
await setAvailableEvents();
|
||||||
}
|
}
|
||||||
return selectResponse;
|
return selectResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { login_via_access_keys, login_select_employee, login_select_occupant };
|
export { loginViaAccessKeys, loginSelectEmployee, loginSelectOccupant };
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
"use server";
|
"use server";
|
||||||
import { fetchDataWithToken } from "../api-fetcher";
|
import { fetchDataWithToken } from "../api-fetcher";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { baseUrl } from "@/apicalls/basics";
|
import { baseUrl } from "../basics";
|
||||||
|
|
||||||
const logOutEndpoint = `${baseUrl}/authentication/logout`;
|
const logOutEndpoint = `${baseUrl}/authentication/logout`;
|
||||||
const logOutAllEndpoint = `${baseUrl}/authentication/disconnect`;
|
const logOutAllEndpoint = `${baseUrl}/authentication/disconnect`;
|
||||||
|
|
||||||
interface LoginOutUser {
|
interface LoginOutUser {
|
||||||
token: string;
|
|
||||||
domain: string;
|
domain: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logout_active_session(payload: LoginOutUser) {
|
async function logoutActiveSession(payload: LoginOutUser) {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
cookieStore.delete("accessToken");
|
cookieStore.delete("accessToken");
|
||||||
cookieStore.delete("accessObject");
|
cookieStore.delete("accessObject");
|
||||||
|
|
@ -20,7 +19,6 @@ async function logout_active_session(payload: LoginOutUser) {
|
||||||
|
|
||||||
const tokenResponse: any = await fetchDataWithToken(
|
const tokenResponse: any = await fetchDataWithToken(
|
||||||
logOutEndpoint,
|
logOutEndpoint,
|
||||||
payload.token,
|
|
||||||
{
|
{
|
||||||
domain: payload.domain,
|
domain: payload.domain,
|
||||||
},
|
},
|
||||||
|
|
@ -33,7 +31,7 @@ async function logout_active_session(payload: LoginOutUser) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logout_all_sessions(payload: LoginOutUser) {
|
async function logoutAllSessions(payload: LoginOutUser) {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
cookieStore.delete("accessToken");
|
cookieStore.delete("accessToken");
|
||||||
cookieStore.delete("accessObject");
|
cookieStore.delete("accessObject");
|
||||||
|
|
@ -41,7 +39,6 @@ async function logout_all_sessions(payload: LoginOutUser) {
|
||||||
cookieStore.delete("userSelection");
|
cookieStore.delete("userSelection");
|
||||||
const tokenResponse: any = await fetchDataWithToken(
|
const tokenResponse: any = await fetchDataWithToken(
|
||||||
logOutAllEndpoint,
|
logOutAllEndpoint,
|
||||||
payload.token,
|
|
||||||
{
|
{
|
||||||
domain: payload.domain,
|
domain: payload.domain,
|
||||||
},
|
},
|
||||||
|
|
@ -54,4 +51,4 @@ async function logout_all_sessions(payload: LoginOutUser) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { logout_active_session, logout_all_sessions };
|
export { logoutActiveSession, logoutAllSessions };
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use server";
|
"use server";
|
||||||
import { fetchData, fetchDataWithToken } from "../api-fetcher";
|
import { fetchData, fetchDataWithToken } from "../api-fetcher";
|
||||||
import { baseUrl } from "@/apicalls/basics";
|
import { baseUrl } from "../basics";
|
||||||
|
|
||||||
const createPasswordEndpoint = `${baseUrl}/authentication/create_password`;
|
const createPasswordEndpoint = `${baseUrl}/authentication/create_password`;
|
||||||
const changePasswordEndpoint = `${baseUrl}/authentication/change_password`;
|
const changePasswordEndpoint = `${baseUrl}/authentication/change_password`;
|
||||||
|
|
@ -13,7 +13,6 @@ interface createPasswordViaToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface changePasswordViaToken {
|
interface changePasswordViaToken {
|
||||||
accessToken: string;
|
|
||||||
oldPassword: string;
|
oldPassword: string;
|
||||||
newPassword: string;
|
newPassword: string;
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +39,6 @@ async function create_password_via_token(payload: createPasswordViaToken) {
|
||||||
async function change_password_via_token(payload: changePasswordViaToken) {
|
async function change_password_via_token(payload: changePasswordViaToken) {
|
||||||
const changePasswordResponse: any = await fetchDataWithToken(
|
const changePasswordResponse: any = await fetchDataWithToken(
|
||||||
changePasswordEndpoint,
|
changePasswordEndpoint,
|
||||||
payload.accessToken,
|
|
||||||
{
|
{
|
||||||
old_password: payload.oldPassword,
|
old_password: payload.oldPassword,
|
||||||
new_password: payload.newPassword,
|
new_password: payload.newPassword,
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
export const baseUrl = "http://0.0.0.0:41575";
|
|
||||||
export const tokenSecret =
|
|
||||||
"SyIkoYIK5JLD2cuRB0hnB-1zcj5FB5oxbB73ph-Oe3Kn0WWeSOjnWAuzzi6ZUX_5TpFF0-KGpKDZepaUhVEmmdaY5E-_sI3b9UwfN_eg-KgtpCiiWiHADSu9bRSBez_ZI4AFkeNK0LSRWpqq9El6V3pauvgsKJU_ZXwplIW49Y8";
|
|
||||||
export const cookieObject: any = {
|
|
||||||
httpOnly: true,
|
|
||||||
path: "/",
|
|
||||||
secure: true,
|
|
||||||
sameSite: "strict",
|
|
||||||
// maxAge: 3600,
|
|
||||||
};
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
"use server";
|
|
||||||
import { fetchDataWithToken } from "../api-fetcher";
|
|
||||||
import { cookies } from "next/headers";
|
|
||||||
import { baseUrl, cookieObject, tokenSecret } from "@/apicalls/basics";
|
|
||||||
import NextCrypto from "next-crypto";
|
|
||||||
|
|
||||||
const eventList = `${baseUrl}/event/list`;
|
|
||||||
const nextCrypto = new NextCrypto(tokenSecret);
|
|
||||||
|
|
||||||
async function retrieve_event_list() {
|
|
||||||
const cookieStore = await cookies();
|
|
||||||
const encrpytAccessToken = cookieStore.get("accessToken")?.value || "";
|
|
||||||
const decryptedAccessToken =
|
|
||||||
(await nextCrypto.decrypt(encrpytAccessToken)) || "";
|
|
||||||
|
|
||||||
const response = await fetchDataWithToken(
|
|
||||||
eventList,
|
|
||||||
decryptedAccessToken,
|
|
||||||
{},
|
|
||||||
"GET",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
console.log("response", response);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
export { retrieve_event_list };
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const BuildPage: React.FC = async () => {
|
const BuildPage: React.FC = async () => {
|
||||||
|
|
|
||||||
|
|
@ -2,29 +2,24 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import {
|
import {
|
||||||
check_access_token_is_valid,
|
checkAccessTokenIsValid,
|
||||||
retrieve_access_token,
|
retrieveAvailableEvents,
|
||||||
retrieve_available_events,
|
} from "@/(apicalls)/cookies/token";
|
||||||
} from "@/apicalls/cookies/token";
|
|
||||||
import DashboardPage from "@/components/Dashboards/DashboardPage";
|
import DashboardPage from "@/components/Dashboards/DashboardPage";
|
||||||
import { retrieveAvailableCategories } from "@/appEvents/categories";
|
import { retrieveAvailableCategories } from "@/appEvents/categories";
|
||||||
|
|
||||||
const Dashboard: React.FC = async () => {
|
const Dashboard: React.FC = async () => {
|
||||||
const accessToken = (await retrieve_access_token()) || "";
|
const token_is_valid = await checkAccessTokenIsValid();
|
||||||
const token_is_valid = await check_access_token_is_valid();
|
|
||||||
if (!token_is_valid) {
|
if (!token_is_valid) {
|
||||||
redirect("/login/email");
|
redirect("/login/email");
|
||||||
}
|
}
|
||||||
|
const eventsList = await retrieveAvailableEvents();
|
||||||
const eventsList = await retrieve_available_events();
|
const availableMenu = retrieveAvailableCategories(eventsList || []);
|
||||||
const availableMenu = retrieveAvailableCategories(eventsList);
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
<DashboardPage
|
<DashboardPage leftSideMenuContent={availableMenu} />
|
||||||
accessToken={accessToken}
|
</>
|
||||||
leftSideMenuContent={availableMenu}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
"use server";
|
"use server";
|
||||||
import LoginWithEmail from "@/components/login/loginwithemail";
|
import LoginWithEmail from "@/components/login/loginwithemail";
|
||||||
import { check_access_token_is_valid } from "@/apicalls/cookies/token";
|
import { checkAccessTokenIsValid } from "@/(apicalls)/cookies/token";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function MyForm() {
|
export default async function MyForm() {
|
||||||
const token_is_valid = await check_access_token_is_valid();
|
const token_is_valid = await checkAccessTokenIsValid();
|
||||||
if (token_is_valid) {
|
if (token_is_valid) {
|
||||||
redirect("/login/select");
|
redirect("/login/select");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import LoginWithPhone from "@/components/login/loginwithephone";
|
import LoginWithPhone from "@/components/login/loginwithephone";
|
||||||
import Image from "next/image";
|
import { checkAccessTokenIsValid } from "@/(apicalls)/cookies/token";
|
||||||
import { check_access_token_is_valid } from "@/apicalls/cookies/token";
|
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function MyForm() {
|
export default async function MyForm() {
|
||||||
const token_is_valid = await check_access_token_is_valid();
|
const token_is_valid = await checkAccessTokenIsValid();
|
||||||
if (token_is_valid) {
|
if (token_is_valid) {
|
||||||
redirect("/login/select");
|
redirect("/login/select");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,14 @@ import React from "react";
|
||||||
import LoginEmployeeCard from "@/components/login/loginemployee";
|
import LoginEmployeeCard from "@/components/login/loginemployee";
|
||||||
import LoginOccupantCard from "@/components/login/loginoccupant";
|
import LoginOccupantCard from "@/components/login/loginoccupant";
|
||||||
import {
|
import {
|
||||||
check_access_token_is_valid,
|
checkAccessTokenIsValid,
|
||||||
retrieve_user_type,
|
retrieveUserType,
|
||||||
} from "@/apicalls/cookies/token";
|
} from "@/(apicalls)/cookies/token";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
const SelectPage: React.FC = async () => {
|
const SelectPage: React.FC = async () => {
|
||||||
const token_is_valid = await check_access_token_is_valid();
|
const token_is_valid = await checkAccessTokenIsValid();
|
||||||
const userType = await retrieve_user_type();
|
const userType = await retrieveUserType();
|
||||||
if (!userType || !token_is_valid) {
|
if (!userType || !token_is_valid) {
|
||||||
redirect("/login/email");
|
redirect("/login/email");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,18 @@
|
||||||
"use server";
|
"use server";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { checkAccessTokenIsValid } from "@/(apicalls)/cookies/token";
|
||||||
import {
|
|
||||||
retrieve_access_token,
|
|
||||||
check_access_token_is_valid,
|
|
||||||
} from "@/apicalls/cookies/token";
|
|
||||||
import ChangePassword from "@/components/password/ChangePassword";
|
import ChangePassword from "@/components/password/ChangePassword";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
const ChangePasswordPage: React.FC = async () => {
|
const ChangePasswordPage: React.FC = async () => {
|
||||||
const token_is_valid = await check_access_token_is_valid();
|
const token_is_valid = await checkAccessTokenIsValid();
|
||||||
if (!token_is_valid) {
|
if (!token_is_valid) {
|
||||||
redirect("/login/email");
|
redirect("/login/email");
|
||||||
}
|
}
|
||||||
const accessToken = (await retrieve_access_token()) || "";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ChangePassword accessToken={accessToken} />
|
<ChangePassword />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
const AccountIcon = (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-landmark"
|
||||||
|
>
|
||||||
|
<line x1="3" x2="21" y1="22" y2="22" />
|
||||||
|
<line x1="6" x2="6" y1="18" y2="11" />
|
||||||
|
<line x1="10" x2="10" y1="18" y2="11" />
|
||||||
|
<line x1="14" x2="14" y1="18" y2="11" />
|
||||||
|
<line x1="18" x2="18" y1="18" y2="11" />
|
||||||
|
<polygon points="12 2 20 7 4 7" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
const meetingIcon = (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-logs"
|
||||||
|
>
|
||||||
|
<path d="M13 12h8" />
|
||||||
|
<path d="M13 18h8" />
|
||||||
|
<path d="M13 6h8" />
|
||||||
|
<path d="M3 12h1" />
|
||||||
|
<path d="M3 18h1" />
|
||||||
|
<path d="M3 6h1" />
|
||||||
|
<path d="M8 12h1" />
|
||||||
|
<path d="M8 18h1" />
|
||||||
|
<path d="M8 6h1" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export { AccountIcon, meetingIcon };
|
||||||
|
|
@ -1,33 +1,87 @@
|
||||||
import exp from "constants";
|
|
||||||
|
|
||||||
const BuildIcon = (
|
const BuildIcon = (
|
||||||
<>
|
<>
|
||||||
<svg
|
<svg
|
||||||
className="fill-current"
|
|
||||||
width="18"
|
|
||||||
height="18"
|
|
||||||
viewBox="0 0 18 18"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-hotel"
|
||||||
>
|
>
|
||||||
<path
|
<path d="M10 22v-6.57" />
|
||||||
d="M6.10322 0.956299H2.53135C1.5751 0.956299 0.787598 1.7438 0.787598 2.70005V6.27192C0.787598 7.22817 1.5751 8.01567 2.53135 8.01567H6.10322C7.05947 8.01567 7.84697 7.22817 7.84697 6.27192V2.72817C7.8751 1.7438 7.0876 0.956299 6.10322 0.956299ZM6.60947 6.30005C6.60947 6.5813 6.38447 6.8063 6.10322 6.8063H2.53135C2.2501 6.8063 2.0251 6.5813 2.0251 6.30005V2.72817C2.0251 2.44692 2.2501 2.22192 2.53135 2.22192H6.10322C6.38447 2.22192 6.60947 2.44692 6.60947 2.72817V6.30005Z"
|
<path d="M12 11h.01" />
|
||||||
fill=""
|
<path d="M12 7h.01" />
|
||||||
/>
|
<path d="M14 15.43V22" />
|
||||||
<path
|
<path d="M15 16a5 5 0 0 0-6 0" />
|
||||||
d="M15.4689 0.956299H11.8971C10.9408 0.956299 10.1533 1.7438 10.1533 2.70005V6.27192C10.1533 7.22817 10.9408 8.01567 11.8971 8.01567H15.4689C16.4252 8.01567 17.2127 7.22817 17.2127 6.27192V2.72817C17.2127 1.7438 16.4252 0.956299 15.4689 0.956299ZM15.9752 6.30005C15.9752 6.5813 15.7502 6.8063 15.4689 6.8063H11.8971C11.6158 6.8063 11.3908 6.5813 11.3908 6.30005V2.72817C11.3908 2.44692 11.6158 2.22192 11.8971 2.22192H15.4689C15.7502 2.22192 15.9752 2.44692 15.9752 2.72817V6.30005Z"
|
<path d="M16 11h.01" />
|
||||||
fill=""
|
<path d="M16 7h.01" />
|
||||||
/>
|
<path d="M8 11h.01" />
|
||||||
<path
|
<path d="M8 7h.01" />
|
||||||
d="M6.10322 9.92822H2.53135C1.5751 9.92822 0.787598 10.7157 0.787598 11.672V15.2438C0.787598 16.2001 1.5751 16.9876 2.53135 16.9876H6.10322C7.05947 16.9876 7.84697 16.2001 7.84697 15.2438V11.7001C7.8751 10.7157 7.0876 9.92822 6.10322 9.92822ZM6.60947 15.272C6.60947 15.5532 6.38447 15.7782 6.10322 15.7782H2.53135C2.2501 15.7782 2.0251 15.5532 2.0251 15.272V11.7001C2.0251 11.4188 2.2501 11.1938 2.53135 11.1938H6.10322C6.38447 11.1938 6.60947 11.4188 6.60947 11.7001V15.272Z"
|
<rect x="4" y="2" width="16" height="20" rx="2" />
|
||||||
fill=""
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M15.4689 9.92822H11.8971C10.9408 9.92822 10.1533 10.7157 10.1533 11.672V15.2438C10.1533 16.2001 10.9408 16.9876 11.8971 16.9876H15.4689C16.4252 16.9876 17.2127 16.2001 17.2127 15.2438V11.7001C17.2127 10.7157 16.4252 9.92822 15.4689 9.92822ZM15.9752 15.272C15.9752 15.5532 15.7502 15.7782 15.4689 15.7782H11.8971C11.6158 15.7782 11.3908 15.5532 11.3908 15.272V11.7001C11.3908 11.4188 11.6158 11.1938 11.8971 11.1938H15.4689C15.7502 11.1938 15.9752 11.4188 15.9752 11.7001V15.272Z"
|
|
||||||
fill=""
|
|
||||||
/>
|
|
||||||
</svg>
|
</svg>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default BuildIcon;
|
const BuildPartIcon = (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-door-open"
|
||||||
|
>
|
||||||
|
<path d="M13 4h3a2 2 0 0 1 2 2v14" />
|
||||||
|
<path d="M2 20h3" />
|
||||||
|
<path d="M13 20h9" />
|
||||||
|
<path d="M10 12v.01" />
|
||||||
|
<path d="M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
const LivingSpaceIcon = (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-users-round"
|
||||||
|
>
|
||||||
|
<path d="M18 21a8 8 0 0 0-16 0" />
|
||||||
|
<circle cx="10" cy="8" r="5" />
|
||||||
|
<path d="M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
const BuildAreaIcon = (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-tree-pine"
|
||||||
|
>
|
||||||
|
<path d="m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z" />
|
||||||
|
<path d="M12 22v-3" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export { BuildIcon, BuildPartIcon, LivingSpaceIcon, BuildAreaIcon };
|
||||||
|
|
|
||||||
|
|
@ -1,88 +1,48 @@
|
||||||
import { title } from "process";
|
import {
|
||||||
import BuildIcon from "./building/iconSet";
|
BuildIcon,
|
||||||
|
BuildPartIcon,
|
||||||
|
LivingSpaceIcon,
|
||||||
|
BuildAreaIcon,
|
||||||
|
} from "./building/iconSet";
|
||||||
|
import { AccountIcon, meetingIcon } from "./account/iconSet";
|
||||||
import BuildPage from "./building/build";
|
import BuildPage from "./building/build";
|
||||||
|
import { InviteIcon, TaskIcon } from "./decisionBook/iconSet";
|
||||||
const LeftMenuCategoriesSecond = [
|
|
||||||
{
|
|
||||||
title: "Daireler",
|
|
||||||
icon: "apartment",
|
|
||||||
firstLayer: false,
|
|
||||||
selfEndpoints: [],
|
|
||||||
subCategories: [],
|
|
||||||
allEndpointUUID: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Kullanılabilir Alanlar",
|
|
||||||
icon: "area",
|
|
||||||
selfEndpoints: [],
|
|
||||||
subCategories: [],
|
|
||||||
allEndpointUUID: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Yaşayan Kişiler",
|
|
||||||
icon: "person",
|
|
||||||
selfEndpoints: [],
|
|
||||||
subCategories: [],
|
|
||||||
allEndpointUUID: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Davetiyeler",
|
|
||||||
icon: "invitation",
|
|
||||||
selfEndpoints: [],
|
|
||||||
subCategories: [],
|
|
||||||
allEndpointUUID: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Görev Ata",
|
|
||||||
icon: "task",
|
|
||||||
selfEndpoints: [],
|
|
||||||
subCategories: [],
|
|
||||||
allEndpointUUID: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Bakiye Sorgulama",
|
|
||||||
icon: "balance",
|
|
||||||
subCategories: [],
|
|
||||||
selfEndpoints: [],
|
|
||||||
allEndpointUUID: ["/account/records/list"],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const BuildSubCategories = [
|
const BuildSubCategories = [
|
||||||
{
|
{
|
||||||
title: "Daireler",
|
title: "Daireler",
|
||||||
icon: "apartment",
|
icon: BuildPartIcon,
|
||||||
component: "BuildPart",
|
component: BuildPage,
|
||||||
selfEndpoints: [
|
selfEndpoints: [
|
||||||
"/building/parts/list",
|
"/building/parts/list",
|
||||||
"/building/parts/create",
|
"/building/parts/create",
|
||||||
"/building/parts/update/{build_uu_id}",
|
"/building/parts/update/{build_uu_id}",
|
||||||
],
|
],
|
||||||
allEndpointUUID: [],
|
allEndpoints: [],
|
||||||
subCategories: [],
|
subCategories: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Kullanılabilir Alanlar",
|
title: "Kullanılabilir Alanlar",
|
||||||
icon: "area",
|
icon: BuildAreaIcon,
|
||||||
component: "BuildArea",
|
component: BuildPage,
|
||||||
selfEndpoints: [
|
selfEndpoints: [
|
||||||
"/building/area/list",
|
"/building/area/list",
|
||||||
"/building/area/create",
|
"/building/area/create",
|
||||||
"/building/area/update/{build_uu_id}",
|
"/building/area/update/{build_uu_id}",
|
||||||
],
|
],
|
||||||
allEndpointUUID: [],
|
allEndpoints: [],
|
||||||
subCategories: [],
|
subCategories: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Yaşayan Kişiler",
|
title: "Yaşayan Kişiler",
|
||||||
icon: "person",
|
icon: LivingSpaceIcon,
|
||||||
component: "LivingSpace",
|
component: BuildPage,
|
||||||
selfEndpoints: [
|
selfEndpoints: [
|
||||||
"/building/living_space/list",
|
"/building/living_space/list",
|
||||||
"/building/living_space/create",
|
"/building/living_space/create",
|
||||||
"/building/living_space/update/{build_uu_id}",
|
"/building/living_space/update/{build_uu_id}",
|
||||||
],
|
],
|
||||||
allEndpointUUID: [],
|
allEndpoints: [],
|
||||||
subCategories: [],
|
subCategories: [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
@ -115,54 +75,60 @@ const LeftMenuCategories = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Toplantılar",
|
title: "Toplantılar",
|
||||||
icon: "meeting",
|
icon: meetingIcon,
|
||||||
allEndpointUUID: [
|
allEndpoints: [
|
||||||
"/build/decision_book/invite/list",
|
"/build/decision_book/invite/list",
|
||||||
"/build/decision_book/invite/create",
|
"/build/decision_book/invite/create",
|
||||||
"/build/decision_book/invite/update",
|
"/build/decision_book/invite/update",
|
||||||
"/build/decision_book/invitations/assign",
|
"/build/decision_book/invitations/assign",
|
||||||
],
|
],
|
||||||
|
component: BuildPage,
|
||||||
subCategories: [
|
subCategories: [
|
||||||
{
|
{
|
||||||
title: "Davetiyeler",
|
title: "Davetiyeler",
|
||||||
icon: "invitation",
|
icon: InviteIcon,
|
||||||
|
component: BuildPage,
|
||||||
selfEndpoints: [
|
selfEndpoints: [
|
||||||
"/build/decision_book/invite/list",
|
"/build/decision_book/invite/list",
|
||||||
"/build/decision_book/invite/create",
|
"/build/decision_book/invite/create",
|
||||||
"/build/decision_book/invite/update",
|
"/build/decision_book/invite/update",
|
||||||
"/build/decision_book/invitations/assign",
|
"/build/decision_book/invitations/assign",
|
||||||
],
|
],
|
||||||
allEndpointUUID: [],
|
allEndpoints: [],
|
||||||
subCategories: [],
|
subCategories: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Görev Ata",
|
title: "Görev Ata",
|
||||||
icon: "task",
|
icon: TaskIcon,
|
||||||
|
component: BuildPage,
|
||||||
selfEndpoints: [],
|
selfEndpoints: [],
|
||||||
subCategories: [],
|
subCategories: [],
|
||||||
allEndpointUUID: [],
|
allEndpoints: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Karar Defteri",
|
title: "Karar Defteri",
|
||||||
icon: "decision",
|
icon: "decision",
|
||||||
|
component: BuildPage,
|
||||||
selfEndpoints: [],
|
selfEndpoints: [],
|
||||||
allEndpointUUID: [],
|
allEndpoints: [],
|
||||||
subCategories: [],
|
subCategories: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Cari Hesaplar",
|
title: "Cari Hesaplar",
|
||||||
icon: "account",
|
icon: AccountIcon,
|
||||||
|
component: BuildPage,
|
||||||
selfEndpoints: [],
|
selfEndpoints: [],
|
||||||
allEndpointUUID: ["/account/records/list"],
|
allEndpoints: ["/account/records/list"],
|
||||||
subCategories: [
|
subCategories: [
|
||||||
{
|
{
|
||||||
title: "Bakiye Sorgulama",
|
title: "Bakiye Sorgulama",
|
||||||
icon: "balance",
|
icon: "balance",
|
||||||
|
component: BuildPage,
|
||||||
subCategories: [],
|
subCategories: [],
|
||||||
selfEndpoints: ["/account/records/list"],
|
selfEndpoints: ["/account/records/list"],
|
||||||
allEndpointUUID: [],
|
allEndpoints: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -177,15 +143,24 @@ export function retrieveAvailableCategories(availableCategories: any) {
|
||||||
for (let i = 0; i < LeftMenuCategories.length; i++) {
|
for (let i = 0; i < LeftMenuCategories.length; i++) {
|
||||||
const category = LeftMenuCategories[i];
|
const category = LeftMenuCategories[i];
|
||||||
if (category.allEndpoints) {
|
if (category.allEndpoints) {
|
||||||
const categoryList = Array.from(category.allEndpoints);
|
const setCategory = isCategoryAvailable(
|
||||||
for (let j = 0; j < categoryList.length; j++) {
|
category,
|
||||||
const endpoint = categoryList[j];
|
availableCategoriesList
|
||||||
if (availableCategoriesList.includes(endpoint)) {
|
);
|
||||||
availableMenu.push(category);
|
if (setCategory) {
|
||||||
break;
|
availableMenu.push(category);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return availableMenu;
|
return availableMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isCategoryAvailable(category: any, availableCategoriesList: any) {
|
||||||
|
const categoryList = Array.from(category.allEndpoints);
|
||||||
|
for (let j = 0; j < categoryList.length; j++) {
|
||||||
|
const endpoint = categoryList[j];
|
||||||
|
if (availableCategoriesList.includes(endpoint)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
const InviteIcon = (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-clipboard-check"
|
||||||
|
>
|
||||||
|
<rect width="8" height="4" x="8" y="2" rx="1" ry="1" />
|
||||||
|
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" />
|
||||||
|
<path d="m9 14 2 2 4-4" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
const TaskIcon = (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-clipboard-list"
|
||||||
|
>
|
||||||
|
<rect width="8" height="4" x="8" y="2" rx="1" ry="1" />
|
||||||
|
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" />
|
||||||
|
<path d="M12 11h4" />
|
||||||
|
<path d="M12 16h4" />
|
||||||
|
<path d="M8 11h.01" />
|
||||||
|
<path d="M8 16h.01" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export { InviteIcon, TaskIcon };
|
||||||
|
|
@ -1,73 +1,16 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { set, z } from "zod";
|
import EventButton from "@/components/ContextComponents/Commons/EventButton";
|
||||||
import { useForm } from "react-hook-form";
|
import Table from "@/components/ContextComponents/Commons/Table";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import {
|
|
||||||
LucideRemoveFormatting,
|
|
||||||
RemoveFormattingIcon,
|
|
||||||
SidebarClose,
|
|
||||||
} from "lucide-react";
|
|
||||||
import TableThree from "@/components/Tables/TableThree";
|
|
||||||
import { retrieve_available_events } from "@/apicalls/cookies/token";
|
|
||||||
import EventButton from "../../Commons/EventButton";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
import { retrieveAvailableEvents } from "@/(apicalls)/cookies/token";
|
||||||
searchText: z.string().default(""),
|
import { retrieveBuildList } from "@/(apicalls)/building/build";
|
||||||
});
|
|
||||||
|
|
||||||
const Build: React.FC = () => {
|
const Build: React.FC = () => {
|
||||||
const packageData = [
|
|
||||||
{
|
|
||||||
name: "Free package",
|
|
||||||
price: 0.0,
|
|
||||||
invoiceDate: `Jan 13,2023`,
|
|
||||||
status: true,
|
|
||||||
selected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Standard Package",
|
|
||||||
price: 59.0,
|
|
||||||
invoiceDate: `Jan 13,2023`,
|
|
||||||
status: true,
|
|
||||||
selected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Business Package",
|
|
||||||
price: 99.0,
|
|
||||||
invoiceDate: `Jan 13,2023`,
|
|
||||||
status: false,
|
|
||||||
selected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Standard Package",
|
|
||||||
price: 59.0,
|
|
||||||
invoiceDate: `Jan 13,2023`,
|
|
||||||
status: false,
|
|
||||||
selected: false,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const headers = [
|
|
||||||
"Package",
|
|
||||||
"Package1",
|
|
||||||
"Package2",
|
|
||||||
"Package3",
|
|
||||||
"Invoice date",
|
|
||||||
"Onaylandı",
|
|
||||||
];
|
|
||||||
|
|
||||||
const [renderTable, setRenderTable] = React.useState(false);
|
const [renderTable, setRenderTable] = React.useState(false);
|
||||||
const [renderCreate, setRenderCreate] = React.useState(false);
|
const [renderCreate, setRenderCreate] = React.useState(false);
|
||||||
const [renderUpdate, setRenderUpdate] = React.useState(false);
|
const [renderUpdate, setRenderUpdate] = React.useState(false);
|
||||||
|
|
||||||
const endpointNeeds = [
|
const endpointNeeds = [
|
||||||
{
|
{
|
||||||
endpoint: "/building/build/list",
|
endpoint: "/building/build/list",
|
||||||
|
|
@ -82,95 +25,24 @@ const Build: React.FC = () => {
|
||||||
component: setRenderUpdate,
|
component: setRenderUpdate,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const [packageList, setPackageList] = React.useState(Array.from(packageData));
|
|
||||||
const [tableShow, settableShow] = React.useState(true);
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof formSchema>>({
|
React.useEffect(() => {
|
||||||
resolver: zodResolver(formSchema),
|
retrieveAvailableEvents()
|
||||||
});
|
.then((data) => {
|
||||||
|
for (const endpointNeed of endpointNeeds) {
|
||||||
function selectItem({ key }: { key: number }) {
|
if (data?.availableEvents.includes(endpointNeed.endpoint)) {
|
||||||
packageList.map((item, index) => {
|
endpointNeed.component(true);
|
||||||
if (index === key) {
|
}
|
||||||
item.selected = !item.selected;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setPackageList([...packageList] as any);
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanSelection() {
|
|
||||||
packageList.map((item) => {
|
|
||||||
item.selected = false;
|
|
||||||
});
|
|
||||||
setPackageList([...packageList] as any);
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanSearch() {
|
|
||||||
form.setValue("searchText", "");
|
|
||||||
setPackageList(Array.from(packageData));
|
|
||||||
}
|
|
||||||
|
|
||||||
function search(values: z.infer<typeof formSchema>) {
|
|
||||||
const searchText = values.searchText;
|
|
||||||
if (searchText === "") {
|
|
||||||
setPackageList(Array.from(packageData));
|
|
||||||
} else {
|
|
||||||
const filteredList = Array.from(packageData).filter((item) => {
|
|
||||||
return item.name.toLowerCase().includes(searchText.toLowerCase());
|
|
||||||
});
|
|
||||||
setPackageList(filteredList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
React.useEffect(() => {}, [packageList]);
|
|
||||||
|
|
||||||
retrieve_available_events()
|
|
||||||
.then((data) => {
|
|
||||||
for (const endpointNeed of endpointNeeds) {
|
|
||||||
if (data?.availableEvents.includes(endpointNeed.endpoint)) {
|
|
||||||
endpointNeed.component(true);
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
.catch((error) => {
|
||||||
.catch((error) => {
|
console.log("error", error);
|
||||||
console.log("error", error);
|
});
|
||||||
});
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className=" md:flex items-center py-5 my-5 rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
<div className=" md:flex items-center py-5 my-5 rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||||
<EventButton
|
|
||||||
onClick={() => cleanSelection()}
|
|
||||||
label="Seçimleri Temizle"
|
|
||||||
bgColor="bg-red-700"
|
|
||||||
icon={
|
|
||||||
<svg
|
|
||||||
className="fill-current"
|
|
||||||
width="20"
|
|
||||||
height="20"
|
|
||||||
viewBox="0 0 18 18"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M13.7535 2.47502H11.5879V1.9969C11.5879 1.15315 10.9129 0.478149 10.0691 0.478149H7.90352C7.05977 0.478149 6.38477 1.15315 6.38477 1.9969V2.47502H4.21914C3.40352 2.47502 2.72852 3.15002 2.72852 3.96565V4.8094C2.72852 5.42815 3.09414 5.9344 3.62852 6.1594L4.07852 15.4688C4.13477 16.6219 5.09102 17.5219 6.24414 17.5219H11.7004C12.8535 17.5219 13.8098 16.6219 13.866 15.4688L14.3441 6.13127C14.8785 5.90627 15.2441 5.3719 15.2441 4.78127V3.93752C15.2441 3.15002 14.5691 2.47502 13.7535 2.47502ZM7.67852 1.9969C7.67852 1.85627 7.79102 1.74377 7.93164 1.74377H10.0973C10.2379 1.74377 10.3504 1.85627 10.3504 1.9969V2.47502H7.70664V1.9969H7.67852ZM4.02227 3.96565C4.02227 3.85315 4.10664 3.74065 4.24727 3.74065H13.7535C13.866 3.74065 13.9785 3.82502 13.9785 3.96565V4.8094C13.9785 4.9219 13.8941 5.0344 13.7535 5.0344H4.24727C4.13477 5.0344 4.02227 4.95002 4.02227 4.8094V3.96565ZM11.7285 16.2563H6.27227C5.79414 16.2563 5.40039 15.8906 5.37227 15.3844L4.95039 6.2719H13.0785L12.6566 15.3844C12.6004 15.8625 12.2066 16.2563 11.7285 16.2563Z"
|
|
||||||
fill=""
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M9.00039 9.11255C8.66289 9.11255 8.35352 9.3938 8.35352 9.75942V13.3313C8.35352 13.6688 8.63477 13.9782 9.00039 13.9782C9.33789 13.9782 9.64727 13.6969 9.64727 13.3313V9.75942C9.64727 9.3938 9.33789 9.11255 9.00039 9.11255Z"
|
|
||||||
fill=""
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M11.2502 9.67504C10.8846 9.64692 10.6033 9.90004 10.5752 10.2657L10.4064 12.7407C10.3783 13.0782 10.6314 13.3875 10.9971 13.4157C11.0252 13.4157 11.0252 13.4157 11.0533 13.4157C11.3908 13.4157 11.6721 13.1625 11.6721 12.825L11.8408 10.35C11.8408 9.98442 11.5877 9.70317 11.2502 9.67504Z"
|
|
||||||
fill=""
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M6.72245 9.67504C6.38495 9.70317 6.1037 10.0125 6.13182 10.35L6.3287 12.825C6.35683 13.1625 6.63808 13.4157 6.94745 13.4157C6.97558 13.4157 6.97558 13.4157 7.0037 13.4157C7.3412 13.3875 7.62245 13.0782 7.59433 12.7407L7.39745 10.2657C7.39745 9.90004 7.08808 9.64692 6.72245 9.67504Z"
|
|
||||||
fill=""
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{renderUpdate && (
|
{renderUpdate && (
|
||||||
<EventButton
|
<EventButton
|
||||||
onClick={() => console.log("Delete clicked")}
|
onClick={() => console.log("Delete clicked")}
|
||||||
|
|
@ -239,7 +111,7 @@ const Build: React.FC = () => {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{renderUpdate && (
|
{renderCreate && (
|
||||||
<EventButton
|
<EventButton
|
||||||
onClick={() => console.log("Create clicked")}
|
onClick={() => console.log("Create clicked")}
|
||||||
label="Kayıt ekle"
|
label="Kayıt ekle"
|
||||||
|
|
@ -274,186 +146,7 @@ const Build: React.FC = () => {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{renderTable ? (
|
{renderTable ? <Table createTable={retrieveBuildList} /> : <></>}
|
||||||
<>
|
|
||||||
<div className="w-full md:flex items-center py-5 my-5 rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
|
||||||
<div className="md:w-full mx-5 md:flex md:my-auto justify-start text-lg align-middle">
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
className="min-w-max md:min-w-full"
|
|
||||||
onSubmit={form.handleSubmit(search)}
|
|
||||||
>
|
|
||||||
<div className="relative">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="searchText"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormControl>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="Aramak istediğiniz metini yazınız"
|
|
||||||
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 || ""}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
className="absolute right-5 top-1/2 -translate-y-1/2"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="2"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
className="lucide lucide-search"
|
|
||||||
>
|
|
||||||
<circle cx="11" cy="11" r="8" />
|
|
||||||
<path d="m21 21-4.3-4.3" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => cleanSearch()}
|
|
||||||
className="absolute right-20 top-1/2 -translate-y-1/2"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="2"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
className="lucide lucide-x"
|
|
||||||
>
|
|
||||||
<path d="M18 6 6 18" />
|
|
||||||
<path d="m6 6 12 12" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="text-lg rounded-sm border border-stroke bg-white px-5 pb-2.5 pt-6 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:pb-1">
|
|
||||||
<div className="max-w-full mt-5 mb-10 overflow-x-auto">
|
|
||||||
<table className="w-full table-auto">
|
|
||||||
<thead>
|
|
||||||
<tr className="bg-gray-2 dark:bg-meta-4 border-b border-[#eee] py-5 dark:border-strokedark xl:pl-11">
|
|
||||||
{headers.map((header, key) => (
|
|
||||||
<th
|
|
||||||
key={key}
|
|
||||||
className="min-w-auto px-4 py-4 font-medium text-black dark:text-white"
|
|
||||||
>
|
|
||||||
{header}
|
|
||||||
</th>
|
|
||||||
))}
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{packageList.map((packageItem, key) => (
|
|
||||||
<tr
|
|
||||||
className={`${
|
|
||||||
packageItem.selected === true ? "bg-blue-900" : ""
|
|
||||||
}`}
|
|
||||||
key={key}
|
|
||||||
onClick={() => selectItem({ key })}
|
|
||||||
>
|
|
||||||
<td className="border-b border-[#eee] py-5 pl-9 dark:border-strokedark xl:pl-11">
|
|
||||||
<h5
|
|
||||||
className={`font-medium ${
|
|
||||||
packageItem.selected === true
|
|
||||||
? "bg-blue-900 text-white"
|
|
||||||
: "text-black"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{packageItem.name}
|
|
||||||
</h5>
|
|
||||||
</td>
|
|
||||||
<td className="border-b border-[#eee] py-5 pl-9 dark:border-strokedark xl:pl-11">
|
|
||||||
<h5
|
|
||||||
className={`font-medium ${
|
|
||||||
packageItem.selected === true
|
|
||||||
? "bg-blue-900 text-white"
|
|
||||||
: "text-black"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{packageItem.name}
|
|
||||||
</h5>
|
|
||||||
</td>
|
|
||||||
<td className="border-b border-[#eee] py-5 pl-9 dark:border-strokedark xl:pl-11">
|
|
||||||
<h5
|
|
||||||
className={`font-medium ${
|
|
||||||
packageItem.selected === true
|
|
||||||
? "bg-blue-900 text-white"
|
|
||||||
: "text-black"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{packageItem.name}
|
|
||||||
</h5>
|
|
||||||
</td>
|
|
||||||
<td className="border-b border-[#eee] py-5 pl-9 dark:border-strokedark xl:pl-11">
|
|
||||||
<h5
|
|
||||||
className={`font-medium ${
|
|
||||||
packageItem.selected === true
|
|
||||||
? "bg-blue-900 text-white"
|
|
||||||
: "text-black"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{packageItem.name}
|
|
||||||
</h5>
|
|
||||||
</td>
|
|
||||||
<td className="border-b border-[#eee] py-5 dark:border-strokedark">
|
|
||||||
<p
|
|
||||||
className={`font-medium ${
|
|
||||||
packageItem.selected === true
|
|
||||||
? "bg-blue-900 text-white"
|
|
||||||
: "text-black"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{packageItem.invoiceDate}
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
<td
|
|
||||||
className={`border-b border-[#eee] py-5 text-center dark:border-strokedark" ${
|
|
||||||
packageItem.selected === true
|
|
||||||
? "bg-blue-100 text-white"
|
|
||||||
: "text-black"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<p
|
|
||||||
className={`inline-flex rounded-full bg-opacity-10 px-3 py-1 text-sm font-medium ${
|
|
||||||
packageItem.status
|
|
||||||
? "bg-success text-success"
|
|
||||||
: "bg-danger text-danger"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{packageItem.status ? "Evet" : "Hayır"}
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,68 +12,72 @@ import {
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from "@/components/ui/form";
|
||||||
import Landing from "@/components/ContextComponents/Commons/Landing";
|
|
||||||
|
|
||||||
interface TableProps {
|
interface TableProps {
|
||||||
data: Array<any>;
|
createTable: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
searchText: z.string().default(""),
|
searchText: z.string().default(""),
|
||||||
});
|
});
|
||||||
|
|
||||||
const Table: React.FC<TableProps> = ({ data }) => {
|
const Table: React.FC<TableProps> = ({ createTable }) => {
|
||||||
const [packageList, setPackageList] = React.useState(Array.from(data));
|
const [tabledata, settabledata] = React.useState([]);
|
||||||
const headersList: Array<string> = getHeaders(data);
|
const [headersList, setHeadersList] = React.useState<string[]>([]);
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
});
|
||||||
|
|
||||||
function getHeaders(data: Array<any>): Array<string> {
|
React.useEffect(() => {
|
||||||
|
createTable({}).then((res: Object) => {
|
||||||
|
const resData: any = res?.data || [];
|
||||||
|
settabledata(resData || []);
|
||||||
|
setHeadersList(getHeaders(resData));
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
function getHeaders(data: Array<any>) {
|
||||||
let returnList: Array<string> = [];
|
let returnList: Array<string> = [];
|
||||||
if (Array.from(data).length > 0) {
|
if (Array.from(data).length > 0) {
|
||||||
Object.entries(data[0]).map(([key, value]) => {
|
Object.entries(data[0]).map(([key, value]) => {
|
||||||
console.log("key, value", key, value);
|
|
||||||
returnList.push(key);
|
returnList.push(key);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof formSchema>>({
|
|
||||||
resolver: zodResolver(formSchema),
|
|
||||||
});
|
|
||||||
|
|
||||||
function selectItem({ key }: { key: number }) {
|
function selectItem({ key }: { key: number }) {
|
||||||
packageList.map((item, index) => {
|
tabledata.map((item, index) => {
|
||||||
if (index === key) {
|
if (index === key) {
|
||||||
item.selected = !item.selected;
|
item.selected = !item.selected;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setPackageList([...packageList] as any);
|
settabledata([...tabledata] as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanSelection() {
|
function cleanSelection() {
|
||||||
packageList.map((item) => {
|
tabledata.map((item) => {
|
||||||
item.selected = false;
|
item.selected = false;
|
||||||
});
|
});
|
||||||
setPackageList([...packageList] as any);
|
settabledata([...tabledata] as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanSearch() {
|
function cleanSearch() {
|
||||||
form.setValue("searchText", "");
|
form.setValue("searchText", "");
|
||||||
setPackageList(Array.from(data));
|
settabledata(Array.from(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
function search(values: z.infer<typeof formSchema>) {
|
function search(values: z.infer<typeof formSchema>) {
|
||||||
const searchText = values.searchText;
|
const searchText = values.searchText;
|
||||||
if (searchText === "") {
|
if (searchText === "") {
|
||||||
setPackageList(Array.from(data));
|
settabledata(Array.from(data));
|
||||||
} else {
|
} else {
|
||||||
const filteredList = Array.from(data).filter((item) => {
|
const filteredList = Array.from(data).filter((item) => {
|
||||||
return item.name.toLowerCase().includes(searchText.toLowerCase());
|
return item.name.toLowerCase().includes(searchText.toLowerCase());
|
||||||
});
|
});
|
||||||
setPackageList(filteredList);
|
settabledata(filteredList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
React.useEffect(() => {}, [packageList]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -251,9 +255,9 @@ const Table: React.FC<TableProps> = ({ data }) => {
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
stroke-width="2"
|
strokeWidth="2"
|
||||||
stroke-linecap="round"
|
strokeLinecap="round"
|
||||||
stroke-linejoin="round"
|
strokeLinejoin="round"
|
||||||
className="lucide lucide-search"
|
className="lucide lucide-search"
|
||||||
>
|
>
|
||||||
<circle cx="11" cy="11" r="8" />
|
<circle cx="11" cy="11" r="8" />
|
||||||
|
|
@ -271,9 +275,9 @@ const Table: React.FC<TableProps> = ({ data }) => {
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
stroke-width="2"
|
strokeWidth="2"
|
||||||
stroke-linecap="round"
|
strokeLinecap="round"
|
||||||
stroke-linejoin="round"
|
strokeLinejoin="round"
|
||||||
className="lucide lucide-x"
|
className="lucide lucide-x"
|
||||||
>
|
>
|
||||||
<path d="M18 6 6 18" />
|
<path d="M18 6 6 18" />
|
||||||
|
|
@ -302,7 +306,7 @@ const Table: React.FC<TableProps> = ({ data }) => {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{packageList.map((packageItem, key) => (
|
{tabledata.map((packageItem, key) => (
|
||||||
<tr
|
<tr
|
||||||
className={`${
|
className={`${
|
||||||
packageItem.selected === true ? "bg-blue-900" : ""
|
packageItem.selected === true ? "bg-blue-900" : ""
|
||||||
|
|
@ -310,7 +314,27 @@ const Table: React.FC<TableProps> = ({ data }) => {
|
||||||
key={key}
|
key={key}
|
||||||
onClick={() => selectItem({ key })}
|
onClick={() => selectItem({ key })}
|
||||||
>
|
>
|
||||||
<td className="border-b border-[#eee] py-5 pl-9 dark:border-strokedark xl:pl-11">
|
{Object.entries(packageItem).map(
|
||||||
|
([key, value]: [key: string, value: any]) => {
|
||||||
|
return (
|
||||||
|
<td
|
||||||
|
key={key}
|
||||||
|
className="border-b border-[#eee] py-5 pl-9 dark:border-strokedark xl:pl-11"
|
||||||
|
>
|
||||||
|
<h5
|
||||||
|
className={`font-medium ${
|
||||||
|
packageItem.selected === true
|
||||||
|
? "bg-blue-900 text-white"
|
||||||
|
: "text-black"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{value || ""}
|
||||||
|
</h5>
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
{/* <td className="border-b border-[#eee] py-5 pl-9 dark:border-strokedark xl:pl-11">
|
||||||
<h5
|
<h5
|
||||||
className={`font-medium ${
|
className={`font-medium ${
|
||||||
packageItem.selected === true
|
packageItem.selected === true
|
||||||
|
|
@ -381,7 +405,7 @@ const Table: React.FC<TableProps> = ({ data }) => {
|
||||||
>
|
>
|
||||||
{packageItem.status ? "Evet" : "Hayır"}
|
{packageItem.status ? "Evet" : "Hayır"}
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td> */}
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,24 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Toaster } from "@/components/ui/toaster";
|
|
||||||
import { showToast } from "@/components/login/toaster";
|
|
||||||
|
|
||||||
import { useToast } from "@/hooks/use-toast";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
import Landing from "../ContextComponents/Commons/Landing";
|
import Landing from "../ContextComponents/Commons/Landing";
|
||||||
import DefaultLayout from "@/components/Layouts/DefaultLayout";
|
import DefaultLayout from "@/components/Layouts/DefaultLayout";
|
||||||
|
|
||||||
interface DashboardPageProps {
|
interface DashboardPageProps {
|
||||||
accessToken: string;
|
|
||||||
leftSideMenuContent: Array<any>;
|
leftSideMenuContent: Array<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DashboardPage: React.FC<DashboardPageProps> = ({
|
const DashboardPage: React.FC<DashboardPageProps> = ({
|
||||||
accessToken,
|
|
||||||
leftSideMenuContent,
|
leftSideMenuContent,
|
||||||
}) => {
|
}) => {
|
||||||
const { toast } = useToast();
|
|
||||||
const router = useRouter();
|
|
||||||
const [activePage, setActivePage] = React.useState(<Landing />);
|
const [activePage, setActivePage] = React.useState(<Landing />);
|
||||||
|
const [activeMenu, setActiveMenu] = React.useState(leftSideMenuContent);
|
||||||
|
|
||||||
|
React.useEffect(() => {}, [activeMenu]);
|
||||||
return (
|
return (
|
||||||
<DefaultLayout
|
<DefaultLayout
|
||||||
accessToken={accessToken}
|
leftSideMenuContent={activeMenu}
|
||||||
leftSideMenuContent={leftSideMenuContent}
|
leftSideMenuSetter={setActiveMenu}
|
||||||
activePage={activePage}
|
activePage={activePage}
|
||||||
setActivePage={setActivePage}
|
setActivePage={setActivePage}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,20 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import ClickOutside from "@/components/ClickOutside";
|
|
||||||
import { logout_active_session } from "@/apicalls/login/logout";
|
|
||||||
import { showToast } from "../login/toaster";
|
|
||||||
import { useToast } from "@/hooks/use-toast";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
|
||||||
interface LoginSelectUser {
|
import { showToast } from "../login/toaster";
|
||||||
access_token: string;
|
import { logoutActiveSession } from "@/(apicalls)/login/logout";
|
||||||
}
|
import ClickOutside from "@/components/ClickOutside";
|
||||||
|
|
||||||
const DropdownUser: React.FC<LoginSelectUser> = ({ access_token }) => {
|
const DropdownUser: React.FC = () => {
|
||||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
const logoutActiveSession = () => {
|
const logoutActiveSessionFunc = () => {
|
||||||
logout_active_session({
|
logoutActiveSession({
|
||||||
token: access_token,
|
|
||||||
domain: "evyos.com.tr",
|
domain: "evyos.com.tr",
|
||||||
})
|
})
|
||||||
.then((responseData: any) => {
|
.then((responseData: any) => {
|
||||||
|
|
@ -163,7 +159,7 @@ const DropdownUser: React.FC<LoginSelectUser> = ({ access_token }) => {
|
||||||
</ul>
|
</ul>
|
||||||
<button
|
<button
|
||||||
className="flex items-center gap-3.5 px-6 py-4 text-sm font-medium duration-300 ease-in-out hover:text-primary lg:text-base"
|
className="flex items-center gap-3.5 px-6 py-4 text-sm font-medium duration-300 ease-in-out hover:text-primary lg:text-base"
|
||||||
onClick={logoutActiveSession}
|
onClick={logoutActiveSessionFunc}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
className="fill-current"
|
className="fill-current"
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,17 @@ import DarkModeSwitcher from "./DarkModeSwitcher";
|
||||||
import DropdownMessage from "./DropdownMessage";
|
import DropdownMessage from "./DropdownMessage";
|
||||||
import DropdownNotification from "./DropdownNotification";
|
import DropdownNotification from "./DropdownNotification";
|
||||||
import DropdownUser from "./DropdownUser";
|
import DropdownUser from "./DropdownUser";
|
||||||
import Image from "next/image";
|
|
||||||
|
|
||||||
interface HeaderProps {
|
interface HeaderProps {
|
||||||
access_token: string;
|
|
||||||
sidebarOpen: string | boolean | undefined;
|
sidebarOpen: string | boolean | undefined;
|
||||||
setSidebarOpen: (arg0: boolean) => void;
|
setSidebarOpen: (arg0: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Header: React.FC<HeaderProps> = ({
|
const Header: React.FC<HeaderProps> = ({ sidebarOpen, setSidebarOpen }) => {
|
||||||
access_token,
|
|
||||||
sidebarOpen,
|
|
||||||
setSidebarOpen,
|
|
||||||
}) => {
|
|
||||||
return (
|
return (
|
||||||
<header className="sticky top-0 z-999 flex w-full bg-white drop-shadow-1 dark:bg-boxdark dark:drop-shadow-none">
|
<header className="sticky top-0 z-999 flex w-full bg-white drop-shadow-1 dark:bg-boxdark dark:drop-shadow-none">
|
||||||
<div className="flex flex-grow items-center justify-between px-4 py-4 shadow-2 md:px-6 2xl:px-11">
|
<div className="flex flex-grow items-center justify-between px-4 py-4 shadow-2 md:px-6 2xl:px-11">
|
||||||
<div className="flex items-center gap-2 sm:gap-4 lg:hidden">
|
<div className="flex items-center gap-2 sm:gap-4 lg:hidden">
|
||||||
{/* <!-- Hamburger Toggle BTN --> */}
|
|
||||||
<button
|
<button
|
||||||
aria-controls="sidebar"
|
aria-controls="sidebar"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
|
@ -62,7 +55,6 @@ const Header: React.FC<HeaderProps> = ({
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{/* <!-- Hamburger Toggle BTN --> */}
|
|
||||||
|
|
||||||
<Link className="block flex-shrink-0 lg:hidden" href="/">
|
<Link className="block flex-shrink-0 lg:hidden" href="/">
|
||||||
{/* <Image
|
{/* <Image
|
||||||
|
|
@ -116,7 +108,7 @@ const Header: React.FC<HeaderProps> = ({
|
||||||
<DropdownNotification />
|
<DropdownNotification />
|
||||||
<DropdownMessage />
|
<DropdownMessage />
|
||||||
</ul>
|
</ul>
|
||||||
<DropdownUser access_token={access_token} />
|
<DropdownUser />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,18 @@ import Header from "@/components/Header";
|
||||||
|
|
||||||
interface DefaultLayoutProps {
|
interface DefaultLayoutProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
accessToken: string;
|
|
||||||
leftSideMenuContent: Array<any>;
|
leftSideMenuContent: Array<any>;
|
||||||
activePage: React.JSX.Element;
|
activePage: React.JSX.Element;
|
||||||
setActivePage: React.Dispatch<React.SetStateAction<React.JSX.Element>>;
|
setActivePage: React.Dispatch<React.SetStateAction<React.JSX.Element>>;
|
||||||
|
leftSideMenuSetter: React.Dispatch<React.SetStateAction<Array<any>>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultLayout: React.FC<DefaultLayoutProps> = ({
|
const DefaultLayout: React.FC<DefaultLayoutProps> = ({
|
||||||
children,
|
children,
|
||||||
accessToken,
|
|
||||||
leftSideMenuContent,
|
leftSideMenuContent,
|
||||||
activePage,
|
activePage,
|
||||||
setActivePage,
|
setActivePage,
|
||||||
|
leftSideMenuSetter,
|
||||||
}) => {
|
}) => {
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||||
return (
|
return (
|
||||||
|
|
@ -26,15 +26,12 @@ const DefaultLayout: React.FC<DefaultLayoutProps> = ({
|
||||||
sidebarOpen={sidebarOpen}
|
sidebarOpen={sidebarOpen}
|
||||||
setSidebarOpen={setSidebarOpen}
|
setSidebarOpen={setSidebarOpen}
|
||||||
leftSideMenuContent={leftSideMenuContent}
|
leftSideMenuContent={leftSideMenuContent}
|
||||||
|
leftSideMenuSetter={leftSideMenuSetter}
|
||||||
activePage={activePage}
|
activePage={activePage}
|
||||||
setActivePage={setActivePage}
|
setActivePage={setActivePage}
|
||||||
/>
|
/>
|
||||||
<div className="relative flex flex-1 w-full overflow-x-hidden flex-col lg:ml-72.5">
|
<div className="relative flex flex-1 w-full overflow-x-hidden flex-col lg:ml-72.5">
|
||||||
<Header
|
<Header sidebarOpen={sidebarOpen} setSidebarOpen={setSidebarOpen} />
|
||||||
access_token={accessToken}
|
|
||||||
sidebarOpen={sidebarOpen}
|
|
||||||
setSidebarOpen={setSidebarOpen}
|
|
||||||
/>
|
|
||||||
<main>
|
<main>
|
||||||
<div className="flex flex-col mx-auto sm:max-w-full sm:p-4 md:p-6 2xl:p-10 sm:block ">
|
<div className="flex flex-col mx-auto sm:max-w-full sm:p-4 md:p-6 2xl:p-10 sm:block ">
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,28 @@
|
||||||
|
"use client";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import Link from "next/link";
|
import { retrieveAvailableCategories } from "@/appEvents/categories";
|
||||||
import SidebarDropdown from "@/components/Sidebar/SidebarDropdown";
|
interface SidebarItemProps {
|
||||||
|
item: any;
|
||||||
|
pageName: any;
|
||||||
|
setPageName: any;
|
||||||
|
leftSideMenuSetter: React.Dispatch<React.SetStateAction<Array<any>>>;
|
||||||
|
}
|
||||||
|
|
||||||
const SidebarItem = ({ item, pageName, setPageName }: any) => {
|
const SidebarItem = ({
|
||||||
|
item,
|
||||||
|
pageName,
|
||||||
|
setPageName,
|
||||||
|
leftSideMenuSetter,
|
||||||
|
}: SidebarItemProps) => {
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
console.log("item", item.title.toLowerCase(), pageName);
|
if (pageName?.title !== item.title) {
|
||||||
if (pageName !== item.title.toLowerCase()) {
|
// const availableMenu = retrieveAvailableCategories(
|
||||||
|
// item?.subCategories || []
|
||||||
|
// );
|
||||||
|
const availableMenu = item?.subCategories || [];
|
||||||
|
if (availableMenu.length !== 0) {
|
||||||
|
leftSideMenuSetter(availableMenu);
|
||||||
|
}
|
||||||
setPageName(item.component);
|
setPageName(item.component);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -20,48 +37,15 @@ const SidebarItem = ({ item, pageName, setPageName }: any) => {
|
||||||
const isItemActive = isActive(item);
|
const isItemActive = isActive(item);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div
|
||||||
<li>
|
onClick={handleClick}
|
||||||
<div
|
className={`${
|
||||||
onClick={handleClick}
|
isItemActive ? "bg-graydark dark:bg-meta-4" : ""
|
||||||
className={`${
|
} group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium text-bodydark1 my-5 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4`}
|
||||||
isItemActive ? "bg-graydark dark:bg-meta-4" : ""
|
>
|
||||||
} group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium text-bodydark1 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4`}
|
{item.icon}
|
||||||
>
|
{item.title}
|
||||||
{item.icon}
|
</div>
|
||||||
{item.title}
|
|
||||||
{/* {item.children && (
|
|
||||||
<svg
|
|
||||||
className={`absolute right-4 top-1/2 -translate-y-1/2 fill-current ${
|
|
||||||
pageName === item.label.toLowerCase() && "rotate-180"
|
|
||||||
}`}
|
|
||||||
width="20"
|
|
||||||
height="20"
|
|
||||||
viewBox="0 0 20 20"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fillRule="evenodd"
|
|
||||||
clipRule="evenodd"
|
|
||||||
d="M4.41107 6.9107C4.73651 6.58527 5.26414 6.58527 5.58958 6.9107L10.0003 11.3214L14.4111 6.91071C14.7365 6.58527 15.2641 6.58527 15.5896 6.91071C15.915 7.23614 15.915 7.76378 15.5896 8.08922L10.5896 13.0892C10.2641 13.4147 9.73651 13.4147 9.41107 13.0892L4.41107 8.08922C4.08563 7.76378 4.08563 7.23614 4.41107 6.9107Z"
|
|
||||||
fill=""
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
)}
|
|
||||||
*/}
|
|
||||||
</div>
|
|
||||||
{/* {item.children && (
|
|
||||||
<div
|
|
||||||
className={`translate transform overflow-hidden ${
|
|
||||||
pageName !== item.label.toLowerCase() && "hidden"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<SidebarDropdown item={item.children} />
|
|
||||||
</div>
|
|
||||||
)} */}
|
|
||||||
</li>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import { usePathname } from "next/navigation";
|
|
||||||
import Link from "next/link";
|
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import SidebarItem from "@/components/Sidebar/SidebarItem";
|
import SidebarItem from "@/components/Sidebar/SidebarItem";
|
||||||
import ClickOutside from "@/components/ClickOutside";
|
import ClickOutside from "@/components/ClickOutside";
|
||||||
import useLocalStorage from "@/hooks/useLocalStorage";
|
import { retrieveAvailableEvents } from "@/(apicalls)/cookies/token";
|
||||||
|
import { retrieveAvailableCategories } from "@/appEvents/categories";
|
||||||
|
|
||||||
interface SidebarProps {
|
interface SidebarProps {
|
||||||
sidebarOpen: boolean;
|
sidebarOpen: boolean;
|
||||||
leftSideMenuContent: Array<any>;
|
leftSideMenuContent: Array<any>;
|
||||||
activePage: React.JSX.Element;
|
activePage: React.JSX.Element;
|
||||||
setActivePage: React.Dispatch<React.SetStateAction<React.JSX.Element>>;
|
setActivePage: React.Dispatch<React.SetStateAction<React.JSX.Element>>;
|
||||||
|
leftSideMenuSetter: React.Dispatch<React.SetStateAction<Array<any>>>;
|
||||||
setSidebarOpen: (arg: boolean) => void;
|
setSidebarOpen: (arg: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,9 +20,17 @@ const Sidebar = ({
|
||||||
sidebarOpen,
|
sidebarOpen,
|
||||||
leftSideMenuContent,
|
leftSideMenuContent,
|
||||||
activePage,
|
activePage,
|
||||||
|
leftSideMenuSetter,
|
||||||
setSidebarOpen,
|
setSidebarOpen,
|
||||||
setActivePage,
|
setActivePage,
|
||||||
}: SidebarProps) => {
|
}: SidebarProps) => {
|
||||||
|
const clearMenu = () => {
|
||||||
|
retrieveAvailableEvents().then((endpointList) => {
|
||||||
|
const availableMenu = retrieveAvailableCategories(endpointList);
|
||||||
|
leftSideMenuSetter(availableMenu);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ClickOutside onClick={() => setSidebarOpen(false)}>
|
<ClickOutside onClick={() => setSidebarOpen(false)}>
|
||||||
<aside
|
<aside
|
||||||
|
|
@ -31,7 +39,6 @@ const Sidebar = ({
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<div className="no-scrollbar flex flex-col overflow-y-auto duration-300 ease-linear">
|
<div className="no-scrollbar flex flex-col overflow-y-auto duration-300 ease-linear">
|
||||||
{/* <!-- Sidebar Menu --> */}
|
|
||||||
<div className="mx-auto max-w-242.5">
|
<div className="mx-auto max-w-242.5">
|
||||||
<div className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
<div className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||||
<div className="relative z-20 h-35 ">
|
<div className="relative z-20 h-35 ">
|
||||||
|
|
@ -103,19 +110,44 @@ const Sidebar = ({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nav className="mt-5 px-4 py-4 lg:mt-9 lg:px-6">
|
<nav className="mt-5 px-4 py-4 lg:mt-9 lg:px-6">
|
||||||
|
<div className="my-5">
|
||||||
|
<div
|
||||||
|
onClick={clearMenu}
|
||||||
|
className=" group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium text-bodydark1 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="lucide lucide-square-x"
|
||||||
|
>
|
||||||
|
<rect width="18" height="18" x="3" y="3" rx="2" ry="2" />
|
||||||
|
<path d="m15 9-6 6" />
|
||||||
|
<path d="m9 9 6 6" />
|
||||||
|
</svg>
|
||||||
|
Ana Menuye Dön
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{leftSideMenuContent.map((group, groupIndex) => (
|
{leftSideMenuContent.map((group, groupIndex) => (
|
||||||
<div key={groupIndex}>
|
<div key={groupIndex}>
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
key={group.component}
|
key={group.title}
|
||||||
item={group}
|
item={group}
|
||||||
pageName={activePage}
|
pageName={activePage}
|
||||||
setPageName={setActivePage}
|
setPageName={setActivePage}
|
||||||
|
leftSideMenuSetter={leftSideMenuSetter}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
{/* <!-- Sidebar Menu --> */}
|
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</ClickOutside>
|
</ClickOutside>
|
||||||
|
|
|
||||||
|
|
@ -282,9 +282,9 @@ const TableThree = () => {
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
stroke-width="2"
|
strokeWidth="2"
|
||||||
stroke-linecap="round"
|
strokeLinecap="round"
|
||||||
stroke-linejoin="round"
|
strokeLinejoin="round"
|
||||||
className="lucide lucide-search"
|
className="lucide lucide-search"
|
||||||
>
|
>
|
||||||
<circle cx="11" cy="11" r="8" />
|
<circle cx="11" cy="11" r="8" />
|
||||||
|
|
@ -302,9 +302,9 @@ const TableThree = () => {
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
stroke-width="2"
|
strokeWidth="2"
|
||||||
stroke-linecap="round"
|
strokeLinecap="round"
|
||||||
stroke-linejoin="round"
|
strokeLinejoin="round"
|
||||||
className="lucide lucide-x"
|
className="lucide lucide-x"
|
||||||
>
|
>
|
||||||
<path d="M18 6 6 18" />
|
<path d="M18 6 6 18" />
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
"use server";
|
"use server";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import LoginSelectEmployee from "./loginselectemployee";
|
import LoginSelectEmployee from "./loginselectemployee";
|
||||||
import {
|
import { retrieveAccessObjects } from "@/(apicalls)/cookies/token";
|
||||||
retrieve_access_objects,
|
|
||||||
retrieve_access_token,
|
|
||||||
} from "@/apicalls/cookies/token";
|
|
||||||
|
|
||||||
const LoginEmployeeCard: React.FC = async () => {
|
const LoginEmployeeCard: React.FC = async () => {
|
||||||
const accessObject: any = await retrieve_access_objects();
|
const accessObject = await retrieveAccessObjects();
|
||||||
const accessToken: any = await retrieve_access_token();
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="min-h-full min-w-full">
|
<div className="min-h-full min-w-full">
|
||||||
|
|
@ -16,10 +12,7 @@ const LoginEmployeeCard: React.FC = async () => {
|
||||||
Şirket Seçimi Yapınız
|
Şirket Seçimi Yapınız
|
||||||
</h1>
|
</h1>
|
||||||
<div>
|
<div>
|
||||||
<LoginSelectEmployee
|
<LoginSelectEmployee company_list={accessObject?.companies_list} />
|
||||||
company_list={accessObject?.companies_list}
|
|
||||||
access_token={accessToken}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
"use server";
|
"use server";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import LoginSelectOccupant from "./loginselectoccupant";
|
import LoginSelectOccupant from "./loginselectoccupant";
|
||||||
import {
|
import { retrieveAccessObjects } from "@/(apicalls)/cookies/token";
|
||||||
retrieve_access_objects,
|
|
||||||
retrieve_access_token,
|
|
||||||
} from "@/apicalls/cookies/token";
|
|
||||||
|
|
||||||
const LoginOccupantCard: React.FC = async () => {
|
const LoginOccupantCard: React.FC = async () => {
|
||||||
const accessObject: any = await retrieve_access_objects();
|
const accessObject: any = await retrieveAccessObjects();
|
||||||
const accessToken: any = await retrieve_access_token();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -19,7 +15,6 @@ const LoginOccupantCard: React.FC = async () => {
|
||||||
<div>
|
<div>
|
||||||
<LoginSelectOccupant
|
<LoginSelectOccupant
|
||||||
available_occupants={accessObject?.available_occupants}
|
available_occupants={accessObject?.available_occupants}
|
||||||
access_token={accessToken}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,13 @@ import { Toaster } from "@/components/ui/toaster";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import { showToast } from "./toaster";
|
import { showToast } from "./toaster";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { login_select_employee } from "@/apicalls/login/login";
|
import { loginSelectEmployee } from "@/(apicalls)/login/login";
|
||||||
import { setAvailableEvents } from "@/apicalls/events/available";
|
|
||||||
|
|
||||||
interface CompanyList {
|
interface CompanyList {
|
||||||
company_list: Array<string>;
|
company_list: Array<string>;
|
||||||
access_token: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const LoginSelectEmployee: React.FC<CompanyList> = ({
|
const LoginSelectEmployee: React.FC<CompanyList> = ({ company_list }) => {
|
||||||
company_list,
|
|
||||||
access_token,
|
|
||||||
}) => {
|
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoading, setIsLoading] = React.useState(false);
|
const [isLoading, setIsLoading] = React.useState(false);
|
||||||
|
|
@ -26,7 +21,7 @@ const LoginSelectEmployee: React.FC<CompanyList> = ({
|
||||||
const companiesList = company_list || [];
|
const companiesList = company_list || [];
|
||||||
const onClick = (data: any) => {
|
const onClick = (data: any) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
login_select_employee({ company_uu_id: data?.uu_id, token: access_token })
|
loginSelectEmployee({ company_uu_id: data?.uu_id })
|
||||||
.then((responseData: any) => {
|
.then((responseData: any) => {
|
||||||
console.log("responseData", responseData);
|
console.log("responseData", responseData);
|
||||||
if (responseData?.completed) {
|
if (responseData?.completed) {
|
||||||
|
|
@ -35,7 +30,6 @@ const LoginSelectEmployee: React.FC<CompanyList> = ({
|
||||||
data: JSON.stringify(responseData),
|
data: JSON.stringify(responseData),
|
||||||
});
|
});
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setAvailableEvents(access_token);
|
|
||||||
router.push("/dashboard");
|
router.push("/dashboard");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,13 @@ import { Toaster } from "@/components/ui/toaster";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import { showToast } from "@/components/login/toaster";
|
import { showToast } from "@/components/login/toaster";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { login_select_occupant } from "@/apicalls/login/login";
|
import { loginSelectOccupant } from "@/(apicalls)/login/login";
|
||||||
import { setAvailableEvents } from "@/apicalls/events/available";
|
|
||||||
|
|
||||||
interface LoginSelectOccupantProps {
|
interface LoginSelectOccupantProps {
|
||||||
access_token: string;
|
|
||||||
available_occupants: Array<any>;
|
available_occupants: Array<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LoginSelectOccupant: React.FC<LoginSelectOccupantProps> = ({
|
const LoginSelectOccupant: React.FC<LoginSelectOccupantProps> = ({
|
||||||
access_token,
|
|
||||||
available_occupants,
|
available_occupants,
|
||||||
}) => {
|
}) => {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
@ -33,10 +30,9 @@ const LoginSelectOccupant: React.FC<LoginSelectOccupantProps> = ({
|
||||||
|
|
||||||
const onClick = (data: any) => {
|
const onClick = (data: any) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
login_select_occupant({
|
loginSelectOccupant({
|
||||||
build_part_uu_id: data?.part_uu_id,
|
build_part_uu_id: data?.part_uu_id,
|
||||||
occupant_uu_id: data?.uu_id,
|
occupant_uu_id: data?.uu_id,
|
||||||
token: access_token,
|
|
||||||
})
|
})
|
||||||
.then((responseData: any) => {
|
.then((responseData: any) => {
|
||||||
console.log("occupant", responseData);
|
console.log("occupant", responseData);
|
||||||
|
|
@ -46,7 +42,6 @@ const LoginSelectOccupant: React.FC<LoginSelectOccupantProps> = ({
|
||||||
data: JSON.stringify(responseData),
|
data: JSON.stringify(responseData),
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setAvailableEvents(access_token);
|
|
||||||
router.push("/dashboard");
|
router.push("/dashboard");
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import { Switch } from "@/components/ui/switch";
|
||||||
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { showToast } from "./toaster";
|
import { showToast } from "./toaster";
|
||||||
import { login_via_access_keys } from "@/apicalls/login/login";
|
import { loginViaAccessKeys } from "../../(apicalls)/login/login";
|
||||||
import Loader from "@/components/common/Loader";
|
import Loader from "@/components/common/Loader";
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
|
|
@ -51,7 +51,7 @@ const LoginWithEmail: React.FC = () => {
|
||||||
|
|
||||||
function onSubmit(values: z.infer<typeof formSchema>) {
|
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
login_via_access_keys({
|
loginViaAccessKeys({
|
||||||
domain: "evyos.com.tr",
|
domain: "evyos.com.tr",
|
||||||
accessKey: values.loginEmailInput,
|
accessKey: values.loginEmailInput,
|
||||||
password: values.loginPassword,
|
password: values.loginPassword,
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { showToast } from "@/components/login/toaster";
|
||||||
import {
|
import {
|
||||||
change_password_via_token,
|
change_password_via_token,
|
||||||
send_forgot_password_email,
|
send_forgot_password_email,
|
||||||
} from "@/apicalls/login/password";
|
} from "../../(apicalls)/login/password";
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
oldPassword: z.string().min(5, { message: "Şifre 6 karakterden az olamaz" }),
|
oldPassword: z.string().min(5, { message: "Şifre 6 karakterden az olamaz" }),
|
||||||
|
|
@ -36,11 +36,7 @@ const formSchema = z.object({
|
||||||
.default(""),
|
.default(""),
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ChangePasswordProps {
|
const ChangePassword: React.FC = () => {
|
||||||
accessToken: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ChangePassword: React.FC<ChangePasswordProps> = ({ accessToken }) => {
|
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
@ -72,7 +68,6 @@ const ChangePassword: React.FC<ChangePasswordProps> = ({ accessToken }) => {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
change_password_via_token({
|
change_password_via_token({
|
||||||
accessToken: accessToken || "",
|
|
||||||
oldPassword: values.oldPassword,
|
oldPassword: values.oldPassword,
|
||||||
newPassword: values.loginPassword,
|
newPassword: values.loginPassword,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import {
|
||||||
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { showToast } from "@/components/login/toaster";
|
import { showToast } from "@/components/login/toaster";
|
||||||
import { create_password_via_token } from "@/apicalls/login/password";
|
import { create_password_via_token } from "../../(apicalls)/login/password";
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
loginPassword: z
|
loginPassword: z
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import { Switch } from "@/components/ui/switch";
|
||||||
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { showToast } from "@/components/login/toaster";
|
import { showToast } from "@/components/login/toaster";
|
||||||
import { send_forgot_password_email } from "@/apicalls/login/password";
|
import { send_forgot_password_email } from "../../(apicalls)/login/password";
|
||||||
import { Link } from "lucide-react";
|
import { Link } from "lucide-react";
|
||||||
import { access } from "fs";
|
import { access } from "fs";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue