-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
many fixes and enhancements for ai chat
- Loading branch information
Showing
8 changed files
with
210 additions
and
26 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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Link } from "wouter" | ||
|
||
export const SnippetLink = ({ | ||
snippet, | ||
}: { | ||
snippet: { | ||
owner_name: string | ||
name: string | ||
unscoped_name: string | ||
} | ||
}) => { | ||
return ( | ||
<> | ||
<Link | ||
className="text-blue-500 font-semibold hover:underline" | ||
href={`/${snippet.owner_name}`} | ||
> | ||
{snippet.owner_name} | ||
</Link> | ||
<span className="px-0.5 text-gray-500">/</span> | ||
<Link | ||
className="text-blue-500 font-semibold hover:underline" | ||
href={`/${snippet.name}`} | ||
> | ||
{snippet.unscoped_name} | ||
</Link> | ||
</> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useState } from "react" | ||
import { useAxios } from "./use-axios" | ||
import { useMutation } from "react-query" | ||
import { Snippet } from "fake-snippets-api/lib/db/schema" | ||
|
||
export const useSaveSnippet = () => { | ||
const axios = useAxios() | ||
|
||
const saveSnippetMutation = useMutation< | ||
Snippet, | ||
Error, | ||
{ code: string; snippet_type: string } | ||
>({ | ||
mutationFn: async ({ code, snippet_type }) => { | ||
const response = await axios.post("/snippets/create", { | ||
code, | ||
snippet_type, | ||
owner_name: "seveibar", // Replace with actual user name or fetch from user context | ||
}) | ||
return response.data.snippet | ||
}, | ||
}) | ||
|
||
const saveSnippet = async (code: string, snippet_type: string) => { | ||
return saveSnippetMutation.mutateAsync({ code, snippet_type }) | ||
} | ||
|
||
return { | ||
saveSnippet, | ||
isLoading: saveSnippetMutation.isLoading, | ||
error: saveSnippetMutation.error, | ||
} | ||
} |
Oops, something went wrong.