Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnebai committed Apr 23, 2020
1 parent cb66c8f commit f6046a5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/screens/Main/RecordStack/QuestionsScreen/QuestionsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ interface Props {
export default function QuestionsScreen(props: Props) {
const [selected, setSelected] = useState<number | null>(null)
const [questions, setQuestions] = useState<Array<Question>>([])
let questionToRemove = 0
const {push} = props.navigation
const [modalVisibility, setModalVisibility] = useState(false)

Expand All @@ -44,17 +43,17 @@ export default function QuestionsScreen(props: Props) {
.catch(error => {
console.log('Error' + error)
})
}, [])
})

async function removeQuestion(){
async function removeQuestion(id: number){
fetch(`${BASE_PATH}/api/user/questions`, {
method: 'DELETE',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
'questionId': questionToRemove,
'questionId': id,
}),
})
.then(res => res.json())
Expand All @@ -81,14 +80,13 @@ export default function QuestionsScreen(props: Props) {
{text: 'View Answer'},
{text: 'Re-record Answer',
onPress: () => {
questionToRemove = item.ID
Alert.alert(
'Are you sure you want to re-record your clip?',
'You\'ll lose your old clip',
[
{text: 'Re-record',
onPress: () => {
removeQuestion()
removeQuestion(item.ID)
push('Record', {question: item.text})
}
},
Expand Down

0 comments on commit f6046a5

Please sign in to comment.