-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from Mlowegene/v2
Trust Relationships List Page
- Loading branch information
Showing
23 changed files
with
2,241 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import apiClient from '../utils/apiClient'; | ||
import { makeQueryString } from '../utils/formatting'; | ||
|
||
export const getTrustRelationships = async (token, {pagination, filter, sorting}) => { | ||
|
||
|
||
const { sort_by, order } = sorting; | ||
|
||
try { | ||
const where = filter.getWhereObj(); | ||
const trustRelationshipsFilter = { | ||
...pagination, | ||
...where, | ||
sort_by, | ||
order | ||
}; | ||
|
||
const queryString = makeQueryString(trustRelationshipsFilter); | ||
const response = await apiClient | ||
.setAuthHeader(token) | ||
.get(`/trust_relationships?${queryString}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
|
||
export const acceptTrustRelationship = async ({id, token}) => { | ||
try { | ||
const response = await apiClient | ||
.setAuthHeader(token) | ||
.get(`/trust_relationships/${id}/accept`); | ||
return response; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
|
||
export const declineTrustRelationship = async ({id, token}) => { | ||
try { | ||
const response = await apiClient | ||
.setAuthHeader(token) | ||
.get(`/trust_relationships/${id}/decline`); | ||
return response; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { getDateText } from "../utils/formatting"; | ||
|
||
export default class TrustRelationshipsFilter { | ||
// possible query options | ||
state; | ||
type; | ||
requestType; | ||
before; | ||
after; | ||
|
||
constructor(options) { | ||
// assign options properties to created instance | ||
Object.assign(this, options); | ||
} | ||
|
||
// where object contains the query options | ||
getWhereObj() { | ||
let where = {}; | ||
|
||
if (this.state) where.state = this.state.toLowerCase(); | ||
if (this.type) where.type = this.type.toLowerCase(); | ||
if (this.requestType) where.requestType = this.requestType.toLowerCase(); | ||
if (this.before) where.before = getDateText(this.before, 'YYYY-MM-DD'); | ||
if (this.after) where.after = getDateText(this.after, 'YYYY-MM-DD'); | ||
|
||
return where; | ||
} | ||
} |
Oops, something went wrong.