Skip to content

Commit

Permalink
refactor: add hooks/data subfolder for useData use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
DPS0340 committed Oct 13, 2022
1 parent 1510c7c commit fb8b52f
Show file tree
Hide file tree
Showing 26 changed files with 63 additions and 63 deletions.
6 changes: 6 additions & 0 deletions src/hooks/data/useABTestsData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import getABTests from '../../api/tests';
import { abTestsAtom } from '../../atoms/tests';
import { useData } from '../useData';

export const useABTestsData = () =>
useData(abTestsAtom, getABTests, { useRawType: true });
8 changes: 8 additions & 0 deletions src/hooks/data/useDeploymentStrategiesData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getDeploymentStrategies } from '../../api/deployment-strategies';
import { deploymentStrategiesAtom } from '../../atoms/deployment-strategies';
import { useData } from '../useData';

export const useDeploymentStrategiesData = () =>
useData(deploymentStrategiesAtom, getDeploymentStrategies, {
useRawType: true,
});
6 changes: 6 additions & 0 deletions src/hooks/data/useDeploymentsData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import getDeployments from '../../api/deployments';
import { deploymentsAtom } from '../../atoms/deployments';
import { useData } from '../useData';

export const useDeploymentsData = () =>
useData(deploymentsAtom, getDeployments);
6 changes: 6 additions & 0 deletions src/hooks/data/useLibrariesData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { getLibraries } from '../../api/library';
import { librariesAtom } from '../../atoms/library';
import { useData } from '../useData';

export const useLibrariesData = () =>
useData(librariesAtom, getLibraries, { useRawType: true });
6 changes: 6 additions & 0 deletions src/hooks/data/useModelMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { getModelMetadataById } from '../../api/models';
import { modelMetadataAtom } from '../../atoms/model-metadata';
import { useData } from '../useData';

export const useModelMetadata = () =>
useData(modelMetadataAtom, getModelMetadataById);
5 changes: 5 additions & 0 deletions src/hooks/data/useModelsData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import getModels from '../../api/models';
import { modelsAtom } from '../../atoms/models';
import { useData } from '../useData';

export const useModelsData = () => useData(modelsAtom, getModels);
6 changes: 6 additions & 0 deletions src/hooks/data/useResourcesData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { getResources } from '../../api/resources';
import { resourcesAtom } from '../../atoms/resources';
import { useData } from '../useData';

export const useResourcesData = () =>
useData(resourcesAtom, getResources, { useRawType: true });
6 changes: 0 additions & 6 deletions src/hooks/useABTestsData.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/hooks/useDeploymentStrategiesData.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/hooks/useDeploymentsData.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/hooks/useLibrariesData.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/hooks/useModelMetadata.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/hooks/useModelsData.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/hooks/useResourcesData.ts

This file was deleted.

10 changes: 5 additions & 5 deletions src/pages/deployments/create-update-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import { resourcesAtom } from '../../atoms/resources';
import { snackbarAtom } from '../../atoms/snackbar';
import ActionCard from '../../components/action-card';
import OverViewTab from '../../components/detail/overview-tab';
import { useDeploymentsData } from '../../hooks/useDeploymentsData';
import { useDeploymentStrategiesData } from '../../hooks/useDeploymentStrategiesData';
import { useModelMetadata } from '../../hooks/useModelMetadata';
import { useModelsData } from '../../hooks/useModelsData';
import { useResourcesData } from '../../hooks/useResourcesData';
import { useDeploymentsData } from '../../hooks/data/useDeploymentsData';
import { useDeploymentStrategiesData } from '../../hooks/data/useDeploymentStrategiesData';
import { useModelMetadata } from '../../hooks/data/useModelMetadata';
import { useModelsData } from '../../hooks/data/useModelsData';
import { useResourcesData } from '../../hooks/data/useResourcesData';
import { ICreateUpdateBaseParams } from '../../interfaces';
import { IResourceFind } from '../../interfaces/pages/resources';
import { IScalingBase } from '../../interfaces/pages/deployments';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/deployments/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import OverViewTab from '../../components/detail/overview-tab';
import YamlTab from '../../components/detail/yaml-tab';
import { UNIT } from '../../constants';
import { useDelete } from '../../hooks/useDelete';
import { useDeploymentsData } from '../../hooks/useDeploymentsData';
import { useDeploymentsData } from '../../hooks/data/useDeploymentsData';

