64 lines
1.3 KiB
JavaScript
64 lines
1.3 KiB
JavaScript
const fs = require('fs');
|
|
|
|
// Get the file name from the command line arguments
|
|
const fileName = process.argv[2];
|
|
|
|
// Check if a file name is provided
|
|
if (!fileName) {
|
|
console.error('Please provide a file name.');
|
|
process.exit(1);
|
|
}
|
|
|
|
|
|
|
|
let FileContiner = `
|
|
import React, { useMemo } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import Actions from "../../Components/Ui/tables/Actions";
|
|
|
|
function fnDelete(props :any ){}
|
|
|
|
const useTableColumns :any = () => {
|
|
const [t] = useTranslation();
|
|
|
|
return useMemo(
|
|
() => [
|
|
|
|
{
|
|
name: t("email"),
|
|
sortable: false,
|
|
center: "true",
|
|
cell: (row:any) => row?.email
|
|
},
|
|
|
|
{
|
|
name: "#",
|
|
sortable: false,
|
|
center: "true",
|
|
cell: (row) => (
|
|
<Actions
|
|
|
|
// importnat to return the row in on Edit Function to store in objectToEdit That Upper in Edit Modal
|
|
onEdit={() => row}
|
|
onView={()=>{}}
|
|
objectToEdit={row}
|
|
showEdit={true}
|
|
// showDelete={false}
|
|
onDelete={() => fnDelete({ id: row.id })}
|
|
/>
|
|
),
|
|
},
|
|
],
|
|
[t]
|
|
);
|
|
};
|
|
|
|
export default useTableColumns;
|
|
|
|
`
|
|
fs.writeFileSync('src/Pages/'+fileName+"/useTableColumns"+".tsx",
|
|
FileContiner
|
|
);
|
|
|
|
console.log(`File "${fileName}" generated successfully.`);
|