Skip to content

Commit

Permalink
feat(auth): handle redirections from fluentci.io
Browse files Browse the repository at this point in the history
feat(auth): handle redirections from fluentci.io

fix localStorage

fix localStorage

fix localStorage

fix localStorage

fix localStorage

fix localStorage

fix localStorage

fix localStorage

feat(auth): handle redirections from fluentci.io

feat(auth): handle redirections from fluentci.io
  • Loading branch information
tsirysndr committed Aug 11, 2024
1 parent 0205a66 commit 58f1474
Show file tree
Hide file tree
Showing 8 changed files with 450 additions and 0 deletions.
Binary file modified webui/bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions webui/codegen.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
overwrite: true
#schema: "https://api.fluentci.io/graphql"
#schema: "http://127.0.0.1:6076/graphql"
schema: "http://127.0.0.1:8787/graphql"
documents: "src/**/*.tsx"
Expand Down
223 changes: 223 additions & 0 deletions webui/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,65 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Category",
"description": null,
"fields": [
{
"name": "id",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "name",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "slug",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Float",
Expand Down Expand Up @@ -1085,6 +1144,39 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "starPackage",
"description": null,
"args": [
{
"name": "id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Package",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "unarchiveProject",
"description": null,
Expand Down Expand Up @@ -1143,6 +1235,39 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "unstarPackage",
"description": null,
"args": [
{
"name": "id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Package",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updateProject",
"description": null,
Expand Down Expand Up @@ -1290,6 +1415,26 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "categories",
"description": null,
"args": [],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Category",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "createdAt",
"description": null,
Expand Down Expand Up @@ -1957,6 +2102,39 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "countPackageStars",
"description": null,
"args": [
{
"name": "id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "countPackages",
"description": null,
Expand Down Expand Up @@ -2479,6 +2657,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "orderBy",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "skip",
"description": null,
Expand Down Expand Up @@ -2691,6 +2881,39 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "starredPackage",
"description": null,
"args": [
{
"name": "id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "versions",
"description": null,
Expand Down
20 changes: 20 additions & 0 deletions webui/src/Containers/Auth/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useEffect } from "react";
import { SignIn } from "@clerk/clerk-react";
import styled from "@emotion/styled";
import { useSearchParams } from "react-router-dom";

const Container = styled.div`
display: flex;
Expand All @@ -10,6 +12,24 @@ const Container = styled.div`
`;

export default function Auth() {
const [qs] = useSearchParams();
const redirect = qs.get("redirect");
const action = qs.get("action");
const id = qs.get("id");

useEffect(() => {
if (redirect && action && id) {
localStorage.setItem(
"extra",
JSON.stringify({
redirect,
action,
id,
})
);
}
}, [redirect, action, id]);

return (
<Container>
<SignIn path="/auth" />
Expand Down
26 changes: 26 additions & 0 deletions webui/src/Containers/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Loading from "./Loading";
import { useRecoilState } from "recoil";
import { HomeState } from "./HomeState";
import Navbar from "../../Components/Navbar";
import { useStarPackageMutation } from "../../Hooks/GraphQL";

const Container = styled.div`
height: calc(100vh - 30px);
Expand All @@ -16,12 +17,37 @@ const Container = styled.div`

const Home: FC = () => {
const [{ loading }, setState] = useRecoilState(HomeState);
const [starPackage] = useStarPackageMutation();

const setLoading = (loading: boolean) => {
setState({ loading });
};

useEffect(() => {
const extra = localStorage.getItem("extra");
if (extra) {
const { id, redirect, action } = JSON.parse(extra);
console.log("extra", extra);
console.log({ id, redirect, action });
switch (action) {
case "star":
starPackage({
variables: {
id,
},
})
.then((res) => {
localStorage.removeItem("extra");
console.log(res);
window.location.href = `https://fluentci.io${redirect}`;
})
.catch((e) => console.error(e));
break;
default:
break;
}
}

if (!location.host) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).ipcRenderer.on(
Expand Down
23 changes: 23 additions & 0 deletions webui/src/GraphQL/Fragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,26 @@ export const OrganizationFragment = gql`
createdAt
}
`;

export const PackageFragment = gql`
fragment PackageFragment on Package {
id
name
publisher
description
version
owner
downloads
repoName
logoUrl
githubUrl
license
createdAt
updatedAt
categories {
id
name
slug
}
}
`;
Loading

0 comments on commit 58f1474

Please sign in to comment.