Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-vm committed Mar 26, 2024
1 parent e6919e7 commit 6cbb06c
Show file tree
Hide file tree
Showing 56 changed files with 646 additions and 1,017 deletions.
6 changes: 6 additions & 0 deletions frontend/src/@types/general/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface PaginationMetadata {
page: number;
records: number;
total: number;
last_page: number;
}
1 change: 1 addition & 0 deletions frontend/src/@types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="./piece.d.ts" />
/// <reference path="./utils" />
/// <reference path="./general" />
34 changes: 0 additions & 34 deletions frontend/src/context/authentication/api/postAuthLogin.ts

This file was deleted.

35 changes: 0 additions & 35 deletions frontend/src/context/authentication/api/postAuthRegister.ts

This file was deleted.

21 changes: 11 additions & 10 deletions frontend/src/context/authentication/authentication.context.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { postAuthLogin, postAuthRegister } from "@features/auth/api";
import React, {
type ReactNode,
useCallback,
Expand All @@ -10,7 +11,6 @@ import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
import { createCustomContext } from "utils";

import { postAuthLogin, postAuthRegister } from "./api";
import {
type IAuthenticationContext,
type IAuthenticationStore,
Expand Down Expand Up @@ -45,6 +45,9 @@ export const AuthenticationProvider: React.FC<{ children: ReactNode }> = ({
userId,
tokenExpiresIn,
}));

console.log("here");

const currentDate = new Date();
const tokenExpirationDate = new Date(
currentDate.getTime() + tokenExpiresIn * 1000,
Expand Down Expand Up @@ -73,16 +76,14 @@ export const AuthenticationProvider: React.FC<{ children: ReactNode }> = ({
const authenticate = useCallback(
async (email: string, password: string) => {
setAuthLoading(true);
void postAuthLogin({ email, password })
await postAuthLogin({ email, password })
.then((res) => {
if (res.status === 200) {
login(
res.data.access_token,
res.data.user_id,
res.data.token_expires_in,
"/workspaces",
);
}
login(
res.access_token,
res.user_id,
res.token_expires_in,
"/workspaces",
);
})
.finally(() => {
setAuthLoading(false);
Expand Down
44 changes: 0 additions & 44 deletions frontend/src/context/workspaces/api/getWorkspaceId.ts

This file was deleted.

84 changes: 0 additions & 84 deletions frontend/src/context/workspaces/api/getWorkspaceMembers.ts

This file was deleted.

38 changes: 0 additions & 38 deletions frontend/src/context/workspaces/api/getWorkspaces.ts

This file was deleted.

42 changes: 25 additions & 17 deletions frontend/src/context/workspaces/repositories.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import {
type QueryObserverResult,
type RefetchOptions,
} from "@tanstack/react-query";
import { useStorage } from "context/storage/useStorage";
import {
type IGetRepoPiecesResponseInterface,
useAuthenticatedGetPieceRepositories,
useFetchAuthenticatedGetRepoIdPieces,
useRepositories,
useRepoIdPieces,
type IGetPiecesRepositoriesResponseInterface,
type IGetPiecesRepositoriesReleasesParams,
type IGetPiecesRepositoriesReleasesResponseInterface,
useAuthenticatedGetPieceRepositoriesReleases,
type RepositoriesReleasesParams,
type RepositoriesReleasesResponse,
useRepositoriesReleases,
useAuthenticatedDeleteRepository,
} from "features/myWorkflows/api";
import React, { useCallback, useEffect, useState } from "react";
import { toast } from "react-toastify";
import { type KeyedMutator } from "swr";
import { createCustomContext } from "utils";

import { useAuthenticatedPostPiecesRepository } from "./api";
Expand All @@ -30,16 +33,21 @@ export interface IPiecesContext {
selectedRepositoryId: null | number;
setSelectedRepositoryId: React.Dispatch<React.SetStateAction<number | null>>;

handleRefreshRepositories: KeyedMutator<
IGetPiecesRepositoriesResponseInterface | undefined
handleRefreshRepositories: (
options?: RefetchOptions | undefined,
) => Promise<
QueryObserverResult<
IGetPiecesRepositoriesResponseInterface | undefined,
Error
>
>;
handleAddRepository: (
params: Omit<IPostWorkspaceRepositoryPayload, "workspace_id">,
) => Promise<IPostWorkspaceRepositoryResponseInterface | unknown>;

handleFetchRepoReleases: (
params: IGetPiecesRepositoriesReleasesParams,
) => Promise<IGetPiecesRepositoriesReleasesResponseInterface | undefined>;
params: RepositoriesReleasesParams,
) => Promise<RepositoriesReleasesResponse | undefined>;

handleDeleteRepository: (id: string) => Promise<any>;

Expand Down Expand Up @@ -68,14 +76,14 @@ const PiecesProvider: React.FC<{ children: React.ReactNode }> = ({

const { workspace, handleRefreshWorkspaces } = useWorkspaces();

const fetchRepoById = useFetchAuthenticatedGetRepoIdPieces();
const fetchRepoById = useRepoIdPieces();

const {
data: repositories,
error: repositoriesError,
isValidating: repositoriesLoading,
mutate: handleRefreshRepositories,
} = useAuthenticatedGetPieceRepositories({});
isLoading: repositoriesLoading,
refetch: handleRefreshRepositories,
} = useRepositories();

useEffect(() => {
let active = true;
Expand Down Expand Up @@ -113,7 +121,7 @@ const PiecesProvider: React.FC<{ children: React.ReactNode }> = ({
}
}, [repositories, fetchRepoById]);

const { data: defaultRepositories } = useAuthenticatedGetPieceRepositories({
const { data: defaultRepositories } = useRepositories({
source: "default",
});

Expand Down Expand Up @@ -142,8 +150,8 @@ const PiecesProvider: React.FC<{ children: React.ReactNode }> = ({
[postRepository, handleRefreshWorkspaces, workspace?.id],
);

const handleFetchRepoReleases =
useAuthenticatedGetPieceRepositoriesReleases();
const { mutateAsync: handleFetchRepoReleases, data } =
useRepositoriesReleases();

const handleDeleteRepository = useAuthenticatedDeleteRepository();

Expand Down
Loading

0 comments on commit 6cbb06c

Please sign in to comment.