Skip to content

Commit

Permalink
refactor: swap out interface with type where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerourke committed Jan 16, 2024
1 parent 951c216 commit 69ea417
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 149 deletions.
26 changes: 13 additions & 13 deletions src/redux/allEntities/allEntitiesReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { inc, lensPath, over } from "ramda";
import {
createReducer,
isActionOf,
type Action,
type ActionType,
type AnyAction,
} from "~/redux/reduxTools";
import {
EntityGroup,
Expand All @@ -17,15 +17,15 @@ import {

import * as allEntitiesActions from "./allEntitiesActions";

export interface AllEntitiesState {
readonly areExistsInTargetShown: boolean;
readonly entityGroupInProcess: EntityGroup | null;
readonly fetchAllFetchStatus: FetchStatus;
readonly pushAllChangesFetchStatus: FetchStatus;
readonly toolAction: ToolAction;
readonly toolNameByMapping: ToolNameByMapping;
readonly transferCountsByEntityGroup: CountsByEntityGroup;
}
export type AllEntitiesState = Readonly<{
areExistsInTargetShown: boolean;
entityGroupInProcess: EntityGroup | null;
fetchAllFetchStatus: FetchStatus;
pushAllChangesFetchStatus: FetchStatus;
toolAction: ToolAction;
toolNameByMapping: ToolNameByMapping;
transferCountsByEntityGroup: CountsByEntityGroup;
}>;

const DEFAULT_TRANSFER_COUNTS = {
[EntityGroup.Clients]: 0,
Expand Down Expand Up @@ -143,7 +143,7 @@ type AllEntitiesApiRequestAction = ActionType<
>;

function isAllEntitiesApiRequestAction(
action: AnyAction,
action: Action,
): action is AllEntitiesApiRequestAction {
return isActionOf(
[
Expand All @@ -160,7 +160,7 @@ type AllEntitiesApiSuccessAction = ActionType<
>;

function isAllEntitiesApiSuccessAction(
action: AnyAction,
action: Action,
): action is AllEntitiesApiSuccessAction {
return isActionOf(
[
Expand All @@ -177,7 +177,7 @@ type AllEntitiesApiFailureAction = ActionType<
>;

function isAllEntitiesApiFailureAction(
action: AnyAction,
action: Action,
): action is AllEntitiesApiFailureAction {
return isActionOf(
[
Expand Down
6 changes: 3 additions & 3 deletions src/redux/app/appReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { isDevelopmentMode } from "~/utilities/environment";

import * as appActions from "./appActions";

export interface AppState {
readonly notifications: Notification[];
}
export type AppState = Readonly<{
notifications: Notification[];
}>;

export const appInitialState: AppState = {
notifications: [],
Expand Down
20 changes: 10 additions & 10 deletions src/redux/clients/clientsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { allEntitiesFlushed } from "~/redux/allEntities/allEntitiesActions";
import {
createReducer,
isActionOf,
type AnyAction,
type Action,
type ActionType,
} from "~/redux/reduxTools";
import { Mapping, type Client } from "~/types";

import * as clientsActions from "./clientsActions";

export interface ClientsState {
readonly source: Dictionary<Client>;
readonly target: Dictionary<Client>;
readonly isFetching: boolean;
}
export type ClientsState = Readonly<{
source: Dictionary<Client>;
target: Dictionary<Client>;
isFetching: boolean;
}>;

export const clientsInitialState: ClientsState = {
source: {},
Expand Down Expand Up @@ -68,7 +68,7 @@ type ClientsCreateOrFetchSuccessAction = ActionType<
>;

function isClientsApiSuccessAction(
action: AnyAction,
action: Action,
): action is ClientsCreateOrFetchSuccessAction {
return isActionOf(
[clientsActions.createClients.success, clientsActions.fetchClients.success],
Expand All @@ -83,7 +83,7 @@ type ClientsApiRequestAction = ActionType<
>;

function isClientsApiRequestAction(
action: AnyAction,
action: Action,
): action is ClientsApiRequestAction {
return isActionOf(
[
Expand All @@ -102,7 +102,7 @@ type ClientsApiFailureAction = ActionType<
>;

function isClientsApiFailureAction(
action: AnyAction,
action: Action,
): action is ClientsApiFailureAction {
return isActionOf(
[
Expand All @@ -119,7 +119,7 @@ type ResetClientsStateAction = ActionType<
>;

function isResetClientsStateAction(
action: AnyAction,
action: Action,
): action is ResetClientsStateAction {
return isActionOf(
[clientsActions.deleteClients.success, allEntitiesFlushed],
Expand Down
12 changes: 6 additions & 6 deletions src/redux/credentials/credentialsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {

import * as credentialsActions from "./credentialsActions";

export interface CredentialsState {
readonly source: Credentials;
readonly target: Credentials;
readonly validationErrorsByMapping: ValidationErrorsByMapping;
readonly validationFetchStatus: FetchStatus;
}
export type CredentialsState = Readonly<{
source: Credentials;
target: Credentials;
validationErrorsByMapping: ValidationErrorsByMapping;
validationFetchStatus: FetchStatus;
}>;

const DEFAULT_VALIDATION_ERRORS = {
source: null,
Expand Down
20 changes: 10 additions & 10 deletions src/redux/projects/projectsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { allEntitiesFlushed } from "~/redux/allEntities/allEntitiesActions";
import {
createReducer,
isActionOf,
type Action,
type ActionType,
type AnyAction,
} from "~/redux/reduxTools";
import { Mapping, type Project } from "~/types";

import * as projectsActions from "./projectsActions";

export interface ProjectsState {
readonly source: Dictionary<Project>;
readonly target: Dictionary<Project>;
readonly isFetching: boolean;
}
export type ProjectsState = Readonly<{
source: Dictionary<Project>;
target: Dictionary<Project>;
isFetching: boolean;
}>;

export const projectsInitialState: ProjectsState = {
source: {},
Expand Down Expand Up @@ -75,7 +75,7 @@ type ProjectsCreateOrFetchSuccessAction = ActionType<
>;

function isProjectsApiSuccessAction(
action: AnyAction,
action: Action,
): action is ProjectsCreateOrFetchSuccessAction {
return isActionOf(
[
Expand All @@ -93,7 +93,7 @@ type ProjectsApiRequestAction = ActionType<
>;

function isProjectsApiRequestAction(
action: AnyAction,
action: Action,
): action is ProjectsApiRequestAction {
return isActionOf(
[
Expand All @@ -112,7 +112,7 @@ type ProjectsApiFailureAction = ActionType<
>;

function isProjectsApiFailureAction(
action: AnyAction,
action: Action,
): action is ProjectsApiFailureAction {
return isActionOf(
[
Expand All @@ -129,7 +129,7 @@ type ResetProjectsStateAction = ActionType<
>;

function isResetProjectsStateAction(
action: AnyAction,
action: Action,
): action is ResetProjectsStateAction {
return isActionOf(
[projectsActions.deleteProjects.success, allEntitiesFlushed],
Expand Down
2 changes: 1 addition & 1 deletion src/redux/reduxTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {
createReducer,
createSelector,
nanoid,
type AnyAction,
type Action,
type Selector,
} from "@reduxjs/toolkit";

Expand Down
20 changes: 10 additions & 10 deletions src/redux/tags/tagsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { allEntitiesFlushed } from "~/redux/allEntities/allEntitiesActions";
import {
createReducer,
isActionOf,
type Action,
type ActionType,
type AnyAction,
} from "~/redux/reduxTools";
import { Mapping, type Tag } from "~/types";

import * as tagsActions from "./tagsActions";

export interface TagsState {
readonly source: Dictionary<Tag>;
readonly target: Dictionary<Tag>;
readonly isFetching: boolean;
}
export type TagsState = Readonly<{
source: Dictionary<Tag>;
target: Dictionary<Tag>;
isFetching: boolean;
}>;

export const tagsInitialState: TagsState = {
source: {},
Expand Down Expand Up @@ -64,7 +64,7 @@ type TagsCreateOrFetchSuccessAction = ActionType<
>;

function isTagsApiSuccessAction(
action: AnyAction,
action: Action,
): action is TagsCreateOrFetchSuccessAction {
return isActionOf(
[tagsActions.createTags.success, tagsActions.fetchTags.success],
Expand All @@ -79,7 +79,7 @@ type TagsApiRequestAction = ActionType<
>;

function isTagsApiRequestAction(
action: AnyAction,
action: Action,
): action is TagsApiRequestAction {
return isActionOf(
[
Expand All @@ -98,7 +98,7 @@ type TagsApiFailureAction = ActionType<
>;

function isTagsApiFailureAction(
action: AnyAction,
action: Action,
): action is TagsApiFailureAction {
return isActionOf(
[
Expand All @@ -115,7 +115,7 @@ type ResetTagsStateAction = ActionType<
>;

function isResetTagsStateAction(
action: AnyAction,
action: Action,
): action is ResetTagsStateAction {
return isActionOf(
[tagsActions.deleteTags.success, allEntitiesFlushed],
Expand Down
20 changes: 10 additions & 10 deletions src/redux/tasks/tasksReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { allEntitiesFlushed } from "~/redux/allEntities/allEntitiesActions";
import {
createReducer,
isActionOf,
type Action,
type ActionType,
type AnyAction,
} from "~/redux/reduxTools";
import { Mapping, type Task } from "~/types";

import * as tasksActions from "./tasksActions";

export interface TasksState {
readonly source: Dictionary<Task>;
readonly target: Dictionary<Task>;
readonly isFetching: boolean;
}
export type TasksState = Readonly<{
source: Dictionary<Task>;
target: Dictionary<Task>;
isFetching: boolean;
}>;

export const tasksInitialState: TasksState = {
source: {},
Expand Down Expand Up @@ -75,7 +75,7 @@ type TasksCreateOrFetchSuccessAction = ActionType<
>;

function isTasksApiSuccessAction(
action: AnyAction,
action: Action,
): action is TasksCreateOrFetchSuccessAction {
return isActionOf(
[tasksActions.createTasks.success, tasksActions.fetchTasks.success],
Expand All @@ -90,7 +90,7 @@ type TasksApiRequestAction = ActionType<
>;

function isTasksApiRequestAction(
action: AnyAction,
action: Action,
): action is TasksApiRequestAction {
return isActionOf(
[
Expand All @@ -109,7 +109,7 @@ type TasksApiFailureAction = ActionType<
>;

function isTasksApiFailureAction(
action: AnyAction,
action: Action,
): action is TasksApiFailureAction {
return isActionOf(
[
Expand All @@ -126,7 +126,7 @@ type ResetTasksStateAction = ActionType<
>;

function isResetTasksStateAction(
action: AnyAction,
action: Action,
): action is ResetTasksStateAction {
return isActionOf(
[tasksActions.deleteTasks.success, allEntitiesFlushed],
Expand Down
Loading

0 comments on commit 69ea417

Please sign in to comment.