The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Sammy/t refactor services use generated code (#194)
Sammy Teillet063ef8a4eba5
diff --git a/front/src/generated/graphql.tsx b/front/src/generated/graphql.tsxindex 3c44a3eab24..e898620c162 100644--- a/front/src/generated/graphql.tsx+++ b/front/src/generated/graphql.tsx@@ -1219,7 +1219,7 @@ export type GetCurrentUserQueryVariables = Exact<{}>;-export type GetCurrentUserQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };+export type GetCurrentUserQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', id: string, workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };export type GetUsersQueryVariables = Exact<{ [key: string]: never; }>;@@ -1867,6 +1867,7 @@ export const GetCurrentUserDocument = gql`displayNameworkspaceMember {+ idworkspace {iddomainNamediff --git a/front/src/modules/companies/interfaces/company.interface.ts b/front/src/modules/companies/interfaces/company.interface.tsindex 5be8d36b6bb..7b4fdaa9d8e 100644--- a/front/src/modules/companies/interfaces/company.interface.ts+++ b/front/src/modules/companies/interfaces/company.interface.ts@@ -33,7 +33,7 @@ export type GraphqlQueryCompany = {accountOwner?: GraphqlQueryUser | null;pipes?: GraphqlQueryPipeline[] | null;- __typename: string;+ __typename?: string;};export type GraphqlMutationCompany = {@@ -46,7 +46,7 @@ export type GraphqlMutationCompany = {createdAt?: string;accountOwnerId?: string;- __typename: string;+ __typename?: string;};export const mapToCompany = (company: GraphqlQueryCompany): Company => ({diff --git a/front/src/modules/companies/services/select.ts b/front/src/modules/companies/services/select.tsindex df0a7cdc17d..49e7fe980b4 100644--- a/front/src/modules/companies/services/select.ts+++ b/front/src/modules/companies/services/select.ts@@ -1,14 +1,13 @@-import { gql, QueryResult, useQuery } from '@apollo/client';+import { gql } from '@apollo/client';import { SelectedSortType } from '@/filters-and-sorts/interfaces/sorts/interface';import {CompanyOrderByWithRelationInput as Companies_Order_By,CompanyWhereInput as Companies_Bool_Exp,SortOrder as Order_By,+ useGetCompaniesQuery,} from '~/generated/graphql';-import { GraphqlQueryCompany } from '../interfaces/company.interface';-export type CompaniesSelectedSortType = SelectedSortType<Companies_Order_By>;export const GET_COMPANIES = gql`@@ -35,10 +34,8 @@ export const GET_COMPANIES = gql`export function useCompaniesQuery(orderBy: Companies_Order_By[],where: Companies_Bool_Exp,-): QueryResult<{ companies: GraphqlQueryCompany[] }> {- return useQuery<{ companies: GraphqlQueryCompany[] }>(GET_COMPANIES, {- variables: { orderBy, where },- });+) {+ return useGetCompaniesQuery({ variables: { orderBy, where } });}export const defaultOrderBy: Companies_Order_By[] = [diff --git a/front/src/modules/people/interfaces/person.interface.ts b/front/src/modules/people/interfaces/person.interface.tsindex f4d3fdbb782..d0d5cd87117 100644--- a/front/src/modules/people/interfaces/person.interface.ts+++ b/front/src/modules/people/interfaces/person.interface.ts@@ -33,7 +33,7 @@ export type GraphqlQueryPerson = {company?: GraphqlQueryCompany | null;- __typename: string;+ __typename?: string;};export type GraphqlMutationPerson = {diff --git a/front/src/modules/people/services/select.ts b/front/src/modules/people/services/select.tsindex ffa364215d9..a8efccdffd8 100644--- a/front/src/modules/people/services/select.ts+++ b/front/src/modules/people/services/select.ts@@ -1,14 +1,13 @@-import { gql, QueryResult, useQuery } from '@apollo/client';+import { gql } from '@apollo/client';import { SelectedSortType } from '@/filters-and-sorts/interfaces/sorts/interface';import {PersonOrderByWithRelationInput as People_Order_By,PersonWhereInput as People_Bool_Exp,SortOrder,+ useGetPeopleQuery,} from '~/generated/graphql';-import { GraphqlQueryPerson } from '../interfaces/person.interface';-export type PeopleSelectedSortType = SelectedSortType<People_Order_By>;export const GET_PEOPLE = gql`@@ -37,8 +36,8 @@ export const GET_PEOPLE = gql`export function usePeopleQuery(orderBy: People_Order_By[],where: People_Bool_Exp,-): QueryResult<{ people: GraphqlQueryPerson[] }> {- return useQuery<{ people: GraphqlQueryPerson[] }>(GET_PEOPLE, {+) {+ return useGetPeopleQuery({variables: { orderBy, where },});}diff --git a/front/src/modules/pipelines/interfaces/pipeline.interface.ts b/front/src/modules/pipelines/interfaces/pipeline.interface.tsindex 29de6dc3aee..5fc0283fa43 100644--- a/front/src/modules/pipelines/interfaces/pipeline.interface.ts+++ b/front/src/modules/pipelines/interfaces/pipeline.interface.ts@@ -8,5 +8,5 @@ export interface GraphqlQueryPipeline {id: string;name?: string;icon?: string | null;- __typename: string;+ __typename?: string;}diff --git a/front/src/modules/users/interfaces/user.interface.ts b/front/src/modules/users/interfaces/user.interface.tsindex 1a76ef2918e..ca787dd6df1 100644--- a/front/src/modules/users/interfaces/user.interface.ts+++ b/front/src/modules/users/interfaces/user.interface.ts@@ -9,15 +9,15 @@ export interface User {id: string;email?: string;displayName?: string;- workspaceMember?: WorkspaceMember;+ workspaceMember?: WorkspaceMember | null;}export type GraphqlQueryUser = {id: string;email?: string;displayName?: string;- workspaceMember?: GraphqlQueryWorkspaceMember;- __typename: string;+ workspaceMember?: GraphqlQueryWorkspaceMember | null;+ __typename?: string;};export type GraphqlMutationUser = {@@ -25,7 +25,7 @@ export type GraphqlMutationUser = {email?: string;displayName?: string;workspaceMemberId?: string;- __typename: string;+ __typename?: string;};export const mapToUser = (user: GraphqlQueryUser): User => ({diff --git a/front/src/modules/users/interfaces/workspaceMember.interface.ts b/front/src/modules/users/interfaces/workspaceMember.interface.tsindex 1e38d00a107..433d9b87687 100644--- a/front/src/modules/users/interfaces/workspaceMember.interface.ts+++ b/front/src/modules/users/interfaces/workspaceMember.interface.ts@@ -12,13 +12,13 @@ export interface WorkspaceMember {export type GraphqlQueryWorkspaceMember = {id: string;workspace: GraphqlQueryWorkspace;- __typename: string;+ __typename?: string;};export type GraphqlMutationWorkspaceMember = {id: string;workspace_id: string;- __typename: string;+ __typename?: string;};export const mapToWorkspaceMember = (diff --git a/front/src/modules/users/services/index.tsx b/front/src/modules/users/services/index.tssimilarity index 55%rename from front/src/modules/users/services/index.tsxrename to front/src/modules/users/services/index.tsindex 5eb898e09f4..3b4cf45bf73 100644--- a/front/src/modules/users/services/index.tsx+++ b/front/src/modules/users/services/index.ts@@ -1,6 +1,6 @@-import { gql, QueryResult, useQuery } from '@apollo/client';+import { gql } from '@apollo/client';-import { GraphqlQueryUser } from '../interfaces/user.interface';+import { useGetCurrentUserQuery as generatedUseGetCurrentUserQuery } from '~/generated/graphql';export const GET_CURRENT_USER = gql`query GetCurrentUser($uuid: String) {@@ -9,6 +9,7 @@ export const GET_CURRENT_USER = gql`displayNameworkspaceMember {+ idworkspace {iddomainName@@ -20,10 +21,8 @@ export const GET_CURRENT_USER = gql`}`;-export function useGetCurrentUserQuery(userId: string | null): QueryResult<{- users: GraphqlQueryUser[];-}> {- return useQuery<{ users: GraphqlQueryUser[] }>(GET_CURRENT_USER, {+export function useGetCurrentUserQuery(userId: string | null) {+ return generatedUseGetCurrentUserQuery({variables: {uuid: userId,},diff --git a/front/src/modules/users/services/test.tsx b/front/src/modules/users/services/test.tssimilarity index 100%rename from front/src/modules/users/services/test.tsxrename to front/src/modules/users/services/test.tsdiff --git a/front/src/modules/workspaces/interfaces/workspace.interface.ts b/front/src/modules/workspaces/interfaces/workspace.interface.tsindex 3436b2618d8..7371ff9b701 100644--- a/front/src/modules/workspaces/interfaces/workspace.interface.ts+++ b/front/src/modules/workspaces/interfaces/workspace.interface.ts@@ -10,7 +10,7 @@ export type GraphqlQueryWorkspace = {displayName?: string;domainName?: string;logo?: string | null;- __typename: string;+ __typename?: string;};export type GraphqlMutationWorkspace = {@@ -18,7 +18,7 @@ export type GraphqlMutationWorkspace = {displayName?: string;domainName?: string;logo?: string | null;- __typename: string;+ __typename?: string;};export const mapToWorkspace = (