GitButler WIP Commit

This commit is contained in:
GitButler 2024-07-03 14:40:45 +02:00 committed by Caleb Owens
parent 9301248b00
commit c42738dd95
No known key found for this signature in database
2 changed files with 45 additions and 2 deletions

View File

@ -0,0 +1,43 @@
import type { HttpClient } from '$lib/backend/httpClient';
import type { CloudProject, Project } from '$lib/projects/types';
export class ProjectService {
constructor(
private project: Project,
private httpClient: HttpClient
) {}
async createCloudProject(
token: string,
params: {
name: string;
description?: string;
uid?: string;
}
): Promise<CloudProject> {
return await this.httpClient.post('projects.json', {
body: params,
token
});
}
async updateCloudProject(
token: string,
repositoryId: string,
params: {
name: string;
description?: string;
}
): Promise<CloudProject> {
return await this.httpClient.put(`projects/${repositoryId}.json`, {
body: params,
token
});
}
async getCloudProject(token: string, repositoryId: string): Promise<CloudProject> {
return await this.httpClient.get(`projects/${repositoryId}.json`, {
token
});
}
}

View File

@ -21,7 +21,7 @@ export async function load({ params, parent }) {
const {
authService,
githubService,
projectService,
projectListingService,
remoteUrl$,
} = await parent();
@ -31,7 +31,7 @@ export async function load({ params, parent }) {
// synchronously available are much greater than the cost.
let project: Project | undefined = undefined;
try {
project = await projectService.getProject(projectId);
project = await projectListingService.getProject(projectId);
invoke('set_project_active', { id: projectId }).then((_r) => {});
} catch (err: any) {
throw error(400, {