mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
removing unused code
This commit is contained in:
committed by
Aaro Koivukangas
parent
7474061afe
commit
fb8ee30e46
@@ -1,5 +1,4 @@
|
||||
import { Router } from 'express'
|
||||
import { getLocalityDetails } from '../services/locality'
|
||||
import { getAllCrossSearch } from '../services/crossSearch'
|
||||
import { fixBigInt } from '../utils/common'
|
||||
|
||||
@@ -10,11 +9,4 @@ router.get('/all', async (req, res) => {
|
||||
return res.status(200).send(fixBigInt(crossSearch))
|
||||
})
|
||||
|
||||
router.get('/:id', async (req, res) => {
|
||||
const id = parseInt(req.params.id)
|
||||
const locality = await getLocalityDetails(id, req.user)
|
||||
if (!locality) return res.status(404).send()
|
||||
return res.status(200).send(fixBigInt(locality))
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
@@ -67,7 +67,6 @@ export const getAllCrossSearch = async (user?: User) => {
|
||||
const removeProjects: (loc: CrossSearchListType) => Omit<CrossSearchListType, 'now_plr'> = loc => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { now_plr, ...rest } = loc
|
||||
// console.log(loc)
|
||||
return rest
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { useMemo } from 'react'
|
||||
import { type MRT_ColumnDef } from 'material-react-table'
|
||||
import { useGetAllCrossSearchQuery, useGetCrossSearchListMutation } from '../../redux/crossSearchReducer'
|
||||
import { useGetAllCrossSearchQuery } from '../../redux/crossSearchReducer'
|
||||
import { CrossSearch } from '@/backendTypes'
|
||||
import { TableView } from '../TableView/TableView'
|
||||
import { useNotify } from '@/hooks/notification'
|
||||
|
||||
export const CrossSearchTable = ({ selectorFn }: { selectorFn?: (newObject: CrossSearch) => void }) => {
|
||||
const CrossSearchQuery = useGetAllCrossSearchQuery()
|
||||
const [getCrossSearchList, { isLoading }] = useGetCrossSearchListMutation()
|
||||
const notify = useNotify()
|
||||
const columns = useMemo<MRT_ColumnDef<CrossSearch>[]>(
|
||||
() => [
|
||||
{
|
||||
@@ -84,27 +81,6 @@ export const CrossSearchTable = ({ selectorFn }: { selectorFn?: (newObject: Cros
|
||||
[]
|
||||
)
|
||||
|
||||
const combinedExport = async (lids: number[]) => {
|
||||
if (isLoading) {
|
||||
notify('Please wait for the last request to complete.', 'warning')
|
||||
return
|
||||
}
|
||||
|
||||
const limit = 99999999
|
||||
if (lids.length > limit) {
|
||||
notify(`Please filter the table more. Current rows: ${lids.length}. Limit: ${limit}`, 'error')
|
||||
return
|
||||
}
|
||||
const result = await getCrossSearchList(lids).unwrap()
|
||||
const dataString = result.map(row => row.join(',')).join('\n')
|
||||
const blob = new Blob([dataString], { type: 'text/csv' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = 'localitiesWithSpecies.csv'
|
||||
a.click()
|
||||
}
|
||||
|
||||
const checkRowRestriction = (row: CrossSearch) => {
|
||||
return !!row.loc_status
|
||||
}
|
||||
@@ -118,8 +94,6 @@ export const CrossSearchTable = ({ selectorFn }: { selectorFn?: (newObject: Cros
|
||||
columns={columns}
|
||||
data={CrossSearchQuery.data}
|
||||
url="crosssearch"
|
||||
combinedExport={combinedExport}
|
||||
exportIsLoading={isLoading}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,14 +9,7 @@ const crossSearchApi = api.injectEndpoints({
|
||||
}),
|
||||
providesTags: result => (result ? [{ type: 'localities' }] : []),
|
||||
}),
|
||||
getCrossSearchList: builder.mutation<string[][], number[]>({
|
||||
query: (lids: number[]) => ({
|
||||
url: `/locality-species`,
|
||||
body: { lids },
|
||||
method: 'POST',
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
export const { useGetAllCrossSearchQuery, useGetCrossSearchListMutation } = crossSearchApi
|
||||
export const { useGetAllCrossSearchQuery } = crossSearchApi
|
||||
|
||||
Reference in New Issue
Block a user