export const DeploymentDetail: React.FC = () => {
const [deployments] = useAtom(deploymentsAtom);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/deployments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { deleteDeployment } from '../../api/deployments';
import { deploymentsAtom } from '../../atoms/deployments';
import ListTable from '../../components/table';
import { useDelete } from '../../hooks/useDelete';
import { useDeploymentsData } from '../../hooks/useDeploymentsData';
import { useDeploymentsData } from '../../hooks/data/useDeploymentsData';
import { IDeploymentView } from '../../interfaces/pages/deployments';
import { filterColumns } from '../../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/model-metadata/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DetailCard } from '../../components/detail/card';
import OverViewTab from '../../components/detail/overview-tab';
import YamlTab from '../../components/detail/yaml-tab';
import { useDelete } from '../../hooks/useDelete';
import { useModelsData } from '../../hooks/useModelsData';
import { useModelsData } from '../../hooks/data/useModelsData';
import { IModelMetadataDetail } from '../../interfaces/pages/model-metadata';
import { convertStatusToIcon } from '../../utils/pages/models';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/models/create-update-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { librariesAtom } from '../../atoms/library';
import { modelsAtom } from '../../atoms/models';
import { snackbarAtom } from '../../atoms/snackbar';
import ActionCard from '../../components/action-card';
import { useLibrariesData } from '../../hooks/useLibrariesData';
import { useLibrariesData } from '../../hooks/data/useLibrariesData';
import { ICreateUpdateBaseParams } from '../../interfaces';

const CreateUpdateModelBase: React.FC<ICreateUpdateBaseParams> = ({
Expand Down
4 changes: 2 additions & 2 deletions src/pages/models/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { modelMetadataAtom } from '../../atoms/model-metadata';
import { modelsAtom } from '../../atoms/models';
import ListTable from '../../components/table';
import { useDelete } from '../../hooks/useDelete';
import { useModelMetadata } from '../../hooks/useModelMetadata';
import { useModelsData } from '../../hooks/useModelsData';
import { useModelMetadata } from '../../hooks/data/useModelMetadata';
import { useModelsData } from '../../hooks/data/useModelsData';
import { IModelMetadataView } from '../../interfaces/pages/models';
import { filterColumns } from '../../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/models/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { deleteModel } from '../../api/models';
import { modelsAtom } from '../../atoms/models';
import ListTable from '../../components/table';
import { useDelete } from '../../hooks/useDelete';
import { useModelsData } from '../../hooks/useModelsData';
import { useModelsData } from '../../hooks/data/useModelsData';
import { IModelView } from '../../interfaces/pages/models';
import { filterColumns } from '../../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/resources/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { snackbarAtom } from '../../atoms/snackbar';
import { DetailCard } from '../../components/detail/card';
import OverViewTab from '../../components/detail/overview-tab';
import { useDelete } from '../../hooks/useDelete';
import { useResourcesData } from '../../hooks/useResourcesData';
import { useResourcesData } from '../../hooks/data/useResourcesData';

export const ResourceDetail = () => {
const refreshData = useResourcesData();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/resources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { deleteResource } from '../../api/resources';
import { resourcesAtom } from '../../atoms/resources';
import ListTable from '../../components/table';
import { useDelete } from '../../hooks/useDelete';
import { useResourcesData } from '../../hooks/useResourcesData';
import { useResourcesData } from '../../hooks/data/useResourcesData';

export const Resources = () => {
const refreshData = useResourcesData();
Expand Down
4 changes: 2 additions & 2 deletions src/pages/tests/ab/create-update-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { deploymentsAtom } from '../../../atoms/deployments';
import { snackbarAtom } from '../../../atoms/snackbar';
import { abTestsAtom } from '../../../atoms/tests';
import ActionCard from '../../../components/action-card';
import { useABTestsData } from '../../../hooks/useABTestsData';
import { useDeploymentsData } from '../../../hooks/useDeploymentsData';
import { useABTestsData } from '../../../hooks/data/useABTestsData';
import { useDeploymentsData } from '../../../hooks/data/useDeploymentsData';
import { ICreateUpdateBaseParams } from '../../../interfaces';

export const CreateUpdateABTestBase: React.FC<ICreateUpdateBaseParams> = ({
Expand Down
4 changes: 2 additions & 2 deletions src/pages/tests/ab/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { snackbarAtom } from '../../../atoms/snackbar';
import { abTestsAtom } from '../../../atoms/tests';
import { DetailCard } from '../../../components/detail/card';
import OverViewTab from '../../../components/detail/overview-tab';
import { useABTestsData } from '../../../hooks/useABTestsData';
import { useABTestsData } from '../../../hooks/data/useABTestsData';
import { useDelete } from '../../../hooks/useDelete';
import { useDeploymentsData } from '../../../hooks/useDeploymentsData';
import { useDeploymentsData } from '../../../hooks/data/useDeploymentsData';
import { IABTestJoined } from '../../../interfaces/pages/tests';
import { joinABTest } from '../../../utils/pages/tests/ab';

Expand Down
4 changes: 2 additions & 2 deletions src/pages/tests/ab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { deleteABTest } from '../../../api/tests';
import { deploymentsAtom } from '../../../atoms/deployments';
import { abTestsAtom } from '../../../atoms/tests';
import ListTable from '../../../components/table';
import { useABTestsData } from '../../../hooks/useABTestsData';
import { useABTestsData } from '../../../hooks/data/useABTestsData';
import { useDelete } from '../../../hooks/useDelete';
import { useDeploymentsData } from '../../../hooks/useDeploymentsData';
import { useDeploymentsData } from '../../../hooks/data/useDeploymentsData';
import { IABTestView } from '../../../interfaces/pages/tests';
import { convertABTestToView } from '../../../utils/pages/tests/ab';

Expand Down

0 comments on commit fb8b52f

Please sign in to comment.