Skip to content

Commit

Permalink
Create meeting.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jul 9, 2018
1 parent ce83265 commit b79e65e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
28 changes: 28 additions & 0 deletions app/mutations/CreateMeetingMutation.js
@@ -0,0 +1,28 @@
import { graphql } from 'react-relay'
import commitMutation from 'relay-commit-mutation-promise'

const mutation = graphql`
mutation CreateMeetingMutation($input: createMeetingInput!) {
createMeeting(input: $input) {
meeting {
id
title
started
finished
}
}
}
`

function commit({ environment, input }) {
const variables = { input }

return commitMutation(environment, {
mutation,
variables
})
}

export default {
commit
}
26 changes: 17 additions & 9 deletions app/screens/Record.js
Expand Up @@ -4,18 +4,21 @@ import { StyleSheet, View, Text, SafeAreaView, Button, ScrollView } from 'react-
import HideableView from 'react-native-hideable-view';
import Icon from 'react-native-vector-icons/Ionicons';

import TimerMachine from 'react-timer-machine'
import TimerMachine from 'react-timer-machine';
import moment from "moment";
import momentDurationFormatSetup from "moment-duration-format";
momentDurationFormatSetup(moment);

import CreateMeetingMutation from '../mutations/CreateMeetingMutation';
import environment from '../Environment'

export default class Record extends React.Component {
constructor(props) {
super(props)
this.state = {
isMeetingStarted: false,
meetingStartedAt: null
}
}
}

startMeeting() {
Expand All @@ -24,13 +27,18 @@ export default class Record extends React.Component {

stopMeeting() {
this.setState({ isMeetingStarted: false, meetingStartedAt: null })

const meeting = {
startDateTime: this.state.meetingStartedAt,
endDateTime: new Date()
}

this.props.navigation.navigate('Main')
CreateMeetingMutation.commit({
environment,
input: {
title: 'Untitled Meeting',
started: this.state.meetingStartedAt,
finished: new Date()
}
}).then(response => {
this.props.navigation.navigate('Main')
}).catch(error => {
alert(error.message);
});
}

toggleMeeting() {
Expand Down

0 comments on commit b79e65e

Please sign in to comment.