[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 lines
983 B

import { fetch } from './fetch'
import { Entity } from '../types'
interface GroupsResponse {
groups: Entity[]
continuation?: string
}
interface NewGroupResponse {
id: string
}
export async function getGroup(id: string) {
return await fetch<Entity>({
path: `/api/group/${id}`
})
}
export async function getGroups(sort: string = 'members', continuation?: string) {
const params = {
sort,
continuation,
}
const querystring = Object.entries(params).filter(([name, value]) => value !== undefined).map(([name, value]) => `${name}=${value}`).join('&')
return await fetch<GroupsResponse>({
path: `/api/groups?${querystring}`
})
}
export async function createGroup(name: string, registration: string, about?: string) {
return await fetch<NewGroupResponse>({
path: '/api/group',
method: 'post',
body: {
name,
registration,
about,
},
})
}