Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/apps/admin/components/affiliation.edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function EditAffiliation({
React.useEffect(() => {
const conformedOrgs = organizations.map(org => ({
value: org.id,
label: org.name[0].payload,
label: org.name && org.name[0].payload,
}));
setOrganizationValuePairs(conformedOrgs);
}, [organizations]);
Expand Down Expand Up @@ -53,6 +53,7 @@ function EditAffiliation({
} catch (error) {
console.log(error);
setSubmitting(false);
return error;
}
}

Expand Down Expand Up @@ -95,7 +96,7 @@ function EditAffiliation({
<Confirm
confirmText="Save"
cancelText="Cancel"
onClose={() => toggleEditing(false)}
onClose={toggleEditing}
onCancel={() => {}}
onConfirm={submitForm}
open={isEditing}
Expand Down
1 change: 1 addition & 0 deletions src/apps/admin/components/company.edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function EditCompany({ company, isEditing, toggleEditing, data, ...props }) {
} catch (error) {
console.log(error);
setSubmitting(false);
return error;
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/apps/admin/components/companylinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import NavigationIcon from '@material-ui/icons/Navigation';

function CompanyLinksInput(props) {
const { values, errors, touched, classes } = props;
// console.log('PROPS IN COMPANY LINKS: ', props);

return (
<FieldArray
Expand Down Expand Up @@ -93,7 +92,6 @@ function CodeXTextField({
value,
...rest
}) {
// console.log('REST IN CODEX TEXT FIELD', value);
const fieldErrors = errors[name];
const isTouched = touched[name];
return (
Expand Down
35 changes: 12 additions & 23 deletions src/apps/admin/components/profile.edit.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useState } from 'react';
import React from 'react';
import { Formik } from 'formik';
import CodeXTextField from './codex.textinput';
import styled from 'styled-components';
import { Mutation } from 'react-apollo';
import { useQuery, useMutation } from 'react-apollo-hooks';
import Fab from '@material-ui/core/Fab';
import Avatar from '@material-ui/core/Avatar';
Expand Down Expand Up @@ -49,27 +48,17 @@ function EditProfile({ open, handleClose, classes, ...props }) {
},
},
},
avatar:
avatar !== ''
? me.person.avatar[0]
? {
update: {
data: {
payload: avatar,
fromDate: new Date(),
},
where: {
id: me.person.avatar[0].id,
},
},
}
: {
create: {
payload: avatar,
fromDate: new Date(),
},
}
: null,
avatar: {
update: {
where: {
id: me.person.avatar[0].id,
},
data: {
payload: avatar,
fromDate: new Date(),
},
},
},
},
},
});
Expand Down
11 changes: 11 additions & 0 deletions src/apps/admin/features/afffiliation.create/graphql/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ export const CREATE_AFFILIATION_MUTATION = gql`
throughDate
title
updatedAt
createdAt
organization {
id
name {
id
payload
fromDate
throughDate
}
description
logo {
id
payload
}
}
person {
__typename
Expand All @@ -33,16 +40,20 @@ export const CREATE_AFFILIATION_MUTATION = gql`
organization {
id
name {
id
payload
}
description
logo {
id
payload
}
}
}
}

