Exemple #1
0
 submitNew(e) {
   e.preventDefault();
   Relay.Store.commitUpdate(
     new CreateLinkMutation({
       title: this.titleInput.value,
       url: this.urlInput.value,
       store: this.props.store
     })
   )
   this.titleInput.value = "";
   this.urlInput.value = "";
 }
Exemple #2
0
 _handleMarkAllPress() {
   const numTodos = this.props.viewer.totalCount;
   const numCompletedTodos = this.props.viewer.completedCount;
   const complete = numTodos !== numCompletedTodos;
   Relay.Store.commitUpdate(
     new MarkAllTodosMutation({
       complete,
       todos: this.props.viewer.todos,
       viewer: this.props.viewer,
     })
   );
 }
Exemple #3
0
 handleSubmit = (e) => {
   e.preventDefault();
   // Mutate
   Relay.Store.commitUpdate(
     new CreateLinkMutation({
       title: this.refs.newTitle.value,
       url: this.refs.newUrl.value,
       store: this.props.store
     })
   );
   this.refs.newTitle.value = "";
   this.refs.newUrl.value = "";
 }
  handleSubmit = (e) => {
    e.preventDefault();

    Relay.Store.applyUpdate(
      new CreateLinkMutation({
        title: this.title.value,
        url: this.url.value,
        store: this.props.store,
      })
    ).commit();
    this.title.value = '';
    this.url.value = '';
  };
Exemple #5
0
 _mutation = (order) => {
   var onFailure = () => {
     console.log('failuuuure!!!');
     order.id = '_' + Math.random().toString(36).substr(2, 9);
   };
   var onSuccess = () => {
     localStorage[this.props.id] = '';
     this.setState({caddy: [], modal: false});
   };
   order.userID = this.props.user.user.userID;
   order.restaurantID = this.props.restaurant.restaurant.id;
   Relay.Store.update(new OrderMutation({order: order}), {onFailure, onSuccess});
 }
Exemple #6
0
  return new Promise((resolve, reject)=> {
    const transaction = Relay.Store.applyUpdate(
      new UnsubscribeFromTopicMutation(data), {
        onSuccess: (transact) => {
          resolve(transact)
        },
        onFailure: (transact) => {
          reject(getErrors(transact))
        }
      }
    )

    transaction.commit();
  })
  return new Promise((resolve, reject) => {
    Relay.Store.update(mutation, {
      onSuccess: resolve,
      onFailure: (transaction) => {
        let error = transaction.getError() || new Error('Mutation failed');

        if (!(error instanceof Error)) {
          error = new Error(error);
        }

        reject(error);
      },
    });
  });
    addItemToCart(reference) {
        
        var addItemInCartMutation = new AddItemInCartMutation({
            viewerId: UserService.getUserId(),
            itemReference: reference,
            cart: this.props.viewer.cart
        });

        var onSuccess = (response) => console.log("Item added to cart");

        var onFailure = (transaction) => console.log("Item not added to cart");

        Relay.Store.commitUpdate(addItemInCartMutation, {onSuccess, onFailure})
    }
Exemple #9
0
 handleSave = (data) => {
   //add viewer id
   data.viewer = this.props.viewer;
   console.log(data.categoryId);
   Relay.Store.commitUpdate(new AddMebelMutation({
     categoryId: data.categoryId,
     subcategoryId: data.subcategoryId,
     title: data.title,
     img: data.img,
     price: data.price,
     art: data.art,
     poroda: data.poroda,
     viewer: data.viewer
   }))
 }
 _handleSignup = (e) => {
   e.preventDefault();
   var details = {
     username: this.refs.usernameInput.value,
     mail: this.refs.mailInput.value,
     password: this.refs.passwordInput.value,
   };
   Relay.Store.commitUpdate(
     new SignupMutation({credentials: details, user: this.props.user})
   );
   this.refs.usernameInput.value = '';
   this.refs.mailInput.value = '';
   this.refs.passwordInput.value = '';
   this.refs.passwordConfirmInput.value = '';
 }
const onEnter = (nextState, replace, callback) => {
  const {params: {channelId}} = nextState;
  const query = Relay.createQuery(node, {channelId});
  Relay.Store.primeCache({query}, readyState => {
    if (readyState.done) {
      const [channel] = Relay.Store.readQuery(query);
      if (channel.joined) {
        callback();
      } else {
        Relay.Store.commitUpdate(new JoinChannelMutation({channel}), {
          onSuccess: () => callback()
        });
      }
    }
  });
}
Exemple #12
0
  handleSubmit = () => {
    if (this.props.disabled) {
      console.warn('New user is not ready');
      return;
    }

    const {master, attributes} = this.props;
    const {name} = attributes;

    Relay.Store.update(
      new NewUserMutation({
        master,
        name,
      })
    );

    this.onComplete();
  }
