@imj_media/tareas 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/.env.template +8 -0
  2. package/.storybook/main.ts +26 -0
  3. package/.storybook/preview.ts +15 -0
  4. package/LICENSE.md +21 -0
  5. package/README.md +50 -0
  6. package/core/actions/get_all_users.action.ts +16 -0
  7. package/core/actions/get_salesman_response.action.ts +16 -0
  8. package/core/actions/get_tasks_project.action.ts +62 -0
  9. package/core/actions/get_tasks_response.action.ts +56 -0
  10. package/eslint.config.js +28 -0
  11. package/global.d.ts +3 -0
  12. package/infraestructure/interfaces/salesmans-obp-response.ts +43 -0
  13. package/infraestructure/interfaces/salesmans-obp.ts +4 -0
  14. package/infraestructure/interfaces/tasks-campania-response.ts +118 -0
  15. package/infraestructure/interfaces/tasks-campania.ts +26 -0
  16. package/infraestructure/interfaces/tasks-kanban-general.ts +25 -0
  17. package/infraestructure/interfaces/tasks-reponse.ts +111 -0
  18. package/infraestructure/interfaces/teams-response.ts +7 -0
  19. package/infraestructure/interfaces/teams.ts +5 -0
  20. package/infraestructure/interfaces/users-obp-response.ts +52 -0
  21. package/infraestructure/interfaces/users.ts +5 -0
  22. package/infraestructure/mappers/all-users-obp.ts +12 -0
  23. package/infraestructure/mappers/campaign-tasks.ts +35 -0
  24. package/infraestructure/mappers/kanban-tasks.ts +35 -0
  25. package/infraestructure/mappers/salesmans-obp.ts +11 -0
  26. package/infraestructure/mappers/teams.ts +12 -0
  27. package/package.json +61 -0
  28. package/postcss.config.js +6 -0
  29. package/src/components/atoms/Avatar.tsx +14 -0
  30. package/src/components/atoms/Comment.tsx +33 -0
  31. package/src/components/atoms/InputSearch.tsx +40 -0
  32. package/src/components/atoms/SkeletonCard.tsx +17 -0
  33. package/src/components/atoms/TabButton.tsx +16 -0
  34. package/src/components/atoms/TooltipUser.tsx +26 -0
  35. package/src/components/atoms/index.ts +2 -0
  36. package/src/components/index.ts +3 -0
  37. package/src/components/kanban-campania/DoneBoard.tsx +12 -0
  38. package/src/components/kanban-campania/KanbanCampania.tsx +39 -0
  39. package/src/components/kanban-campania/ToDoBoard.tsx +12 -0
  40. package/src/components/kanban-campania/WorkingBoard.tsx +13 -0
  41. package/src/components/kanban-campania/filters.ts +46 -0
  42. package/src/components/kanban-campania/index.ts +3 -0
  43. package/src/components/kanban-general/DoneBoard.tsx +12 -0
  44. package/src/components/kanban-general/KanbanGeneral.tsx +40 -0
  45. package/src/components/kanban-general/ToDoBoard.tsx +12 -0
  46. package/src/components/kanban-general/WorkingBoard.tsx +13 -0
  47. package/src/components/kanban-general/filters.ts +58 -0
  48. package/src/components/kanban-general/index.ts +3 -0
  49. package/src/components/layout/FilterButton.tsx +50 -0
  50. package/src/components/layout/FilterContent.tsx +70 -0
  51. package/src/components/layout/IndexComponents.tsx +32 -0
  52. package/src/components/lista-campania/ChildTask.tsx +22 -0
  53. package/src/components/lista-campania/Date.tsx +30 -0
  54. package/src/components/lista-campania/ListaCampania.tsx +21 -0
  55. package/src/components/lista-campania/ParentTask.tsx +57 -0
  56. package/src/components/molecules/AllComments.tsx +78 -0
  57. package/src/components/molecules/ButtonAssignUsers.tsx +175 -0
  58. package/src/components/molecules/DependentTasks.tsx +64 -0
  59. package/src/components/molecules/Tabs.tsx +39 -0
  60. package/src/components/molecules/index.ts +1 -0
  61. package/src/components/organisms/Board.tsx +87 -0
  62. package/src/components/organisms/Checkbox.tsx +45 -0
  63. package/src/components/organisms/DetailsTask.tsx +286 -0
  64. package/src/components/organisms/TabDetailsTask.tsx +39 -0
  65. package/src/components/organisms/Task.tsx +176 -0
  66. package/src/components/organisms/index.ts +2 -0
  67. package/src/components/tasks/PriorityButton.tsx +79 -0
  68. package/src/components/templates/Layout.tsx +84 -0
  69. package/src/components/templates/TableList/components/TableList.scss +270 -0
  70. package/src/components/templates/TableList/components/TableList.tsx +239 -0
  71. package/src/components/templates/TableList/components/index.tsx +1 -0
  72. package/src/constants/colors.ts +64 -0
  73. package/src/constants/gaps.ts +8 -0
  74. package/src/constants/paddings.ts +8 -0
  75. package/src/constants/shadows.ts +5 -0
  76. package/src/context/filtersLayout.context.tsx +118 -0
  77. package/src/context/kanbanCampania.context.tsx +50 -0
  78. package/src/context/useApis.context.tsx +47 -0
  79. package/src/context/userLog.context.tsx +50 -0
  80. package/src/env.d.ts +10 -0
  81. package/src/functions/taskCalculations.tsx +818 -0
  82. package/src/hooks/useAllUsers.ts +18 -0
  83. package/src/hooks/useCheckTask.tsx +15 -0
  84. package/src/hooks/useComerciales.ts +58 -0
  85. package/src/hooks/useDoneTasks.ts +90 -0
  86. package/src/hooks/useElementPosition.ts +34 -0
  87. package/src/hooks/useFunctionsTasks.ts +57 -0
  88. package/src/hooks/useNormalizedData.ts +36 -0
  89. package/src/hooks/useTeams.ts +19 -0
  90. package/src/hooks/useToDoTasks.ts +89 -0
  91. package/src/hooks/useWorkingTasks.ts +85 -0
  92. package/src/index.css +55 -0
  93. package/src/index.ts +2 -0
  94. package/src/index.tsx +1 -0
  95. package/src/pages/App.tsx +42 -0
  96. package/src/pages/NoAccessToken.tsx +20 -0
  97. package/src/pages/NoUser.tsx +20 -0
  98. package/src/stories/AppTasks.stories.tsx +36 -0
  99. package/src/stories/Table.stories.tsx +160 -0
  100. package/src/types/index.ts +107 -0
  101. package/src/types/interfaces.ts +67 -0
  102. package/src/types/layout.types.ts +30 -0
  103. package/src/utils/filters.functions.ts +17 -0
  104. package/src/utils/formats.ts +33 -0
  105. package/src/utils/functionsStorybook.tsx +0 -0
  106. package/src/utils/inputs.functions.ts +25 -0
  107. package/src/utils/tanstack.functions.ts +19 -0
  108. package/src/utils/utils.ts +12 -0
  109. package/src/vite-env.d.ts +1 -0
  110. package/tailwind.config.js +31 -0
  111. package/tsconfig.app.json +26 -0
  112. package/tsconfig.json +7 -0
  113. package/tsconfig.node.json +24 -0
  114. package/vite.config.ts +16 -0
