-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
359 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,51 @@ | ||
import axios from "axios"; | ||
import { gql } from "graphql-request"; | ||
import useSWR from "swr"; | ||
|
||
const query = gql` | ||
{ | ||
query { | ||
allRescuenameNameAddeds { | ||
nodes { | ||
name | ||
vault | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export type ExpiryNames = { | ||
data: { | ||
query: { | ||
allRescuenameNameAddeds: { | ||
nodes: { | ||
name: string; | ||
vault: string; // but number | ||
}[]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
export const useExpiryNames = () => { | ||
return useSWR("/my/names", async (): Promise<string[]> => { | ||
// TODO: Placeholder | ||
const names = await fetch("./names.json"); | ||
return useSWR( | ||
"/my/names", | ||
async (): Promise<{ name: string; vault: string }[]> => { | ||
const x = await axios.post( | ||
// Yes, this uses a cors-anywhere bypass. This is a demo. | ||
// The streamingfast entrypoint doesnt output the right cors headers | ||
"https://cors-anywhere.herokuapp.com/https://srv.streamingfast.io/9e804b35/graphql", | ||
{ | ||
query | ||
} | ||
); | ||
|
||
// eslint-disable-next-line unicorn/no-await-expression-member | ||
const names2 = (await names.json())["names"]; | ||
const xy = x.data as ExpiryNames; | ||
|
||
return names2.filter((name: string) => name.length >= 5 + 4); | ||
}); | ||
return xy.data.query.allRescuenameNameAddeds.nodes.filter( | ||
(node) => node.name.length >= 5 | ||
); | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,9 @@ | ||
import * as React from "react" | ||
import { clsx, type ClassValue } from "clsx" | ||
import { twMerge } from "tailwind-merge" | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)) | ||
} | ||
|
||
export function formatDate(input: string | number): string { | ||
const date = new Date(input) | ||
return date.toLocaleDateString("en-US", { | ||
month: "long", | ||
day: "numeric", | ||
year: "numeric", | ||
}) | ||
} | ||
|
||
export function absoluteUrl(path: string) { | ||
return `${process.env.NEXT_PUBLIC_APP_URL}${path}` | ||
} | ||
const date = new Date(input); | ||
|
||
export function classNames(...classes: unknown[]): string { | ||
return classes.filter(Boolean).join(" "); | ||
return date.toLocaleDateString("en-US", { | ||
month: "long", | ||
day: "numeric", | ||
year: "numeric" | ||
}); | ||
} |