Skip to content

Commit 7c8b99c

Browse files
committed
Refactored Policies.js
1 parent 55721ed commit 7c8b99c

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/pages/Policies.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React, { useState, useEffect } from 'react'
2-
import axios from 'axios'
3-
import { apiURL } from '../config.json'
42
import Navigation from '../components/Navigation'
53
import ReactMarkdown from 'react-markdown'
64
import { Helmet } from 'react-helmet'
75
import { usePromiseTracker, trackPromise } from 'react-promise-tracker'
86
import LoadingIndicator from '../modules/LoadingIndicator'
7+
import userStory from '../services/user_story'
98

109
const Policies = () => {
1110
const [policies, setPolicies] = useState('')
@@ -14,19 +13,7 @@ const Policies = () => {
1413

1514
useEffect(() => {
1615
const fetchPolicies = async () => {
17-
const response = await axios.post(
18-
`${apiURL}/graphql`,
19-
{
20-
query: `query {
21-
userStoryPolicies {
22-
Description
23-
}
24-
}`
25-
},
26-
{
27-
withCredentials: true
28-
}
29-
)
16+
const response = await userStory.getPolicies()
3017
setPolicies(response.data.data.userStoryPolicies?.[0].Description)
3118
}
3219
trackPromise(fetchPolicies())

src/services/user_story.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ const userStory = {
147147
}
148148
return apiCall('/graphql', categoryQuery)
149149
},
150+
getPolicies: () => {
151+
const policyQuery = {
152+
query: `query {
153+
userStoryPolicies {
154+
Description
155+
}
156+
}`
157+
}
158+
return apiCall('/graphql', policyQuery)
159+
},
150160
getPriorities: () => {
151161
const priorityQuery = {
152162
query: `query { __type(name: "ENUM_USERSTORY_PRIORITY") {enumValues {name}}}`

0 commit comments

Comments
 (0)