diff --git a/src/components/Shared/Table.js b/src/components/Shared/Table.js index 45e45e6..70a4098 100644 --- a/src/components/Shared/Table.js +++ b/src/components/Shared/Table.js @@ -1,56 +1,85 @@ import React from "react"; -import { Table, Thead, Tbody, Tr, Th, Td } from "react-super-responsive-table" -import "./Table.css" +import { Table, Thead, Tbody, Tr, Th, Td } from "react-super-responsive-table"; +import "./Table.css"; import "react-super-responsive-table/dist/SuperResponsiveTableStyle.css"; -export const CreateTable = (data, columns, deleteFunction, editFunction, sting) => ( +export const CreateTable = ( + data, + columns, + deleteFunction, + editFunction, + sting +) => ( - {columns.map(x => )} - {(deleteFunction || editFunction) - ? ( - - ) - : null} + {columns.map((x) => ( + + ))} + {deleteFunction || editFunction ? : null} - {data.map((item, index) => { - return ( - - {columns.map(property => { - const value = item[property]; - try { - if (property === "link" && value && new URL(value).hostname === "dailybruin.com") { - return () - } - } - catch { } - return ( - - ) - })} - {(deleteFunction || editFunction || sting) - ? ( + {columns.map((property) => { + const value = item[property]; + try { + if ( + property === "link" && + value && + new URL(value).hostname === "dailybruin.com" + ) { + return ( + + ); } - })}>Delete) - : null} - {editFunction - ? ( editFunction(item)}>Edit) - : null} - {sting - ? ( sting(item["_id"])}>Sting) - : null} - ) - : null} - - ) - })} + } catch {} + return ( + + ); + })} + {deleteFunction || editFunction || sting ? ( + + ) : null} + + ); + })}
{x}actions{x}actions
{value}{value ? value : '\u00A0'} - {deleteFunction - ? ( deleteFunction(item["_id"]).then(() => { - if (window) { - window.location.reload(); + {[] + .concat(data) + .sort((a, b) => (a.placement[0] > b.placement[0] ? 1 : -1)) + .map((item, index) => { + return ( +
+ + {value} + +
+ {value ? value : "\u00A0"} + + {deleteFunction ? ( + + deleteFunction(item["_id"]).then(() => { + if (window) { + window.location.reload(); + } + }) + } + > + Delete + + ) : null} + {editFunction ? ( + editFunction(item)}> + Edit + + ) : null} + {sting ? ( + sting(item["_id"])}> + Sting + + ) : null} +
-) \ No newline at end of file +);