moved hoc's into plugin

This commit is contained in:
Wyatt Johnson
2018-05-03 08:59:26 -06:00
parent 225a04fed1
commit 87d0c99558
5 changed files with 101 additions and 120 deletions
-110
View File
@@ -1,7 +1,6 @@
import { gql } from 'react-apollo';
import withMutation from '../hocs/withMutation';
import update from 'immutability-helper';
import moment from 'moment';
function convertItemType(item_type) {
switch (item_type) {
@@ -645,115 +644,6 @@ export const withChangePassword = withMutation(
}
);
export const withRequestAccountDeletion = withMutation(
gql`
mutation RequestAccountDeletion {
requestAccountDeletion {
...RequestAccountDeletionResponse
}
}
`,
{
props: ({ mutate }) => ({
requestAccountDeletion: () => {
return mutate({
variables: {},
update: proxy => {
const RequestAccountDeletionQuery = gql`
query Talk_CancelAccountDeletion {
me {
id
scheduledDeletionDate
}
}
`;
const prev = proxy.readQuery({
query: RequestAccountDeletionQuery,
});
const scheduledDeletionDate = moment()
.add(12, 'hours')
.toDate();
const data = update(prev, {
me: {
scheduledDeletionDate: { $set: scheduledDeletionDate },
},
});
proxy.writeQuery({
query: RequestAccountDeletionQuery,
data,
});
},
});
},
}),
}
);
export const withRequestDownloadLink = withMutation(
gql`
mutation RequestDownloadLink {
requestDownloadLink {
...RequestDownloadLinkResponse
}
}
`,
{
props: ({ mutate }) => ({
requestDownloadLink: () => {
return mutate({
variables: {},
});
},
}),
}
);
export const withCancelAccountDeletion = withMutation(
gql`
mutation RequestDownloadLink {
cancelAccountDeletion {
...CancelAccountDeletionResponse
}
}
`,
{
props: ({ mutate }) => ({
cancelAccountDeletion: () => {
return mutate({
variables: {},
update: proxy => {
const CancelAccountDeletionQuery = gql`
query Talk_CancelAccountDeletion {
me {
id
scheduledDeletionDate
}
}
`;
const prev = proxy.readQuery({ query: CancelAccountDeletionQuery });
const data = update(prev, {
me: {
scheduledDeletionDate: { $set: null },
},
});
proxy.writeQuery({
query: CancelAccountDeletionQuery,
data,
});
},
});
},
}),
}
);
export const withUpdateAssetSettings = withMutation(
gql`
mutation UpdateAssetSettings($id: ID!, $input: AssetSettingsInput!) {
-3
View File
@@ -25,9 +25,6 @@ export {
withUnbanUser,
withStopIgnoringUser,
withSetCommentStatus,
withRequestAccountDeletion,
withRequestDownloadLink,
withCancelAccountDeletion,
withChangePassword,
withChangeUsername,
} from 'coral-framework/graphql/mutations';
@@ -3,7 +3,7 @@ import { bindActionCreators } from 'redux';
import { connect, withFragments, excludeIf } from 'plugin-api/beta/client/hocs';
import AccountDeletionRequestedSign from '../components/AccountDeletionRequestedSign';
import { notify } from 'coral-framework/actions/notification';
import { withCancelAccountDeletion } from 'plugin-api/beta/client/hocs';
import { withCancelAccountDeletion } from '../mutations';
const mapDispatchToProps = dispatch => bindActionCreators({ notify }, dispatch);
@@ -6,7 +6,7 @@ import { notify } from 'coral-framework/actions/notification';
import {
withRequestAccountDeletion,
withCancelAccountDeletion,
} from 'plugin-api/beta/client/hocs';
} from '../mutations';
const mapDispatchToProps = dispatch => bindActionCreators({ notify }, dispatch);
@@ -1,19 +1,113 @@
import { withMutation } from 'plugin-api/beta/client/hocs';
import { gql } from 'react-apollo';
import update from 'immutability-helper';
import moment from 'moment';
export const withRequestDownloadLink = withMutation(
gql`
mutation DownloadCommentHistory {
mutation RequestDownloadLink {
requestDownloadLink {
errors {
translation_key
}
...RequestDownloadLinkResponse
}
}
`,
{
props: ({ mutate }) => ({
requestDownloadLink: () => mutate({ variables: {} }),
requestDownloadLink: () => {
return mutate({
variables: {},
});
},
}),
}
);
export const withRequestAccountDeletion = withMutation(
gql`
mutation RequestAccountDeletion {
requestAccountDeletion {
...RequestAccountDeletionResponse
}
}
`,
{
props: ({ mutate }) => ({
requestAccountDeletion: () => {
return mutate({
variables: {},
update: proxy => {
const RequestAccountDeletionQuery = gql`
query Talk_CancelAccountDeletion {
me {
id
scheduledDeletionDate
}
}
`;
const prev = proxy.readQuery({
query: RequestAccountDeletionQuery,
});
const scheduledDeletionDate = moment()
.add(12, 'hours')
.toDate();
const data = update(prev, {
me: {
scheduledDeletionDate: { $set: scheduledDeletionDate },
},
});
proxy.writeQuery({
query: RequestAccountDeletionQuery,
data,
});
},
});
},
}),
}
);
export const withCancelAccountDeletion = withMutation(
gql`
mutation RequestDownloadLink {
cancelAccountDeletion {
...CancelAccountDeletionResponse
}
}
`,
{
props: ({ mutate }) => ({
cancelAccountDeletion: () => {
return mutate({
variables: {},
update: proxy => {
const CancelAccountDeletionQuery = gql`
query Talk_CancelAccountDeletion {
me {
id
scheduledDeletionDate
}
}
`;
const prev = proxy.readQuery({ query: CancelAccountDeletionQuery });
const data = update(prev, {
me: {
scheduledDeletionDate: { $set: null },
},
});
proxy.writeQuery({
query: CancelAccountDeletionQuery,
data,
});
},
});
},
}),
}
);