Skip to content

Commit ccc0a17

Browse files
committed
refactor(frontend): switch to graffle and re-organize directories
1 parent 3a8900f commit ccc0a17

File tree

6 files changed

+28
-97
lines changed

6 files changed

+28
-97
lines changed

frontend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"prepare": "cd .. && husky frontend/.husky"
1212
},
1313
"dependencies": {
14+
"@opentelemetry/api": "^1.9.0",
15+
"es-toolkit": "^1.25.2",
16+
"graffle": "^8.0.0-next.75",
1417
"graphql": "^16.9.0",
15-
"graphql-request": "^7.1.0",
1618
"next": "14.2.8",
1719
"react": "^18",
1820
"react-dom": "^18"

frontend/src/components/Footer.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import React from "react";
22

33
import Image from "next/image";
44

5-
import { Social } from "@/pages/queries";
5+
import { socialsQueryType } from "@/queries/socials";
66

7-
const Footer: React.FC<{ socials: Social[] }> = ({ socials }) => {
7+
interface IFooter {
8+
socials: socialsQueryType["socials"];
9+
}
10+
11+
const Footer: React.FC<IFooter> = ({ socials }) => {
812
return (
913
<div className={
1014
"py-4 bg-gradient-to-b from-light-blue to-30% to-kleros-purple"

frontend/src/pages/components/TrustedBy.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

frontend/src/pages/index.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import Footer from "@/components/Footer";
2-
import { graphQLClient } from "@/utils/graphQLClient";
2+
import TrustedBy from "@/components/TrustedBy";
3+
import { partnersQuery, partnersQueryType } from "@/queries/partners";
4+
import { socialsQuery, socialsQueryType } from "@/queries/socials";
35

4-
import TrustedBy from "./components/TrustedBy";
5-
import {
6-
partnersQueryDocument,
7-
Partner,
8-
Social,
9-
footerQueryDocument,
10-
} from "./queries";
6+
interface IHome {
7+
partners: partnersQueryType["partners"];
8+
socials: socialsQueryType["socials"];
9+
}
1110

12-
const Home: React.FC<{ partners: Partner[]; socials: Social[] }> = (
13-
{ partners, socials }
14-
) => {
11+
const Home: React.FC<IHome> = ({ partners, socials }) => {
1512
return (
1613
<div>
1714
<TrustedBy {...{ partners }}/>
@@ -21,14 +18,12 @@ const Home: React.FC<{ partners: Partner[]; socials: Social[] }> = (
2118
}
2219

2320
export const getStaticProps = async () => {
24-
const partnersData: { partners: Partner[] } =
25-
await graphQLClient.request(partnersQueryDocument, {});
26-
const socialsData: { socials: Social[] } =
27-
await graphQLClient.request(footerQueryDocument, {});
21+
const { partners } = await partnersQuery.run();
22+
const { socials } = await socialsQuery.run();
2823
return {
2924
props: {
30-
partners: partnersData?.partners,
31-
socials: socialsData?.socials
25+
partners,
26+
socials,
3227
}
3328
};
3429
};

frontend/src/pages/queries.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { GraphQLClient } from "graphql-request";
2-
1+
import { Graffle } from "@/graffle/__.js";
32
import { getStrapiURL } from "@/utils/getStrapiURL";
43

54
const endpoint = getStrapiURL("/graphql");
65

76
const token = process.env.STRAPI_TOKEN;
87

9-
export const graphQLClient = new GraphQLClient(
10-
endpoint,
11-
{
12-
headers: { Authorization: `Bearer ${token}` }
13-
}
14-
);
8+
export const graffle = Graffle.create({
9+
schema: endpoint,
10+
transport: {
11+
headers: { Authorization: `Bearer ${token}` },
12+
},
13+
});
1514

0 commit comments

Comments
 (0)