1
0
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:
Youssef 2022-02-10 09:33:09 +01:00
parent 4d0d39891a
commit df448e66e8
4 changed files with 39 additions and 14 deletions

View File

@ -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;
}

View File

@ -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 () => {

View File

@ -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',

View 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;
}