mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
refactor: add application interface and add use applications output interface
This commit is contained in:
parent
4d0d39891a
commit
df448e66e8
@ -5,19 +5,9 @@ import icons from '../icon-names';
|
||||
import GeneralSelect from '../../common/GeneralSelect/GeneralSelect';
|
||||
import useApplicationsApi from '../../../hooks/api/actions/useApplicationsApi/useApplicationsApi';
|
||||
import useToast from '../../../hooks/useToast';
|
||||
import { IApplication } from '../../../interfaces/application';
|
||||
|
||||
|
||||
interface IApplication {
|
||||
appName: string;
|
||||
color: string;
|
||||
createdAt: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
instances: [];
|
||||
links: object;
|
||||
seenToggles: [];
|
||||
strategies: [];
|
||||
url: string;
|
||||
}
|
||||
interface IApplicationUpdateProps {
|
||||
application: IApplication;
|
||||
}
|
||||
|
@ -2,8 +2,20 @@ import useSWR, { mutate, SWRConfiguration } from 'swr';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { formatApiPath } from '../../../../utils/format-path';
|
||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||
import { IApplication } from '../../../../interfaces/application';
|
||||
|
||||
const useApplication = (name: string, options: SWRConfiguration = {}) => {
|
||||
interface IUseApplicationOutput {
|
||||
application: IApplication;
|
||||
refetchApplication: () => void;
|
||||
loading: boolean;
|
||||
error?: Error;
|
||||
APPLICATION_CACHE_KEY: string;
|
||||
}
|
||||
|
||||
const useApplication = (
|
||||
name: string,
|
||||
options: SWRConfiguration = {}
|
||||
): IUseApplicationOutput => {
|
||||
const path = formatApiPath(`api/admin/metrics/applications/${name}`);
|
||||
|
||||
const fetcher = async () => {
|
||||
|
@ -2,10 +2,21 @@ import useSWR, { mutate, SWRConfiguration } from 'swr';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { formatApiPath } from '../../../../utils/format-path';
|
||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||
import { IApplication } from '../../../../interfaces/application';
|
||||
|
||||
const path = formatApiPath('api/admin/metrics/applications');
|
||||
|
||||
const useApplications = (options: SWRConfiguration = {}) => {
|
||||
interface IUseApplicationsOutput {
|
||||
applications: IApplication[];
|
||||
refetchApplications: () => void;
|
||||
loading: boolean;
|
||||
error?: Error;
|
||||
APPLICATIONS_CACHE_KEY: string;
|
||||
}
|
||||
|
||||
const useApplications = (
|
||||
options: SWRConfiguration = {}
|
||||
): IUseApplicationsOutput => {
|
||||
const fetcher = async () => {
|
||||
return fetch(path, {
|
||||
method: 'GET',
|
||||
|
12
frontend/src/interfaces/application.ts
Normal file
12
frontend/src/interfaces/application.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export interface IApplication {
|
||||
appName: string;
|
||||
color: string;
|
||||
createdAt: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
instances: [];
|
||||
links: object;
|
||||
seenToggles: [];
|
||||
strategies: [];
|
||||
url: string;
|
||||
}
|
Loading…
Reference in New Issue
Block a user