-
-
- Kullanıcı bu etkinliğe erişim iznine sahip değil.
-
-
+
+
+
+
+
+ Kullanıcı bu etkinliğe erişim iznine sahip değil.
+
- >
+
);
};
diff --git a/src/components/ContextComponents/Commons/SearchBar.tsx b/src/components/ContextComponents/Commons/SearchBar.tsx
new file mode 100644
index 0000000..48a5498
--- /dev/null
+++ b/src/components/ContextComponents/Commons/SearchBar.tsx
@@ -0,0 +1,11 @@
+import React from 'react';
+
+const SearchBar: React.FC = () => {
+ return (
+
+ {/* SearchBar component */}
+
+ );
+};
+
+export default SearchBar;
\ No newline at end of file
diff --git a/src/components/ContextComponents/Commons/Table.tsx b/src/components/ContextComponents/Commons/Table.tsx
index fcc5c8b..bb5dd87 100644
--- a/src/components/ContextComponents/Commons/Table.tsx
+++ b/src/components/ContextComponents/Commons/Table.tsx
@@ -12,12 +12,16 @@ import {
FormLabel,
FormMessage,
} from "@/components/ui/form";
+import { retrieveHeadersByEndpoint } from "../functions/retrieveEndpointAndValidations";
interface TableProps {
- createTable: any;
- headers: any;
- tableSelectedRow: any;
- setTableSelectedRow: React.Dispatch
>;
+ createEndpoint: string;
+ updateEndpoint: string;
+ tableFunction: any;
+ UpdatePage: any;
+ setFormPage: any;
+ updatePageInfo: any;
+ returnToPage: any;
}
const formSchema = z.object({
@@ -25,227 +29,206 @@ const formSchema = z.object({
});
const Table: React.FC = ({
- createTable,
- tableSelectedRow,
- setTableSelectedRow,
- headers,
+ createEndpoint,
+ updateEndpoint,
+ tableFunction,
+ UpdatePage,
+ setFormPage,
+ updatePageInfo,
+ returnToPage,
}) => {
- const [initalData, setInitalData] = React.useState([]);
+ const [apiHeaders, setApiHeaders] = React.useState([]);
const [tabledata, settabledata] = React.useState([]);
- const [headersList, setHeadersList] = React.useState([]);
-
- const incomingHeaders = Array.from(Object.values(headers)) || [];
- const headersObject = headers || {};
+ const [searchDropDown, setSearchDropDown] = React.useState("");
const form = useForm>({
resolver: zodResolver(formSchema),
});
- React.useEffect(() => {
- if (incomingHeaders.length !== 0) {
- let headersNew: any = [];
- createTable({})
- .then((res: any) => {
- const resData: any = res?.data || [];
- if (resData?.length > 0) {
- settabledata(resData || []);
- setInitalData(resData || []);
- for (const key in resData[0]) {
- if (Object.keys(headersObject).includes(key)) {
- headersNew.push(headers[key]);
- } else {
- console.log("key", key);
- }
- }
- if (headersNew.length > 0) {
- setHeadersList(headersNew);
- }
- }
- })
- .catch((err: any) => {});
- }
- }, [headers]);
-
- function cleanSearch() {
- form.setValue("searchText", "");
- settabledata(Array.from(initalData));
+ function retrieveData(query: null | any = null) {
+ return tableFunction(query)
+ .then((res: any) => {
+ settabledata(res?.data || []);
+ return res?.data || [];
+ })
+ .catch((err: any) => {});
}
- function search(values: z.infer) {
- const searchText = values.searchText;
+ React.useEffect(() => {
+ retrieveHeadersByEndpoint(createEndpoint).then((validations: any) => {
+ if (validations?.headers.length !== 0) {
+ tableFunction({
+ page: 1,
+ limit: 10,
+ order_field: "uu_id",
+ order_type: "desc",
+ })
+ .then((response: any) => {
+ settabledata(response?.data || []);
+ for (const key in response?.data[0]) {
+ if (Object.keys(validations?.headers).includes(key)) {
+ setApiHeaders((prev: string[]) => [
+ ...prev,
+ validations?.headers[key],
+ ]);
+ }
+ }
+ })
+ .catch((err: any) => {});
+ }
+ retrieveData();
+ });
+ }, []);
+
+ function cleanSearch() {
+ retrieveData();
+ }
+
+ function searchByForm() {
+ const searchText = form.getValues("searchText");
if (searchText === "") {
- settabledata(Array.from(initalData));
+ cleanSearch();
} else {
- const filteredList = Array.from(tabledata).filter((item) => {
- return Object.values(item).some((row: any) => {
- console.log(row);
- return row.toLowerCase().includes(searchText.toLowerCase());
- });
- });
- console.log("filteredList", filteredList);
- settabledata(filteredList);
+ if (searchText.length > 3) {
+ setQuery({ searchDropDown: searchText });
+ retrieveData();
+ }
}
}
+ function updateSelectedRow({ selectedComponent }: any) {
+ setFormPage(
+ console.log("saveFunction")}
+ />
+ );
+ }
+
return (
<>
-
-
-
-
setTableSelectedRow({})}
- >
-
-
-
-
-
-
-
-
+ );
+ })}
- {headersList.map((header, key) => (
- |
- {header}
- |
- ))}
+ {apiHeaders &&
+ apiHeaders?.map((header, key) => (
+
+ {header}
+ |
+ ))}
+
- {tabledata.map((packageItem: any) => (
-
- setTableSelectedRow(
- tableSelectedRow.uu_id == packageItem.uu_id
- ? {}
- : packageItem
- )
- }
- >
- {Object.entries(packageItem).map(
+ {tabledata.map((row: any) => (
+
+ {Object.entries(row).map(
([key, value]: [key: string, value: any]) => {
return (
-
- {value || ""}
-
+ {value || ""}
|
);
}
diff --git a/src/components/ContextComponents/Commons/isNotAllowedButton.tsx b/src/components/ContextComponents/Commons/isNotAllowedButton.tsx
index e7af1bf..c4a725d 100644
--- a/src/components/ContextComponents/Commons/isNotAllowedButton.tsx
+++ b/src/components/ContextComponents/Commons/isNotAllowedButton.tsx
@@ -3,13 +3,18 @@ import React from "react";
import EventButton from "@/components/ContextComponents/Commons/ButtonEvent";
interface IsNotAllowedButtonProps {
+ buttonKey: string;
label: string;
}
-const IsNotAllowedButton: React.FC = ({ label }) => {
+const IsNotAllowedButton: React.FC = ({
+ label,
+ buttonKey,
+}) => {
return (
<>
{
+ if (JSON.stringify(validator?.validated) !== "{}") {
+ apiValidation = validator;
+ Object.keys(validator?.validated).map((key: string) => {
+ zodValidation[key] = null;
+ const keyValidation = validator?.validated[key] || {
+ fieldType: { type: "string" },
+ required: false,
+ };
+ const fieldType: String = keyValidation.fieldType?.type || "string";
+ const required = keyValidation.required || false;
+ if (fieldType === "string") {
+ zodValidation[key] = required ? z.string() : z.string().optional();
+ } else if (fieldType === "integer") {
+ zodValidation[key] = required ? z.number() : z.number().optional();
+ }
+ });
+ return {
+ zodValidation: zodValidation,
+ apiValidation: apiValidation,
+ };
+ }
+ })
+ .catch(() => {});
+ return {
+ zodValidation: zodValidation,
+ apiValidation: apiValidation,
+ };
+}
+
+async function retrieveHeadersByEndpoint(endpoint: string) {
+ let headers: any = {};
+
+ await retrieveHeadersEndpoint({
+ endpoint: endpoint,
+ })
+ .then((validator) => {
+ if (JSON.stringify(validator?.headers) !== "{}") {
+ headers = validator?.headers;
+ return {
+ headers: headers,
+ };
+ }
+ })
+ .catch(() => {});
+ return {
+ headers: headers,
+ };
+}
+
+export { retrieveValidationsByEndpoint, retrieveHeadersByEndpoint };
diff --git a/src/components/Dashboards/DashboardPage.tsx b/src/components/Dashboards/DashboardPage.tsx
index dde1914..96b3e46 100644
--- a/src/components/Dashboards/DashboardPage.tsx
+++ b/src/components/Dashboards/DashboardPage.tsx
@@ -13,8 +13,12 @@ const DashboardPage: React.FC = ({
}) => {
const [activePage, setActivePage] = React.useState();
const [activeMenu, setActiveMenu] = React.useState(leftSideMenuContent);
+ const [activeValidationList, setActiveValidationList] = React.useState([]);
+ const [activeValidation, setActiveValidation] = React.useState({});
- React.useEffect(() => {}, [activeMenu]);
+ React.useEffect((
+
+ ) => {}, [activeMenu]);
return (