Exemple #13
0
  // Upload the files and create the bikeshed
  // Navigates to the bikeshed if succesful
  submitForm () {
    const { router } = this.context
    const { duration, images, title } = this.state
    this.setState({ saving: true })
    Relay.Store.commitUpdate(new CreateBikeshedMutation({ duration, images, title }), {
      // @TODO: Show a snackbar message
      onFailure: (transaction) => {
        this.setState({ saving: false })
      },
      onSuccess: (response) => {
        this.setState({ saving: false })

        // Navigate to newly created bikeshed page
        const bikeshedId = response.createBikeshed.bikeshed.id
        router.push(`/bikesheds/${bikeshedId}`)
      }
    })
  }
Exemple #14
0
    promise: () => new Promise((resolve, reject) => {

      Relay.Store.commitUpdate(new PasswordMutation({
        id,
        type: 'set',
        password: newPassword,
        sessionToken: viewer.sessionToken,
        viewer,
      }), {
        onSuccess: function ({setPassword: {viewer: {...props}}}) {
          resolve({...props});
        },
        onFailure: function (transaction) {
          const error = transaction.getError();
          reject({error});
        },
      });

    })
Exemple #15
0
    promise: () => new Promise((resolve, reject) => {

      Relay.Store.commitUpdate(new UpdateAccountMutation({
        id,
        displayName,
        email,
        sessionToken: viewer.sessionToken,
        viewer,
      }), {
        onSuccess: function ({updateAccount: {viewer: {...props}}}) {
          resolve({...props});
        },
        onFailure: function (transaction) {
          const error = transaction.getError();
          reject({error});
        },
      });

    })
Exemple #16
0
  handleAddCategoryClick = () => {
    //debug
    if(process.env.NODE_ENV == 'development')
      console.log({text:this.state.title})

    //title (не забыть добавить валидацию)
    var title = this.state.title;

    //add category
    Relay.Store.commitUpdate(new AddCategoryMutation({
      title: title,
      viewer: this.props.viewer
    }));

    //clear field
    this.setState({
      title: ''
    });
  }
Exemple #17
0
 handleSubmit = (e) => {
   e.preventDefault();
   let onSuccess = () => {
     $('#modal').closeModal();
   };
   let onFailure = (transaction) => {
     var error = transaction.getError() || new Error('Mutation failed.');
     console.error(error);
   };
   Relay.Store.commitUpdate(
     new CreateLinkMutation({
       title: this.refs.newTitle.value,
       url: this.refs.newUrl.value,
       store: this.props.store
     }),
     {onFailure, onSuccess}
   );
   this.refs.newTitle.value = "";
   this.refs.newUrl.value = "";
 };
  save(ev) {

    console.log('save', this.props);

    Relay.Store.commitUpdate(new UpdateProfileMutation({
      user_id: this.refs.owner_id.value,
      fname: this.refs.fname.value,
      lname: this.refs.lname.value,
      profile_id: this.refs.profile_id.value,
      viewer: this.props.viewer,
      profile: this.props.viewer.user.profile
    }), {
      onSuccess: (res) => {
        console.log('success', res)
        //history.pushState(null, `/campaigns`)
      },
      onFailure: (res) => console.log('fail', res)
    });

  }
Exemple #19
0
 onKeyPress(e) {
     if (e.charCode == ENTER_KEY_CODE) {
     
     let onSuccess = () => this.addEntryInput.value = "";
     
     let { text } = this.state;
     
     text = text.trim();
     
     if(text.length === 0) return;
     
     let createDate = moment().format();
     let addEntryMutation = new AddEntryMutation({text, createDate, viewer: this.props.viewer});
     Relay.Store.commitUpdate(addEntryMutation, {onSuccess: onSuccess});       
     
     
     // clean up the input box
     this.state.text = "";
      e.target.value = "";
     }
 };
	onSubmit = () => {
		const { express, note, status, pickupDate, pickupTime,
			address, pickupWorkerId, orderItems } = this.state;

		Relay.Store.commitUpdate(new CreateOrderMutation({
			user: this.props.user,
			express,
			note,
			status,
			pickupDate,
			pickupTime: `${pickupTime.start}~${pickupTime.end}`,
			pickupAddress: `${address.address}, ${address.postalCode} (${address.contact} ${address.contactName})`,
			pickupWorkerId,
			orderItems: orderItems.map(item => ({
				productId: item.id,
				washType: item.washType,
				quantity: item.quantity
			}))
		}), {onSuccess: this.onSuccess, onFailure: this.onFailure});
		this.setState({submitting: true});
	}
