admin(ui): fix remaining problems with SearchableSelect.tsx
This commit is contained in:
parent
3971c4499d
commit
93be6db530
7 changed files with 118 additions and 161 deletions
|
@ -1,25 +1,18 @@
|
|||
import { Database, rawDataToDatabase } from '@/api/admin/databases/getDatabases';
|
||||
import http from '@/api/http';
|
||||
import { Database, rawDataToDatabase } from '@/api/admin/databases/getDatabases';
|
||||
|
||||
interface Filters {
|
||||
name?: string;
|
||||
host?: string;
|
||||
}
|
||||
|
||||
interface Wow {
|
||||
[index: string]: string;
|
||||
}
|
||||
|
||||
export default (filters?: Filters): Promise<Database[]> => {
|
||||
let params = {};
|
||||
const params = {};
|
||||
if (filters !== undefined) {
|
||||
params = Object.keys(filters).map((key) => {
|
||||
const a: Wow = {};
|
||||
a[`filter[${key}]`] = (filters as unknown as Wow)[key];
|
||||
return a;
|
||||
Object.keys(filters).forEach(key => {
|
||||
// @ts-ignore
|
||||
params['filter[' + key + ']'] = filters[key];
|
||||
});
|
||||
|
||||
console.log(params);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import http from '@/api/http';
|
||||
import { Location, rawDataToLocation } from '@/api/admin/locations/getLocations';
|
||||
|
||||
export default (filters?: Record<string, string>): Promise<Location[]> => {
|
||||
interface Filters {
|
||||
short?: string;
|
||||
long?: string;
|
||||
}
|
||||
|
||||
export default (filters?: Filters): Promise<Location[]> => {
|
||||
const params = {};
|
||||
if (filters !== undefined) {
|
||||
Object.keys(filters).forEach(key => {
|
||||
|
|
|
@ -61,7 +61,7 @@ export const rawDataToNode = ({ attributes }: FractalResponseData): Node => ({
|
|||
updatedAt: new Date(attributes.updated_at),
|
||||
|
||||
relations: {
|
||||
databaseHost: attributes.relationships?.databaseHost !== undefined ? rawDataToDatabase(attributes.relationships.databaseHost as FractalResponseData) : undefined,
|
||||
databaseHost: attributes.relationships?.database_host !== undefined ? rawDataToDatabase(attributes.relationships.database_host as FractalResponseData) : undefined,
|
||||
location: attributes.relationships?.location !== undefined ? rawDataToLocation(attributes.relationships.location as FractalResponseData) : undefined,
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue