Skip to content

Commit

Permalink
chore(services): removed company from services (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
devFra authored Sep 4, 2024
1 parent 8d08642 commit b622196
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 49 deletions.
6 changes: 3 additions & 3 deletions src/components/report/ReportFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export const ReportFilters = component$<{

const _projectSig = useComputed$(async () => {
return selectedCustomer.value != ''
? (await getProjects('it', selectedCustomer.value)).map((project) => project.name)
? (await getProjects(selectedCustomer.value)).map((project) => project.name)
: [];
});

const projectSig = useComputed$(async () => {
return selectedCustomer.value != '' ? await getProjects('it', selectedCustomer.value) : [];
return selectedCustomer.value != '' ? await getProjects(selectedCustomer.value) : [];
});

const onChangeCustomer = $(() => {
Expand All @@ -53,7 +53,7 @@ export const ReportFilters = component$<{

const taskSig = useComputed$(async () => {
return _projectSelected.value != ''
? await getTasks('it', selectedCustomer.value, selectedProject.value)
? await getTasks(selectedCustomer.value, selectedProject.value)
: [];
});

Expand Down
5 changes: 2 additions & 3 deletions src/hooks/timesheet/useNewTimeEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const useNewTimeEntry = (
projectSelected.value = initProject;
taskSelected.value = initTaskt;
if (value != '') {
dataProjectsSig.value = await getProjects('it', value);
dataProjectsSig.value = await getProjects(value);
projectEnableSig.value = true;
} else {
projectTypeEnabled.newProject = false;
Expand All @@ -88,7 +88,7 @@ export const useNewTimeEntry = (
if (customerSelected.value != '') {
taskSelected.value = initTaskt;
if (value.name != '') {
dataTaksSign.value = await getTasks('it', customerSelected.value, value);
dataTaksSign.value = await getTasks(customerSelected.value, value);
taskEnableSig.value = true;
} else {
taskEnableSig.value = false;
Expand All @@ -107,7 +107,6 @@ export const useNewTimeEntry = (

const insertNewTimeEntry = $(async () => {
const savingResult = await saveTask(
'it',
customerSelected.value,
projectSelected.value,
taskSelected.value
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useCustomers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useCustomers = () => {

const updateCustomer = $(async (customer: Customer, editedCusteomr: Customer) => {
appStore.isLoading = true;
const projectList = await getProjects('it', customer);
const projectList = await getProjects(customer);
const results = projectList.map(async (project) => {
return await updateProjectCustomer(customer, editedCusteomr, project);
});
Expand All @@ -42,7 +42,7 @@ export const useCustomers = () => {

const removeCustomer = $(async (customer: Customer) => {
appStore.isLoading = true;
const projectList = await getProjects('it', customer);
const projectList = await getProjects(customer);
const results = projectList.map(async (project) => {
return await removeProjectCustomer(customer, project);
});
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useProjects = () => {
const fetchProjects = $(async (customer: Customer) => {
projects.value = [];
isLoading.value = true;
projects.value = await getProjects(undefined, customer);
projects.value = await getProjects(customer);
isLoading.value = false;
});

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useTasks = () => {
const fetchTasks = $(async (customer: Customer, project: Project) => {
tasks.value = [];
isLoading.value = true;
tasks.value = await getTasks(undefined, customer, project);
tasks.value = await getTasks(customer, project);
isLoading.value = false;
});

Expand Down
5 changes: 1 addition & 4 deletions src/services/customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import { Customer } from '@models/customer';
import { Project } from '@models/project';
import { checkHttpResponseStatus, getHttpResponse } from '../network/httpRequest';

export const getCustomers = async (company: string = 'it'): Promise<Customer[]> =>
export const getCustomers = async (): Promise<Customer[]> =>
getHttpResponse<Customer[]>({
path: `task/customer`,
params: {
company,
},
});

export const editCustomer = async (
Expand Down
21 changes: 5 additions & 16 deletions src/services/effort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,25 @@ import { Effort, EffortMatrix } from '@models/effort';
import { Month } from '@models/month';
import { checkHttpResponseStatus, getHttpResponse } from '../network/httpRequest';

export const getEffort = async (
months: number = 3,
company: string = 'it'
): Promise<EffortMatrix> => [
...(await getMyCompanyEffort(months, company)),
...(await getNetowrkingEffort(months, company)),
export const getEffort = async (months: number = 3): Promise<EffortMatrix> => [
...(await getMyCompanyEffort(months)),
...(await getNetowrkingEffort(months)),
];

const getMyCompanyEffort = async (
months: number = 3,
company: string = 'it'
): Promise<EffortMatrix> =>
const getMyCompanyEffort = async (months: number = 3): Promise<EffortMatrix> =>
getHttpResponse<EffortMatrix>({
path: `effort/next`,
params: {
months: months.toString(),
company,
},
});

const getNetowrkingEffort = async (
months: number = 3,
company: string = 'it'
): Promise<EffortMatrix> => {
const getNetowrkingEffort = async (months: number = 3): Promise<EffortMatrix> => {
try {
let response = await getHttpResponse<EffortMatrix>({
path: `networking/effort/next`,
params: {
months: months.toString(),
company,
},
});

Expand Down
3 changes: 1 addition & 2 deletions src/services/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Customer } from '@models/customer';
import { Project } from '@models/project';
import { checkHttpResponseStatus, getHttpResponse } from '../network/httpRequest';

export const getProjects = async (company: string = 'it', customer: Customer): Promise<Project[]> =>
export const getProjects = async (customer: Customer): Promise<Project[]> =>
getHttpResponse<Project[]>({
path: `task/project`,
params: {
company,
customer,
},
});
Expand Down
15 changes: 6 additions & 9 deletions src/services/skillMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@ export const getSkillMatrixMine = async (): Promise<Skill[]> =>
export const pathSkillMatrixMine = async (skill: Skill): Promise<boolean> =>
checkHttpResponseStatus('skill-matrix/mine', 204, 'PATCH', skill);

export const getSkills = async (company: string = 'it'): Promise<SkillMatrix> => [
...(await getCompanySkills(company)),
...(await getNetworkingSkills(company)),
export const getSkills = async (): Promise<SkillMatrix> => [
...(await getCompanySkills()),
...(await getNetworkingSkills()),
];

export const getCompanySkills = async (company: string = 'it'): Promise<SkillMatrix> =>
getHttpResponse<SkillMatrix>(`skill-matrix?company=${encodeURIComponent(company)}`);
export const getCompanySkills = async (): Promise<SkillMatrix> =>
getHttpResponse<SkillMatrix>(`skill-matrix`);

export const getNetworkingSkills = async (company: string = 'it'): Promise<SkillMatrix> => {
export const getNetworkingSkills = async (): Promise<SkillMatrix> => {
try {
let response = await getHttpResponse<SkillMatrix>({
path: `networking/skills`,
params: {
company,
},
});
response = response.map((el) => {
const [[companyName, _]] = Object.entries(el);
Expand Down
9 changes: 1 addition & 8 deletions src/services/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,22 @@ import { Project } from '@models/project';
import { Task } from '@models/task';
import { checkHttpResponseStatus, getHttpResponse } from '../network/httpRequest';

export const getTasks = async (
company: string = 'it',
customer: Customer,
project: Project
): Promise<Task[]> =>
export const getTasks = async (customer: Customer, project: Project): Promise<Task[]> =>
getHttpResponse<Task[]>({
path: `task/task`,
params: {
company,
customer,
project: project.name,
},
});

export const saveTask = async (
company: string = 'it',
customer: Customer,
project: Project,
task: Task,
index?: number
): Promise<boolean> =>
checkHttpResponseStatus(`task/task`, 200, 'POST', {
company: company,
customer: customer,
project: project,
task: task,
Expand Down

0 comments on commit b622196

Please sign in to comment.