@@ -0,0 +1,64 @@
1
+
2
+ export const COLORS = {
3
+ bg: {
4
+ DEFAULT: "#EFEFEF",
5
+ content: "#FAFAFA",
6
+ card: "#FAFAFA",
7
+ //* To add the variant in Dark mode only add the -dark suffix to each color
8
+ },
9
+ texts: {
10
+ DEFAULT: "#252525",
11
+ enfasis: "#3658c1",
12
+ subtext: "#4f4f4f",
13
+ placeholder: "#929292",
14
+ },
15
+ primary:{
16
+ light:"#E7E9F2",
17
+ medium: "#dae2ec",
18
+ dark:"#334990",
19
+ regular: "#425CAC",
20
+ pastel:"#5c7ddd",
21
+ },
22
+ success:{
23
+ light:"#368156",
24
+ medium: "#D2E9DC",
25
+ dark:"#368156",
26
+ regular: "#43B071",
27
+ pastel:"#57BA81",
28
+ },
29
+ danger:{
30
+ light:"#F1E5E4",
31
+ medium: "#EBDBD9",
32
+ dark:"#8C352C",
33
+ regular: "#C34335",
34
+ pastel:"#C4335",
35
+ },
36
+ warning: {
37
+ light:"#F2ECE5",
38
+ medium: "#EBE3D9",
39
+ dark:"#B4782F",
40
+ regular: "#D38A31",
41
+ pastel:"#D38A31",
42
+ },
43
+ alert:{
44
+ light:"#F1F1E4",
45
+ medium: "#EAE9D9",
46
+ dark:"#ADA63A",
47
+ regular: "#D6CC48",
48
+ pastel:"#D6CC48",
49
+ },
50
+ info: {
51
+ light:"#E7F5FF",
52
+ medium: "#D9E6EE",
53
+ dark:"#1C5073",
54
+ regular: "#1B6698",
55
+ pastel:"#1B6698",
56
+ },
57
+ link:{
58
+ light:"#ECF8FE",
59
+ medium: "#D8F1FD",
60
+ dark:"#0A7AAE",
61
+ regular: "#0EA5E9",
62
+ pastel:"#0EA5E9",
63
+ },
64
+ }
@@ -0,0 +1,8 @@
1
+ export const GAPS = {
2
+ s:"4px",
3
+ m:"8px",
4
+ l:"12px",
5
+ xl:"16px",
6
+ xxl:"20px",
7
+ xxxl:"24px",
8
+ }
@@ -0,0 +1,8 @@
1
+ export const PADDINGS = {
2
+ s:"4px",
3
+ m:"8px",
4
+ l:"12px",
5
+ xl:"16px",
6
+ xxl:"20px",
7
+ xxxl:"24px",
8
+ }
@@ -0,0 +1,5 @@
1
+ export const SHADOWS = {
2
+ "button-primary":"inset 0 0 0 2px #dae2ec",
3
+ "button-primary-hover":"inset 0 0 0 2px #425CAC, 0 0 5px #00000030",
4
+ input:"inset 0 0 0 2px #dae2ec",
5
+ }
@@ -0,0 +1,118 @@
1
+ import React,{ createContext, useContext, useEffect, useState } from "react";
2
+ import { addEstructureToFilters } from "../utils/filters.functions";
3
+ export interface IFieldFilter {
4
+ label: string;
5
+ type: TType;
6
+ id: string;
7
+ options?: {id: string | number, name: string}[];
8
+ }
9
+
10
+ interface IFiltersLayoutContext {
11
+ fields: IFieldFilter[];
12
+ filters: FiltersContext;
13
+ defineFields: (fields: IFieldFilter[]) => void;
14
+ updateFilters: ({name, value}: {name: string, value: string}) => void;
15
+ cleanFilters: () => void;
16
+ applyFilters: () => void;
17
+ initialFilters: TFilters;
18
+ }
19
+
20
+ interface FiltersContext {
21
+ justProjects: boolean;
22
+ owner: IOwner;
23
+ }
24
+
25
+ interface IOwner {
26
+ user: string;
27
+ config: string;
28
+ }
29
+ export interface TFilters {
30
+ label: string;
31
+ type: TType;
32
+ id: string;
33
+ options?: {id: string | number, name: string}[];
34
+ [key: string]: any;
35
+ }
36
+ type TType = React.HTMLInputTypeAttribute;
37
+ const FiltersLayoutContext = createContext({} as IFiltersLayoutContext);
38
+
39
+ export const FiltersLayoutProvider = ({children}: {children: React.ReactNode}) => {
40
+ //TODO: add setFillters
41
+ const [filters, setFilters] = useState<FiltersContext>( {} as FiltersContext);
42
+ const [temporalFilters, setTemporalFilters] = useState<TFilters>( {} as TFilters);
43
+ const [fields, setFields] = useState<IFieldFilter[]>([]);
44
+
45
+ const updateFilters = ({name, value}: {name: string, value: string})=>{
46
+ function parseIfNumeric(val: string | number ) {
47
+ // Check if the value is numeric
48
+ if (!isNaN(val as number) && val !== null && val !== "") {
49
+ return parseFloat(val as string); // Parse the value as a float
50
+ }
51
+
52
+ // If not numeric, return null or handle as needed
53
+ return null;
54
+ }
55
+
56
+ let newValue = parseIfNumeric(value);
57
+ setTemporalFilters(prev=>{
58
+ let newFilters:any = {...prev};
59
+
60
+ let field = fields?.find(field=>field.label.toLowerCase().replace(/ /g, "_") === name)
61
+ if(field) newFilters[field.id] = newValue ?? value;
62
+ else newFilters[name] = newValue ?? value;
63
+ return newFilters
64
+ })
65
+ }
66
+
67
+ useEffect(()=>{
68
+ console.log(temporalFilters)
69
+ },[temporalFilters])
70
+
71
+ useEffect(()=>{
72
+ let newFilters = fields.map(field=>{
73
+ if(field.id === "owner.config") return [field.id, "yo_y_mis_equipos"]
74
+ if(field.id === "dependency") return [field.id, "sin"]
75
+ return [field.id, null]
76
+ })
77
+ setTemporalFilters(
78
+ Object.fromEntries(newFilters)
79
+ )
80
+ },[fields])
81
+
82
+ const cleanFilters = ()=>{
83
+ let newFilters = fields.map(field=>{
84
+ if(field.id === "owner.config") return [field.id, "yo_y_mis_equipos"]
85
+ if(field.id === "dependency") return [field.id, "sin"]
86
+ return [field.id, null]
87
+ })
88
+
89
+ setTemporalFilters( Object.fromEntries(newFilters) )
90
+ setFilters(addEstructureToFilters(temporalFilters))
91
+ }
92
+
93
+ const applyFilters = ()=>{
94
+ let filtersWithEstructure = addEstructureToFilters(temporalFilters)
95
+ setFilters(filtersWithEstructure)
96
+ }
97
+
98
+ return (
99
+ <FiltersLayoutContext.Provider value={{
100
+ //properties
101
+ fields,
102
+ filters,
103
+
104
+ //methods
105
+ defineFields: setFields,
106
+ updateFilters,
107
+ cleanFilters,
108
+ applyFilters,
109
+ initialFilters: temporalFilters
110
+ }}>
111
+ {children}
112
+ </FiltersLayoutContext.Provider>
113
+ )
114
+ }
115
+
116
+ export const useFiltersLayoutContext = () => {
117
+ return useContext(FiltersLayoutContext);
118
+ }
@@ -0,0 +1,50 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { createContext, useContext } from "react";
3
+ import { getTasksProject } from "../../core/actions/get_tasks_project.action";
4
+ import { useApis } from "./useApis.context";
5
+ import { useFiltersLayoutContext } from "./filtersLayout.context";
6
+ import { useUser } from "./userLog.context";
7
+ interface IInfoCampaniaContext {
8
+ children: React.ReactNode,
9
+ project: number
10
+ }
11
+
12
+ interface IValuesContext {
13
+ tasksProject: any
14
+ }
15
+
16
+ const KanbanCampaniaContext = createContext({} as IValuesContext);
17
+
18
+ export const InfoCampaniaProvider = ({children, project}: IInfoCampaniaContext) => {
19
+ const {tasks_api} = useApis();
20
+ const {filters} = useFiltersLayoutContext();
21
+ const {user} = useUser();
22
+
23
+ const tasksProject = useQuery({
24
+ queryKey: ["tasksProject", project],
25
+ queryFn: () => getTasksProject({
26
+ filters: {
27
+ owner:{
28
+ user: user.id,
29
+ config: (filters?.owner?.config ?? "yo_y_mis_equipos") as "yo_y_mis_equipos" | "mis_equipos" | "yo"
30
+ },
31
+ },
32
+ project,
33
+ tasks_api
34
+ })
35
+ })
36
+
37
+ const projectID = project ?? null
38
+
39
+
40
+ return (
41
+ <KanbanCampaniaContext.Provider value={{
42
+ //properties
43
+ tasksProject,
44
+ }}>
45
+ {children}
46
+ </KanbanCampaniaContext.Provider>
47
+ )
48
+ }
49
+
50
+ export const useInfoCampania = () => useContext(KanbanCampaniaContext);
@@ -0,0 +1,47 @@
1
+ import axios, { AxiosInstance } from "axios";
2
+ import qs from "qs";
3
+ import { createContext, useContext } from "react";
4
+
5
+
6
+ interface IUserLogContext {
7
+ user: User,
8
+ children: React.ReactNode,
9
+ env: Env,
10
+ }
11
+
12
+ interface User {
13
+ id: number,
14
+ accessToken: string,
15
+ }
16
+
17
+ interface IValuesContext {
18
+ tasks_api: AxiosInstance,
19
+ }
20
+
21
+ type Env = "dev" | "prod"
22
+
23
+ const ApiContext = createContext({} as IValuesContext);
24
+
25
+ export const UseApisProvider = ({children, user, env}: IUserLogContext) => {
26
+ const { VITE_PUBLIC_URL_DEV, VITE_PUBLIC_URL_PROD } = import.meta.env;
27
+
28
+ const tasks_api = axios.create({
29
+ baseURL: env === "dev" ? VITE_PUBLIC_URL_DEV : VITE_PUBLIC_URL_PROD,
30
+ headers: {
31
+ Authorization: `Bearer ${user.accessToken}`,
32
+ },
33
+ paramsSerializer: (params: any) => qs.stringify(params, { encodeValuesOnly: true }),
34
+ })
35
+
36
+
37
+ return (
38
+ <ApiContext.Provider value={{
39
+ //methods
40
+ tasks_api
41
+ }}>
42
+ {children}
43
+ </ApiContext.Provider>
44
+ )
45
+ }
46
+
47
+ export const useApis = () => useContext(ApiContext);
@@ -0,0 +1,50 @@
1
+ import axios, { AxiosInstance } from "axios";
2
+ import qs from "qs";
3
+ import { createContext, useContext } from "react";
4
+
5
+
6
+ interface IUserLogContext {
7
+ user: User,
8
+ children: React.ReactNode,
9
+ env: Env,
10
+ }
11
+
12
+ interface User {
13
+ id: number,
14
+ accessToken: string,
15
+ }
16
+
17
+ interface IValuesContext {
18
+ user: User,
19
+ tasks_api: AxiosInstance,
20
+ }
21
+
22
+ type Env = "dev" | "prod"
23
+
24
+ const UserLogContext = createContext({} as IValuesContext);
25
+
26
+ export const UserLogProvider = ({children, user, env}: IUserLogContext) => {
27
+ const { VITE_PUBLIC_URL_DEV, VITE_PUBLIC_URL_PROD } = import.meta.env;
28
+
29
+ const tasks_api = axios.create({
30
+ baseURL: env === "dev" ? VITE_PUBLIC_URL_DEV : VITE_PUBLIC_URL_PROD,
31
+ headers: {
32
+ Authorization: `Bearer ${user.accessToken}`,
33
+ },
34
+ paramsSerializer: (params: any) => qs.stringify(params, { encodeValuesOnly: true }),
35
+ })
36
+
37
+ return (
38
+ <UserLogContext.Provider value={{
39
+ //properties
40
+ user,
41
+
42
+ //methods
43
+ tasks_api
44
+ }}>
45
+ {children}
46
+ </UserLogContext.Provider>
47
+ )
48
+ }
49
+
50
+ export const useUser = () => useContext(UserLogContext);
package/src/env.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_PUBLIC_URL_DEV: string
5
+ readonly VITE_PUBLIC_TOKEN_CLIENT_DEV: string
6
+ }
7
+
8
+ interface ImportMeta {
9
+ readonly env: ImportMetaEnv
10
+ }