From d4db853c3ec3d09e3684f7edf8be231917c66df8 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Thu, 8 Feb 2024 17:58:55 -0300 Subject: [PATCH] frontend: add ~ alias --- twenty-frontend/src/js/components/App.tsx | 2 +- twenty-frontend/src/js/components/Group.tsx | 4 ++-- twenty-frontend/src/js/components/NavBar.tsx | 6 +++--- .../src/js/components/ProjectSelect.tsx | 6 +++--- twenty-frontend/src/js/components/Projects.tsx | 8 ++++---- twenty-frontend/src/js/components/Task.tsx | 18 +++++++++--------- .../src/js/components/TaskStatusSelect.tsx | 6 +++--- twenty-frontend/src/js/components/Tasks.tsx | 10 +++++----- .../src/js/hooks/mutations/useCompleteTask.ts | 2 +- .../src/js/hooks/mutations/useCreateTask.ts | 2 +- .../src/js/hooks/mutations/useDestroyTask.ts | 2 +- .../mutations/useSetRandomProjectColor.tsx | 2 +- .../src/js/hooks/mutations/useUpdateTask.ts | 2 +- .../src/js/hooks/queries/useFindTask.ts | 2 +- .../src/js/hooks/queries/useTasks.ts | 2 +- twenty-frontend/src/js/main/projects.tsx | 4 ++-- twenty-frontend/src/js/main/task/edit.tsx | 4 ++-- twenty-frontend/src/js/main/task/new.tsx | 4 ++-- twenty-frontend/src/js/main/tasks.tsx | 4 ++-- twenty-frontend/tsconfig.json | 4 ++-- twenty-frontend/webpack.config.js | 6 ++++-- 21 files changed, 51 insertions(+), 49 deletions(-) diff --git a/twenty-frontend/src/js/components/App.tsx b/twenty-frontend/src/js/components/App.tsx index 9eb4bba..51c83fb 100644 --- a/twenty-frontend/src/js/components/App.tsx +++ b/twenty-frontend/src/js/components/App.tsx @@ -1,6 +1,6 @@ import { PropsWithChildren } from "react"; import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client"; -import { ParamContext } from "/Context"; +import { ParamContext } from "~/Context"; export function App({ children }: PropsWithChildren<{}>) { const client = new ApolloClient({ diff --git a/twenty-frontend/src/js/components/Group.tsx b/twenty-frontend/src/js/components/Group.tsx index cb81b8a..b39328b 100644 --- a/twenty-frontend/src/js/components/Group.tsx +++ b/twenty-frontend/src/js/components/Group.tsx @@ -1,8 +1,8 @@ -import type { Task } from "/types/schema"; +import type { Task } from "~/types/schema"; import classnames from "classnames"; import { DateTime } from "luxon"; import { QueryResult } from "@apollo/client"; -import { TaskStatusSelect } from "/components/TaskStatusSelect"; +import { TaskStatusSelect } from "~/components/TaskStatusSelect"; type Props = { groupName: string; diff --git a/twenty-frontend/src/js/components/NavBar.tsx b/twenty-frontend/src/js/components/NavBar.tsx index 9cd2fca..f395380 100644 --- a/twenty-frontend/src/js/components/NavBar.tsx +++ b/twenty-frontend/src/js/components/NavBar.tsx @@ -1,7 +1,7 @@ import { useContext } from "react"; -import { ParamContext } from "/Context"; -import { Maybe } from "/types/schema"; -import { ProjectSelect } from "/components/ProjectSelect"; +import { ParamContext } from "~/Context"; +import { Maybe } from "~/types/schema"; +import { ProjectSelect } from "~/components/ProjectSelect"; const BASE_CLASSNAMES = ["block", "w-3/4", "no-underline", "p-3", "mt-2"]; const ACTIVE_CLASSNAMES = [ ...BASE_CLASSNAMES, diff --git a/twenty-frontend/src/js/components/ProjectSelect.tsx b/twenty-frontend/src/js/components/ProjectSelect.tsx index 3f9d1ed..9ddcfc0 100644 --- a/twenty-frontend/src/js/components/ProjectSelect.tsx +++ b/twenty-frontend/src/js/components/ProjectSelect.tsx @@ -1,6 +1,6 @@ -import { useProjects } from "/hooks/queries/useProjects"; -import { Project, Maybe } from "/types/schema"; -import { Select, Option } from "/components/Select"; +import { useProjects } from "~/hooks/queries/useProjects"; +import { Project, Maybe } from "~/types/schema"; +import { Select, Option } from "~/components/Select"; type Props = { selected: Maybe; diff --git a/twenty-frontend/src/js/components/Projects.tsx b/twenty-frontend/src/js/components/Projects.tsx index da623a1..59f0002 100644 --- a/twenty-frontend/src/js/components/Projects.tsx +++ b/twenty-frontend/src/js/components/Projects.tsx @@ -1,8 +1,8 @@ -import { useSetRandomProjectColor } from "/hooks/mutations/useSetRandomProjectColor"; +import { useSetRandomProjectColor } from "~/hooks/mutations/useSetRandomProjectColor"; import { useEffect } from "react"; -import { NavBar } from "/components/NavBar"; -import { useProjects } from "/hooks/queries/useProjects"; -import { Project } from "/types/schema"; +import { NavBar } from "~/components/NavBar"; +import { useProjects } from "~/hooks/queries/useProjects"; +import { Project } from "~/types/schema"; export function Projects() { const { data, loading } = useProjects(); diff --git a/twenty-frontend/src/js/components/Task.tsx b/twenty-frontend/src/js/components/Task.tsx index d9596c7..8b037ee 100644 --- a/twenty-frontend/src/js/components/Task.tsx +++ b/twenty-frontend/src/js/components/Task.tsx @@ -1,14 +1,14 @@ import { useEffect, useState, useContext } from "react"; -import { ParamContext } from "/Context"; +import { ParamContext } from "~/Context"; import { useForm } from "react-hook-form"; -import { useCreateTask } from "/hooks/mutations/useCreateTask"; -import { useUpdateTask } from "/hooks/mutations/useUpdateTask"; -import { useFindTask } from "/hooks/queries/useFindTask"; -import { useProjects } from "/hooks/queries/useProjects"; -import { Task, Project, TaskInput, Maybe } from "/types/schema"; -import { rendermd } from "/lib/markdown-utils"; -import { NavBar } from "/components/NavBar"; -import { Tabs, Tab } from "/components/Tabs"; +import { useCreateTask } from "~/hooks/mutations/useCreateTask"; +import { useUpdateTask } from "~/hooks/mutations/useUpdateTask"; +import { useFindTask } from "~/hooks/queries/useFindTask"; +import { useProjects } from "~/hooks/queries/useProjects"; +import { Task, Project, TaskInput, Maybe } from "~/types/schema"; +import { rendermd } from "~/lib/markdown-utils"; +import { NavBar } from "~/components/NavBar"; +import { Tabs, Tab } from "~/components/Tabs"; const DEFAULT_TASK_CONTENT = [ "## Subtasks", diff --git a/twenty-frontend/src/js/components/TaskStatusSelect.tsx b/twenty-frontend/src/js/components/TaskStatusSelect.tsx index 55b6c9c..4b81115 100644 --- a/twenty-frontend/src/js/components/TaskStatusSelect.tsx +++ b/twenty-frontend/src/js/components/TaskStatusSelect.tsx @@ -1,6 +1,6 @@ -import { Task, TaskStatus } from "/types/schema"; -import { useUpdateTask } from "hooks/mutations/useUpdateTask"; -import { GET_TASKS } from "/hooks/queries/useTasks"; +import { Task, TaskStatus } from "~/types/schema"; +import { useUpdateTask } from "~/hooks/mutations/useUpdateTask"; +import { GET_TASKS } from "~/hooks/queries/useTasks"; type Props = { task: Task; diff --git a/twenty-frontend/src/js/components/Tasks.tsx b/twenty-frontend/src/js/components/Tasks.tsx index 1e6044e..7349108 100644 --- a/twenty-frontend/src/js/components/Tasks.tsx +++ b/twenty-frontend/src/js/components/Tasks.tsx @@ -1,9 +1,9 @@ import { useEffect, useContext } from "react"; -import { ParamContext } from "/Context"; -import { NavBar } from "/components/NavBar"; -import { Group } from "/components/Group"; -import { TaskStatus, Maybe } from "/types/schema"; -import { useTasks } from "/hooks/queries/useTasks"; +import { ParamContext } from "~/Context"; +import { NavBar } from "~/components/NavBar"; +import { Group } from "~/components/Group"; +import { TaskStatus, Maybe } from "~/types/schema"; +import { useTasks } from "~/hooks/queries/useTasks"; export function Tasks() { const params = useContext(ParamContext); diff --git a/twenty-frontend/src/js/hooks/mutations/useCompleteTask.ts b/twenty-frontend/src/js/hooks/mutations/useCompleteTask.ts index 20752e8..49a0d20 100644 --- a/twenty-frontend/src/js/hooks/mutations/useCompleteTask.ts +++ b/twenty-frontend/src/js/hooks/mutations/useCompleteTask.ts @@ -1,5 +1,5 @@ import { gql, useMutation } from "@apollo/client"; -import { CompleteTaskPayload, MutationCompleteTaskArgs } from "/types/schema"; +import { CompleteTaskPayload, MutationCompleteTaskArgs } from "~/types/schema"; const GQL = gql` mutation CompleteTask($taskId: Int!) { diff --git a/twenty-frontend/src/js/hooks/mutations/useCreateTask.ts b/twenty-frontend/src/js/hooks/mutations/useCreateTask.ts index 646d18a..860ccb4 100644 --- a/twenty-frontend/src/js/hooks/mutations/useCreateTask.ts +++ b/twenty-frontend/src/js/hooks/mutations/useCreateTask.ts @@ -2,7 +2,7 @@ import { CreateTaskPayload, MutationCreateTaskArgs, TaskInput, -} from "/types/schema"; +} from "~/types/schema"; import { gql, useMutation } from "@apollo/client"; const GQL = gql` diff --git a/twenty-frontend/src/js/hooks/mutations/useDestroyTask.ts b/twenty-frontend/src/js/hooks/mutations/useDestroyTask.ts index 46b1558..f238bb4 100644 --- a/twenty-frontend/src/js/hooks/mutations/useDestroyTask.ts +++ b/twenty-frontend/src/js/hooks/mutations/useDestroyTask.ts @@ -1,5 +1,5 @@ import { gql, useMutation } from "@apollo/client"; -import { DestroyTaskPayload, MutationDestroyTaskArgs } from "/types/schema"; +import { DestroyTaskPayload, MutationDestroyTaskArgs } from "~/types/schema"; const GQL = gql` mutation DestroyTask($taskId: Int!) { diff --git a/twenty-frontend/src/js/hooks/mutations/useSetRandomProjectColor.tsx b/twenty-frontend/src/js/hooks/mutations/useSetRandomProjectColor.tsx index 6008d5e..8f39be8 100644 --- a/twenty-frontend/src/js/hooks/mutations/useSetRandomProjectColor.tsx +++ b/twenty-frontend/src/js/hooks/mutations/useSetRandomProjectColor.tsx @@ -3,7 +3,7 @@ import { SetRandomProjectColorPayload, MutationSetRandomProjectColorArgs, Project, -} from "/types/schema"; +} from "~/types/schema"; const GQL = gql` mutation SetRandomProjectColor($projectId: Int!) { diff --git a/twenty-frontend/src/js/hooks/mutations/useUpdateTask.ts b/twenty-frontend/src/js/hooks/mutations/useUpdateTask.ts index 5c62501..917049a 100644 --- a/twenty-frontend/src/js/hooks/mutations/useUpdateTask.ts +++ b/twenty-frontend/src/js/hooks/mutations/useUpdateTask.ts @@ -2,7 +2,7 @@ import { UpdateTaskPayload, MutationUpdateTaskArgs, TaskInput, -} from "/types/schema"; +} from "~/types/schema"; import { gql, useMutation, DocumentNode } from "@apollo/client"; const GQL = gql` diff --git a/twenty-frontend/src/js/hooks/queries/useFindTask.ts b/twenty-frontend/src/js/hooks/queries/useFindTask.ts index 01760c7..60f2380 100644 --- a/twenty-frontend/src/js/hooks/queries/useFindTask.ts +++ b/twenty-frontend/src/js/hooks/queries/useFindTask.ts @@ -1,5 +1,5 @@ import { gql, useQuery } from "@apollo/client"; -import { Maybe, Task } from "/types/schema"; +import { Maybe, Task } from "~/types/schema"; const GQL = gql` query Query($taskId: Int!) { diff --git a/twenty-frontend/src/js/hooks/queries/useTasks.ts b/twenty-frontend/src/js/hooks/queries/useTasks.ts index b989b01..a3deb96 100644 --- a/twenty-frontend/src/js/hooks/queries/useTasks.ts +++ b/twenty-frontend/src/js/hooks/queries/useTasks.ts @@ -1,5 +1,5 @@ import { useQuery, gql } from "@apollo/client"; -import { Task } from "/types/schema"; +import { Task } from "~/types/schema"; export const GET_TASKS = gql` query GetTasks($status: TaskStatus!, $projectId: Int) { diff --git a/twenty-frontend/src/js/main/projects.tsx b/twenty-frontend/src/js/main/projects.tsx index 4e6a917..f0fe9e8 100644 --- a/twenty-frontend/src/js/main/projects.tsx +++ b/twenty-frontend/src/js/main/projects.tsx @@ -1,6 +1,6 @@ import ReactDOM from "react-dom/client"; -import { App } from "/components/App"; -import { Projects } from "/components/Projects"; +import { App } from "~/components/App"; +import { Projects } from "~/components/Projects"; (function () { const root = document.querySelector(".react-root")!; diff --git a/twenty-frontend/src/js/main/task/edit.tsx b/twenty-frontend/src/js/main/task/edit.tsx index 339412a..1194213 100644 --- a/twenty-frontend/src/js/main/task/edit.tsx +++ b/twenty-frontend/src/js/main/task/edit.tsx @@ -1,6 +1,6 @@ import ReactDOM from "react-dom/client"; -import { App } from "/components/App"; -import { Task } from "/components/Task"; +import { App } from "~/components/App"; +import { Task } from "~/components/Task"; (function () { const root = document.querySelector(".react-root")!; diff --git a/twenty-frontend/src/js/main/task/new.tsx b/twenty-frontend/src/js/main/task/new.tsx index 339412a..1194213 100644 --- a/twenty-frontend/src/js/main/task/new.tsx +++ b/twenty-frontend/src/js/main/task/new.tsx @@ -1,6 +1,6 @@ import ReactDOM from "react-dom/client"; -import { App } from "/components/App"; -import { Task } from "/components/Task"; +import { App } from "~/components/App"; +import { Task } from "~/components/Task"; (function () { const root = document.querySelector(".react-root")!; diff --git a/twenty-frontend/src/js/main/tasks.tsx b/twenty-frontend/src/js/main/tasks.tsx index 18d42cd..0e70807 100644 --- a/twenty-frontend/src/js/main/tasks.tsx +++ b/twenty-frontend/src/js/main/tasks.tsx @@ -1,6 +1,6 @@ import ReactDOM from "react-dom/client"; -import { App } from "/components/App"; -import { Tasks } from "/components/Tasks"; +import { App } from "~/components/App"; +import { Tasks } from "~/components/Tasks"; (function () { const root = document.querySelector(".react-root")!; diff --git a/twenty-frontend/tsconfig.json b/twenty-frontend/tsconfig.json index 945cfa9..1b9a130 100644 --- a/twenty-frontend/tsconfig.json +++ b/twenty-frontend/tsconfig.json @@ -11,7 +11,7 @@ "allowJs": true, "lib": [ "ES2022", "DOM" ], "allowUmdGlobalAccess": true, - "baseUrl": "src/", - "paths": { "*": ["js/*"] }, + "baseUrl": "./src", + "paths": { "~/*": ["./js/*"] }, } } diff --git a/twenty-frontend/webpack.config.js b/twenty-frontend/webpack.config.js index 0a969d7..aef8bac 100644 --- a/twenty-frontend/webpack.config.js +++ b/twenty-frontend/webpack.config.js @@ -5,8 +5,10 @@ const process = require('process'); module.exports = { mode: process.env.NODE_ENV || "development", resolve: { - roots: [path.resolve('src/js'), path.resolve('node_modules')], - modules: [path.resolve('src/js'), path.resolve('node_modules')], + alias: { + '~': [path.resolve('src/js')] + }, + modules: [path.resolve('node_modules')], extensions: ['.js', '.ts', '.tsx'] }, module: {