metadata {
id
isDraft
isPublic
isRejected
Expand Down
43 changes: 43 additions & 0 deletions src/apps/admin/features/afffiliation.create/graphql/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,46 @@ export const GET_COMPANY_TARGET_MARKETS = gql`
}
}
`;

export const GET_PERSON_AFFILIATIONS_QUERY = gql`
query GetPersonAffiliationsQuery(
$where: PersonOrganizationAffiliationWhereInput
$orderBy: PersonOrganizationAffiliationOrderByInput
) {
personOrganizationAffiliations(where: $where, orderBy: $orderBy) {
__typename
id
createdAt
fromDate
throughDate
title
role
description
organization {
__typename
id
name {
__typename
id
payload
}
description
logo {
__typename
id
payload
}
}
metadata {
__typename
id
isDraft
isPublic
isRejected
isUnverified
isApproved
isPendingReview
}
}
}
`;
52 changes: 49 additions & 3 deletions src/apps/admin/features/afffiliation.create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { Formik } from 'formik';
import CodeXTextField from '../../components/codex.textinput';
import styled from 'styled-components';
import { useMutation } from 'react-apollo-hooks';
import { CREATE_AFFILIATION_MUTATION } from './graphql/mutations';
import { StaticQuery, graphql } from 'gatsby';
import {
CREATE_AFFILIATION_MUTATION,
GET_PERSON_AFFILIATIONS_QUERY,
} from './graphql';
import Confirm from '../../../../atoms/confirm';
import { checkCanFormSubmit, validationSchema } from './helpers';

Expand All @@ -18,7 +20,51 @@ function EditAffiliation({
user,
...props
}) {
const createAffiliation = useMutation(CREATE_AFFILIATION_MUTATION);
const createAffiliation = useMutation(CREATE_AFFILIATION_MUTATION, {
update(
client,
{
data: { createAffiliation },
}
) {
if (client.data.data.ROOT_QUERY.personOrganizationAffiliations) {
try {
const {
personOrganizationAffiliations: affiliations,
} = client.readQuery({
query: GET_PERSON_AFFILIATIONS_QUERY,

variables: {
where: {
person: {
id: user.person.id,
},
},
orderBy: 'fromDate_DESC',
},
});

const updatedData = affiliations.concat([createAffiliation]);

client.writeQuery({
query: GET_PERSON_AFFILIATIONS_QUERY,
data: {
personOrganizationAffiliations: updatedData,
},
});
} catch (error) {
console.log(
`ERROR updating cache for CREATE_AFFILIATION_MUTATION in affiliation.create/index.js ${error}`
);
return error;
}
} else {
console.log(
'personOrganizationAffiliations query has not been called yet, not updating the cache'
);
}
},
});

async function handleSubmit(
{ fromDate, throughDate, role, description, title, organization },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function IntegrationDownshift(props) {

const Categories = props => {
const ORGANIZATION_CATEGORIES = gql`
{
query GetOrganizationCategories {
organizationCategories {
id
payload
Expand Down
12 changes: 8 additions & 4 deletions src/apps/admin/features/company.create/graphql/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ import gql from 'graphql-tag';
export const CREATE_COMPANY_MUTATION = gql`
mutation CreateCompany($data: OrganizationCreateInput!) {
createOrganization(data: $data) {
__typename
id
logo {
id
payload
fromDate
throughDate
}
name {
id
payload
fromDate
throughDate
}
description
yearFounded
location {
__typename
id
formatted_address
geometry
}
affiliation {
__typename
id
fromDate
person {
__typename
id
}
}
Expand All @@ -34,6 +37,7 @@ export const CREATE_COMPANY_MUTATION = gql`
}
}
metadata {
id
isDraft
isPublic
isRejected
Expand Down
74 changes: 74 additions & 0 deletions src/apps/admin/features/company.create/graphql/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,77 @@ export const GET_COMPANY_TARGET_MARKETS = gql`
}
}
`;

export const GET_USER_ADMIN_COMPANIES = gql`
query GetUserAdminCompanies($where: PartyAccountWhereUniqueInput!) {
partyAccount(where: $where) {
id
admin {
id
yearFounded
description
name {
id
payload
}
logo {
id
payload
}
description
metadata {
id
isDraft
isPublic
isRejected
isUnverified
isApproved
isPendingReview
}
}
}
}
`;

export const GET_PERSON_AFFILIATIONS_QUERY = gql`
query GetPersonAffiliationsQuery(
$where: PersonOrganizationAffiliationWhereInput
$orderBy: PersonOrganizationAffiliationOrderByInput
) {
personOrganizationAffiliations(where: $where, orderBy: $orderBy) {
__typename
id
createdAt
fromDate
throughDate
title
role
description
organization {
__typename
id
name {
__typename
id
payload
}
description
logo {
__typename
id
payload
}
}
metadata {
__typename
id
isDraft
isPublic
isRejected
isUnverified
isApproved
isPendingReview
}
}
}
`;
Loading