diondiondion 94314b2982 [Glitch] Implement editing collection settings and deleting collections
Port 6f53b0b634ee821272d2fc9c73c8ce0df7d63814 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2026-01-29 21:20:52 +01:00

40 lines
1.1 KiB
TypeScript

import {
apiRequestPost,
apiRequestPut,
apiRequestGet,
apiRequestDelete,
} from 'flavours/glitch/api';
import type {
ApiWrappedCollectionJSON,
ApiCollectionWithAccountsJSON,
ApiCreateCollectionPayload,
ApiUpdateCollectionPayload,
ApiCollectionsJSON,
} from '../api_types/collections';
export const apiCreateCollection = (collection: ApiCreateCollectionPayload) =>
apiRequestPost<ApiWrappedCollectionJSON>('v1_alpha/collections', collection);
export const apiUpdateCollection = ({
id,
...collection
}: ApiUpdateCollectionPayload) =>
apiRequestPut<ApiWrappedCollectionJSON>(
`v1_alpha/collections/${id}`,
collection,
);
export const apiDeleteCollection = (collectionId: string) =>
apiRequestDelete(`v1_alpha/collections/${collectionId}`);
export const apiGetCollection = (collectionId: string) =>
apiRequestGet<ApiCollectionWithAccountsJSON>(
`v1_alpha/collections/${collectionId}`,
);
export const apiGetAccountCollections = (accountId: string) =>
apiRequestGet<ApiCollectionsJSON>(
`v1_alpha/accounts/${accountId}/collections`,
);