Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init optimiztion #29

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions components/DataGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import UserAction from './UserAction';
import { toast } from 'react-toastify';
import EditButtons from './editButtons';
Expand All @@ -12,11 +13,10 @@ import { DataGrid, GridRowId, GridRowSpacingParams, gridClasses, GridRenderCellP

interface DataTableProps {
jobs: CrawledJob[];
refershData: () => void;
}


const DataTable = ( {jobs, refershData}:DataTableProps ) => {
const DataTable = ( {jobs}:DataTableProps ) => {

const [rowId, setRowId] = useState('')
const [loading, setLoading] = useState<boolean>(false)
Expand Down Expand Up @@ -70,7 +70,7 @@ const DataTable = ( {jobs, refershData}:DataTableProps ) => {
},

], [rowId])

// this should be called after the set render, avoiding the limit
let rows = crawlerjobs.map((crawlerjobs:Job)=>{
const {id,company,title,type,link,deadline,logo,skills}=crawlerjobs;
return {
Expand Down Expand Up @@ -115,7 +115,6 @@ const DataTable = ( {jobs, refershData}:DataTableProps ) => {
}

const handleConfirm = async () => {
console.log('confirm')
const res = await fetch ('/api/confirm', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -154,11 +153,6 @@ const DataTable = ( {jobs, refershData}:DataTableProps ) => {

}

const handeelRefershData = async () => {
refershData()
setCrawlerSuccess(false)
setKey((prev) => prev + 1)
}


return (
Expand Down Expand Up @@ -243,7 +237,6 @@ const DataTable = ( {jobs, refershData}:DataTableProps ) => {

onRowSelectionModelChange={(params) => {
setSelectedJobs(params)
console.log(params)

}}

Expand All @@ -265,7 +258,6 @@ const DataTable = ( {jobs, refershData}:DataTableProps ) => {
<div className="text-4xl text-white self-start">Crawler finished successfully</div>
<div className='self-center flex items-center justify-center '>
<button className="button text-white bg-blue-400 py-3 px-5 rounded-2xl "
onClick={handeelRefershData}
>Refresh table</button>
</div>
<p className='self-end text-xs text-white '>if you have unfinished business you can close the popup and refresh it manually later</p>
Expand Down
1 change: 1 addition & 0 deletions components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import Image from "next/image";

const Header = ( ) => {
Expand Down
2 changes: 2 additions & 0 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use client'
import Header from "./Header";
import { useTheme } from 'next-themes'


interface LayoutProps {
children: React.ReactNode;
}
Expand Down
2 changes: 2 additions & 0 deletions components/UserAction.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client'

import { toast } from 'react-toastify';
import { useState, useEffect } from 'react';
import { green } from '@mui/material/colors';
Expand Down
1 change: 1 addition & 0 deletions components/editButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { useState } from 'react';
import { GridRowId } from '@mui/x-data-grid';
import { green } from '@mui/material/colors';
Expand Down
1 change: 0 additions & 1 deletion pages/api/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { CrawledJob, PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();


export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== 'POST') {
return res.status(405).json({ message: 'Method not allowed' });
Expand Down
9 changes: 2 additions & 7 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ import DataTable from '@/components/DataGrid'
import type { Job } from '@/Database/interface';



export default function Home( {jobs}:{jobs:CrawledJob[]}) {

const router = useRouter();

const refershData = () => {
router.replace(router.asPath);
}

return (
<>
Expand All @@ -24,7 +19,7 @@ export default function Home( {jobs}:{jobs:CrawledJob[]}) {
<main className="flex min-h-screen w-full flex-col items-center justify-between p-24">


<DataTable jobs={jobs} refershData={refershData} />
<DataTable jobs={jobs} />

</main>
</>
Expand Down