Skip to content

Commit

Permalink
refactor: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
FredPeal committed Nov 22, 2023
1 parent 75cdb65 commit 24e2d81
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 26,685 deletions.
26,546 changes: 0 additions & 26,546 deletions package-lock.json

This file was deleted.

6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
Users,
CustomFields,
Locations,
Companies,
CompaniesBranches,
Leads,
Inventory,
Agents,
Expand Down Expand Up @@ -88,6 +90,8 @@ export default class KanvasCore {
public usersLists: UsersLists;
public messages: Messages;
public roles: Roles;
public companies: Companies;
public companiesBranches: CompaniesBranches;

constructor(protected options: Options) {
this.client = new ApolloClient({
Expand All @@ -111,6 +115,8 @@ export default class KanvasCore {
this.usersLists = new UsersLists(this.client);
this.messages = new Messages(this.client);
this.roles = new Roles(this.client);
this.companies = new Companies(this.client);
this.companiesBranches = new CompaniesBranches(this.client);
}

protected generateURL() {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/companies-branches/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class CompaniesBranches {
mutation: CREATE_COMPANY_BRANCH,
variables: { input },
});
return response.data.createCompanyBranch;
return response.data.createCompanyBranch as CompanyBranchInterface;
}

public async updateCompanyBranch(
Expand All @@ -66,7 +66,7 @@ export class CompaniesBranches {
mutation: UPDATE_COMPANY_BRANCH,
variables: { id: id, input: input },
});
return response.data.updateCompanyBranch;
return response.data.updateCompanyBranch as CompanyBranchInterface;
}

public async deleteCompanyBranch(id: string): Promise<Boolean> {
Expand Down
5 changes: 2 additions & 3 deletions src/modules/companies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DELETE_COMPANY_MUTATION,
ADD_USER_TO_COMPANY,
REMOVE_USER_FROM_COMPANY,
} from '../../mutations';
} from 'mutations';
import {
COMPANIES_QUERY,
COMPANY_USERS_QUERY,
Expand All @@ -20,7 +20,6 @@ import {
QueryCompanyUsersWhereWhereConditions,
CompanySettings,
} from '../../types';
import { from } from '@apollo/client';

export class Companies {
constructor(protected client: ClientType) {}
Expand Down Expand Up @@ -80,7 +79,7 @@ export class Companies {
mutation: DELETE_COMPANY_MUTATION,
variables: { id: id },
});
return response.data.deleteCompany;
return response.data.deleteCompany as Boolean;
}

public async addUserToCompany(id: string, user_id: string): Promise<Boolean> {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export * from './commerce';
export * from './usersLists';
export * from './messages';
export * from './roles';
export * from './companies';
export * from './companies-branches';
54 changes: 27 additions & 27 deletions src/mutations/companies-branches.mutation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gql } from '@apollo/client';
import { gql } from '@apollo/client/core';

export const CREATE_COMPANY_BRANCH = gql`
mutation createCompanyBranch($input: CompanyBranchInput) {
Expand Down Expand Up @@ -28,30 +28,30 @@ export const CREATE_COMPANY_BRANCH = gql`
`;

export const UPDATE_COMPANY_BRANCH = gql`
updateCompanyBranch($id: ID!, $input: CompanyBranchInput) {
updateCompanyBranch(id: $id, input: $input) {
id
uuid
company
companies_id
name
email
phone
photo {
id
uuid
name
url
type
size
field_name
}
zipcode
is_default
created_at
updated_at
}
mutation updateCompanyBranch($id: ID!, $input: CompanyBranchInput) {
updateCompanyBranch(id: $id, input: $input) {
id
uuid
company
companies_id
name
email
phone
photo {
id
uuid
name
url
type
size
field_name
}
zipcode
is_default
created_at
updated_at
}
}
`;

export const DELETE_COMPANY_BRANCH = gql`
Expand All @@ -67,7 +67,7 @@ export const ADD_USER_TO_BRANCH = gql`
`;

export const REMOVE_USER_FROM_BRANCH = gql`
mutation removeUserFromBranch($id: ID!, user_id: ID!){
removeUserFromBranch(id: $id, user_id: $user_id)
}
mutation removeUserFromBranch($id: ID!, $user_id: ID!) {
removeUserFromBranch(id: $id, user_id: $user_id)
}
`;
2 changes: 1 addition & 1 deletion src/mutations/companies.mutation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gql } from '@apollo/client';
import { gql } from '@apollo/client/core';
export const CREATE_COMPANY_MUTATION = gql`
mutation($input: CompanyInput!) {
createCompany(input: $input) {
Expand Down
2 changes: 1 addition & 1 deletion src/queries/companies-branches.query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gql } from '@apollo/client';
import { gql } from '@apollo/client/core';

export const COMPANIES_BRANCHES_QUERY = gql`
query branches(
Expand Down
205 changes: 100 additions & 105 deletions src/queries/companies.query.ts
Original file line number Diff line number Diff line change
@@ -1,118 +1,113 @@
import { gql } from '@apollo/client';
import { gql } from '@apollo/client/core';

export const COMPANIES_QUERY = gql`
query companies(
$where: QueryCompaniesWhereWhereConditions,
$orderBy: [QueryCompaniesOrderByOrderByClause!],
$first: Int!
page: !Int
){
companies(
where: $where,
orderBy: $orderBy,
first: $first,
page: $page
){
data {
id
name
uuid
website
address
zipcode
email
language
timezone
phone
country_code
created_at
updated_at
photo {
id
uuid
name
url
type
size
field_name
}
user {
id
firstname
lastname
displayname
}
groups {
id
uuid
name
}
branches {
id
uuid
name
}
},
paginatorInfo {
count,
currentPage,
lastPage,
perPage,
total
}
query companies(
$where: QueryCompaniesWhereWhereConditions
$orderBy: [QueryCompaniesOrderByOrderByClause!]
$first: Int!
$page: Int!
) {
companies(where: $where, orderBy: $orderBy, first: $first, page: $page) {
data {
id
name
uuid
website
address
zipcode
email
language
timezone
phone
country_code
created_at
updated_at
photo {
id
uuid
name
url
type
size
field_name
}
user {
id
firstname
lastname
displayname
}
groups {
id
uuid
name
}
branches {
id
uuid
name
}
}
paginatorInfo {
count
currentPage
lastPage
perPage
total
}
}
}
`;

export const COMPANY_USERS_QUERY = gql`
companyUsers(
$where: QueryCompanyUsersWhereWhereConditions,
$first: Int!,
$page: Int
){
query companyUsers(
$where: QueryCompanyUsersWhereWhereConditions
$first: Int!
$page: Int
) {
data {
id
uuid
firstname
lastname
displayname
default_company
default_company_branch
email
branches {
id
name
phone
}
companies {
id
name
}
contact {
phone_number
cell_phone_number
}
roles
abilities
custom_fields(orderBy: [{ column: UPDATED_AT, order: DESC }]) {
data {
id
uuid
firstname
lastname
displayname
default_company
default_company_branch
email
branches {
id
name
phone
}
companies {
id
name
}
contact {
phone_number
cell_phone_number
}
roles
abilities
custom_fields(orderBy: [{ column: UPDATED_AT, order: DESC }]) {
data {
name
value
}
}
photo {
url
}
},
paginatorInfo {
count,
currentPage,
lastPage,
perPage,
total
name
value
}
}
photo {
url
}
}
`;
paginatorInfo {
count
currentPage
lastPage
perPage
total
}
}
`;

export const COMPANY_SETTINGS_QUERY = gql`
query companySettings {
Expand Down

0 comments on commit 24e2d81

Please sign in to comment.