Exemple #21
0
  _ajouter(){
    var viewer = this.props.viewer;
    var amount = this.state.amount;
    var from = 'pas important'; // se fait dans le backend
    var projet = this.props.project;
    var name = this.state.name;
    var to = this.state.participants;
    to = _.map(to, (participant) => {
      return participant.id;
    })
    Relay.Store.commitUpdate(
      new CreateSpendingMutation({
        projet,
        to,
        amount,
      }),
      {
        onSuccess: ({CreateSpending}) => {
          var Spendings = CreateSpending.projet;

          Spendings = _.pickBy(Spendings, function (propertyName) {
              console.log('propertyName', propertyName);
              return (typeof propertyName === "object")
          });

          console.log('Spendings', Spendings);
          console.log('CreateSpending', CreateSpending);
          CreateSpending.projet.spendings = Spendings;
          var newdata = CreateSpending.projet;
          console.log('newdata', newdata);
          this.props.app.goToPrev();
        },
        onFailure: (err) => {
          var error = err.getError() || new Error('Mutation failed.');
          console.error(error);
          this.setState({state: 'fucked'});
        }
      }
    );
  }
Exemple #22
0
 _settingsUpdateMutation = () => {
   var scorable = Settings.scorable;
   var open = Settings.open;
   var schedule = Settings.schedule;
   schedule.map((schedule) => {
     delete schedule.__dataID__
     schedule.openHours.map((hours) => delete hours.__dataID__);
   });
   var resto = {
     id: this.props.id,
     scorable: scorable,
     open: open,
     schedule: schedule
   };
   var onFailure = () => {
     console.log('onFailure');
   };
   var onSuccess = () => {
     console.log('onSuccess');
     this.setState({save: false});
   };
   Relay.Store.commitUpdate(new UpdateRestaurantMutation({restaurant: resto}), {onFailure, onSuccess});
 };
Exemple #23
0
 handleSubmit = (e) => {
   e.preventDefault();
   //mutation
   Relay.Store.commitUpdate( //takes an instance of a mutation class as an argument
     new CreateCharacterMutation({
       firstName: this.refs.newFirstName.value,
       lastName: this.refs.newLastName.value,
       middleName: this.refs.newMiddleName.value,
       dob: this.refs.newDob.value,
       dod: this.refs.newDod.value,
       house: this.refs.newHouse.value,
       occupation: this.refs.newOccupation.value,
       magical: this.refs.newMagical.value,
       wand: this.refs.newWand.value,
       patronus: this.refs.newPatronus.value,
       DA: this.refs.newDA.value,
       deathEater: this.refs.newDeathEater.value,
       specialSkills: this.refs.newSpecialSkills.value,
       gender: this.refs.newGender.value,
       store: this.props.store
     })
   );
   this.refs.newFirstName = "";
   this.refs.newLastName = "";
   this.refs.newMiddleName = "";
   this.refs.newDob = "";
   this.refs.newDod = "";
   this.refs.newHouse = "";
   this.refs.newOccupation = "";
   this.refs.newMagical = "";
   this.refs.newWand = "";
   this.refs.newPatronus = "";
   this.refs.newDA = "";
   this.refs.newDeathEater = "";
   this.refs.newSpecialSkills = "";
   this.refs.newGender = "";
 };
 completedTodos.forEach((todo) => {
   Relay.Store.commitUpdate(
     new RemoveTodoMutation({todo: todo, viewer: this.props.viewer})
   )
 })
Exemple #25
0
 .forEach((edge) => Relay.Store.update(
   new ChangeTodoStatusMutation({
     id: edge.node.id,
     complete: setTo,
   })
 ));
	_deleteWidget(widget) {
		Relay.Store.commitUpdate(new DeleteWidgetMutation({
			viewer: this.props.viewer, widget, widgetId: widget.id
		}));			
	}
	_updateWidget(widget) {
		Relay.Store.commitUpdate(new UpdateWidgetMutation(
			Object.assign({	viewer: this.props.viewer, widget: widget }, widget)
		));		
	}
	_appendWidget(widget) {
		Relay.Store.commitUpdate(new InsertWidgetMutation(Object.assign({
			viewer: this.props.viewer, widget: null }, widget)));
	}
Exemple #29
0
		  .forEach((edge) => Relay.Store.update(
			new DeleteTodoMutation({
			  id: edge.node.id,
			  viewer: this.props.viewer,
			})
		  ));
Exemple #30
0
 _handleTextInputSave(text) {
   this._setEditMode(false);
   Relay.Store.commitUpdate(
     new RenameTodoMutation({todo: this.props.todo, text})
   );
 }