Skip to content

Commit

Permalink
refactor types
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan-Y-Ko committed Oct 1, 2024
1 parent 2ab7364 commit 8aa077f
Show file tree
Hide file tree
Showing 23 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/app/(auth)/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { formatInTimeZone } from "date-fns-tz";
import { clientSignIn, clientSignOut } from "@/store/features/auth/authSlice";
import { useAppDispatch } from "@/store/hooks";
import { type User, getUserState } from "@/store/features/user/userSlice";
import { type AppError } from "@/modules/shared/types";
import { type AppError } from "@/types/types";
import { currentDate } from "@/utils/getCurrentSprint";

interface AuthProviderProps {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(auth)/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { cookies } from "next/headers";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { getAccessToken, getRefreshToken } from "@/utils/getCookie";
import { POST, UNAUTHPOST } from "@/utils/requests";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { fetchSprints } from "@/myVoyage/sprints/components/RedirectToCurrentSpr
import { fetchMeeting } from "@/myVoyage/sprints/components/SprintWrapper";
import type { User } from "@/store/features/user/userSlice";
import type { Sprint, Voyage } from "@/store/features/sprint/sprintSlice";
import type { AppError, AsyncActionResponse } from "@/modules/shared/types";
import { type AppError } from "@/types/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { getCurrentSprint } from "@/utils/getCurrentSprint";
import { getCurrentVoyageData } from "@/utils/getCurrentVoyageData";
import { fetchResources } from "@/app/(main)/my-voyage/[teamId]/voyage-resources/components/ResourcesComponentWrapper";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { type TeamDirectory } from "@/store/features/directory/directorySlice";

import { getAccessToken } from "@/utils/getCookie";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { GET } from "@/utils/requests";
import { CacheTag } from "@/utils/cacheTag";
import { type User } from "@/store/features/user/userSlice";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { revalidateTag } from "next/cache";
import { getAccessToken } from "@/utils/getCookie";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { PATCH } from "@/utils/requests";
import { CacheTag } from "@/utils/cacheTag";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { getAccessToken } from "@/utils/getCookie";
import { GET } from "@/utils/requests";
import { CacheTag } from "@/utils/cacheTag";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { ErrorType } from "@/utils/error";

function transformData(features: Features[]): FeaturesList[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type Features } from "@/store/features/features/featuresSlice";
import { CacheTag } from "@/utils/cacheTag";
import { getAccessToken } from "@/utils/getCookie";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { DELETE, PATCH, POST } from "@/utils/requests";

interface SaveOrderProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IdeationClientAdapter } from "./ideationClientAdapter";
import { getAccessToken } from "@/utils/getCookie";
import { DELETE, PATCH, POST } from "@/utils/requests";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { CacheTag } from "@/utils/cacheTag";
import { type AddIdeationResponseDto } from "@/modules/ideation/application/dtos/response.dto";
import { type AddIdeationUsecaseDto } from "@/modules/ideation/application/dtos/addIdeationUsecaseDto";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getAccessToken } from "@/utils/getCookie";
import { getCurrentVoyageData } from "@/utils/getCurrentVoyageData";
import { getUser } from "@/utils/getUser";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { GET } from "@/utils/requests";
import routePaths from "@/utils/routePaths";
import { ErrorType } from "@/utils/error";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { getCurrentSprint } from "@/utils/getCurrentSprint";
import { GET } from "@/utils/requests";
import { CacheTag } from "@/utils/cacheTag";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { type Sprint } from "@/store/features/sprint/sprintSlice";
import { getCurrentVoyageData } from "@/utils/getCurrentVoyageData";
import routePaths from "@/utils/routePaths";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {

import { getCurrentSprint } from "@/utils/getCurrentSprint";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { GET } from "@/utils/requests";
import { getAccessToken } from "@/utils/getCookie";
import { getUser } from "@/utils/getUser";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getUser } from "@/utils/getUser";
import { GET } from "@/utils/requests";
import { CacheTag } from "@/utils/cacheTag";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { getCurrentVoyageData } from "@/utils/getCurrentVoyageData";
import routePaths from "@/utils/routePaths";
import { Forms } from "@/utils/form/formsEnums";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { revalidateTag } from "next/cache";
import { getAccessToken } from "@/utils/getCookie";
import { DELETE, PATCH, POST } from "@/utils/requests";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { CacheTag } from "@/utils/cacheTag";
import { getSprintCache } from "@/utils/getSprintCache";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Category } from "./finalize/types";
import { CacheTag } from "@/utils/cacheTag";
import { getAccessToken } from "@/utils/getCookie";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { DELETE, PATCH, POST } from "@/utils/requests";
import { type TechStackItem } from "@/store/features/techStack/techStackSlice";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { revalidateTag } from "next/cache";
import { getAccessToken } from "@/utils/getCookie";
import { POST, DELETE } from "@/utils/requests";
import { handleAsync } from "@/utils/handleAsync";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { CacheTag } from "@/utils/cacheTag";

interface ResourceProps {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useServerAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useCallback, useState } from "react";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";

type ActionType<X, Y> = (arg: X) => Promise<AsyncActionResponse<Y>>;

Expand Down
6 changes: 0 additions & 6 deletions src/modules/shared/types.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/store/features/modal/modalSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type DeleteFeatureProps,
type deleteFeature,
} from "@/myVoyage/features/featuresService";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import {
type DeleteAgendaTopicProps,
type DeleteAgendaTopicResponse,
Expand Down
3 changes: 3 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// only put global types here
export interface AppError {
message: string;
}
3 changes: 2 additions & 1 deletion src/utils/getCurrentVoyageData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getCurrentVoyageTeam } from "./getCurrentVoyageTeam";
import type { AsyncActionResponse, AppError } from "@/modules/shared/types";
import { type AppError } from "@/types/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { type User } from "@/store/features/user/userSlice";

interface GetCurrentVoyageDataProps<X, Y> {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getCurrentVoyageTeam.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type AppError } from "@/modules/shared/types";
import { type AppError } from "@/types/types";
import {
type User,
type VoyageTeamMember,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getUser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getAccessToken } from "./getCookie";
import { handleAsync } from "./handleAsync";
import { GET } from "./requests";
import { type AsyncActionResponse } from "@/modules/shared/types";
import { type AsyncActionResponse } from "@/utils/handleAsync";
import { type User } from "@/store/features/user/userSlice";

export function getUser(): Promise<AsyncActionResponse<User>> {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/handleAsync.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
type AsyncActionResponse,
type AsyncFunction,
} from "@/modules/shared/types";
import { type AppError } from "@/types/types";

export type AsyncFunction<X> = () => Promise<X>;
export type AsyncActionResponse<X> = [X | null, AppError | null];

export async function handleAsync<X>(
asyncFn: AsyncFunction<X>,
Expand Down

0 comments on commit 8aa077f

Please sign in to comment.