Skip to content

Commit

Permalink
Merge pull request #22 from L-Steinmacher/refactor
Browse files Browse the repository at this point in the history
update all the things!!!!
  • Loading branch information
L-Steinmacher authored Sep 22, 2023
2 parents 3c00713 + 38eb2b0 commit a706693
Show file tree
Hide file tree
Showing 10 changed files with 1,737 additions and 830 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DISCORD_CLIENT_SECRET=""
# Google reCAPTCHA V2 Provider
# https://developers.google.com/recaptcha/intro
GOOGLE_RECATPTCHA_SECRET_KEY="google recaptcha secret key"
NEXT_PUBLIC_RECAPTCHA_KEY="google recaptcha site key"
GOOGLE_PUBLIC_RECAPTCHA_KEY="google recaptcha site key"

# These are all generated from Vercel Postgres Database and can be found in the Vercel Dashboard
# Setup is free and easy. I'm not paid to say this, I just like it. Follow the instructions here:
Expand Down
2 changes: 1 addition & 1 deletion lib/markdownToHtml.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import remarkHtml from 'remark-html'
import remarkParse from 'remark-parse/lib'
import remarkParse from 'remark-parse'
import { type Plugin, unified } from 'unified'

export default async function markdownToHtml(markdown: string) {
Expand Down
2,462 changes: 1,687 additions & 775 deletions package-lock.json

Large diffs are not rendered by default.

78 changes: 39 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,60 +41,60 @@
"/server-build"
],
"dependencies": {
"@next-auth/prisma-adapter": "^1.0.5",
"@prisma/client": "^5.1.0",
"@t3-oss/env-nextjs": "^0.3.1",
"@tanstack/react-query": "^4.29.7",
"@trpc/client": "^10.26.0",
"@trpc/next": "^10.26.0",
"@trpc/react-query": "^10.26.0",
"@trpc/server": "^10.26.0",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.3.1",
"@t3-oss/env-nextjs": "^0.6.1",
"@tanstack/react-query": "^4.35.3",
"@trpc/client": "^10.38.4",
"@trpc/next": "^10.38.4",
"@trpc/react-query": "^10.38.4",
"@trpc/server": "^10.38.4",
"@vercel/analytics": "^1.0.2",
"@vercel/postgres": "^0.4.1",
"@vercel/postgres": "^0.5.0",
"bad-words": "^3.0.4",
"date-fns": "^2.30.0",
"esm": "^3.2.25",
"gray-matter": "^4.0.3",
"langchain": "^0.0.146",
"lru-cache": "^10.0.0",
"next": "^13.4.2",
"next-auth": "^4.22.1",
"langchain": "^0.0.153",
"lru-cache": "^10.0.1",
"next": "^13.5.2",
"next-auth": "^4.23.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-google-recaptcha": "^3.1.0",
"reading-time": "^1.5.0",
"rehype-highlight": "^6.0.0",
"remark": "^14.0.3",
"rehype-highlight": "^7.0.0",
"remark": "^15.0.1",
"remark-html": "^15.0.2",
"remark-parse": "^10.0.2",
"resend": "^1.0.0",
"superjson": "1.12.2",
"unified": "^10.1.2",
"zod": "^3.21.4"
"remark-parse": "^11.0.0",
"resend": "^1.1.0",
"superjson": "1.13.1",
"unified": "^11.0.3",
"zod": "^3.22.2"
},
"devDependencies": {
"@faker-js/faker": "^8.0.2",
"@playwright/test": "^1.36.0",
"@faker-js/faker": "^8.1.0",
"@playwright/test": "^1.38.1",
"@types/bad-words": "^3.0.1",
"@types/eslint": "^8.37.0",
"@types/node": "^18.17.0",
"@types/prettier": "^2.7.2",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@types/eslint": "^8.44.2",
"@types/node": "^20.6.3",
"@types/prettier": "^2.7.3",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"@types/react-google-recaptcha": "^2.1.5",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"autoprefixer": "^10.4.14",
"eslint": "^8.40.0",
"eslint-config-next": "^13.4.2",
"postcss": "^8.4.21",
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.2.8",
"prisma": "^5.1.0",
"tailwindcss": "^3.3.0",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"autoprefixer": "^10.4.16",
"eslint": "^8.49.0",
"eslint-config-next": "^13.5.2",
"postcss": "^8.4.30",
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.5.4",
"prisma": "^5.3.1",
"tailwindcss": "^3.3.3",
"ts-node": "^10.9.1",
"tsx": "^3.12.7",
"typescript": "^5.1.6"
"tsx": "^3.12.10",
"typescript": "^5.2.2"
},
"prisma": {
"schema": "./prisma/schema.prisma",
Expand Down
3 changes: 3 additions & 0 deletions src/components/commentDeleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export default function CommentDeleteButton({
onSuccess: async () => {
await utils.comments.invalidate();
},
onError: error => {
console.log('error deleting comment', error);
}
});

function handleDeleteComment(commentId: string) {
Expand Down
9 changes: 5 additions & 4 deletions src/components/commentEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function CommentEditModal({ comment }: { comment: Comment }) {

const [isModalOpen, setIsModalOpen] = useState(false);
const [commentContent, setCommentContent] = useState<string>(
comment?.content,
comment.content,
);
const [caseType, setCaseType] = useState<string>('none');
const [isTranslating, setIsTranslating] = useState(false);
Expand All @@ -35,9 +35,9 @@ export default function CommentEditModal({ comment }: { comment: Comment }) {
};

useEffect(() => {
if (!commentContent) {
setCommentContent(comment?.content);
}
// if (!commentContent) {
// setCommentContent(comment?.content);
// }
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
closeModal();
Expand All @@ -64,6 +64,7 @@ export default function CommentEditModal({ comment }: { comment: Comment }) {
window.removeEventListener('keydown', handleKeyDown);
document.removeEventListener('click', handleOutsideClick);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const utils = api.useContext();
Expand Down
4 changes: 1 addition & 3 deletions src/components/commentLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { signIn } from 'next-auth/react';
import ReCAPTCHA from 'react-google-recaptcha';


import { typedBoolean } from '~/utils/miscUtils';
import CommentCard from './commentCard';
import useController from '~/hooks/useController';

const RECAPTCHA_SITE_KEY = process.env.NEXT_PUBLIC_RECAPTCHA_KEY;
const RECAPTCHA_SITE_KEY = process.env.GOOGLE_PUBLIC_RECAPTCHA_KEY;

export function CommentLayout({ slug }: { slug: string }) {

Expand All @@ -21,7 +20,6 @@ export function CommentLayout({ slug }: { slug: string }) {
setGotime,
commentContainerRef,
userIsLoggedIn,

} = useController({ slug })

return (
Expand Down
3 changes: 0 additions & 3 deletions src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const env = createEnv({
// VERCEL: z.string().optional(),
VERCEL_ENV: z.string().optional(),
GOOGLE_RECATPTCHA_SECRET_KEY: z.string(),
NEXT_PUBLIC_RECAPTCHA_KEY: z.string(),
RESEND_API_KEY: z.string().min(1),
ADMIN_EMAIL: z.string().email(),
},
Expand All @@ -47,7 +46,6 @@ export const env = createEnv({
* `NEXT_PUBLIC_`.
*/
client: {
NEXT_PUBLIC_RECAPTCHA_KEY: z.string(),
// NEXT_PUBLIC_CLIENTVAR: z.string().min(1),
},

Expand Down Expand Up @@ -75,7 +73,6 @@ export const env = createEnv({
// VERCEL: process.env.VERCEL,
VERCEL_ENV: process.env.VERCEL_ENV,
GOOGLE_RECATPTCHA_SECRET_KEY: process.env.GOOGLE_RECATPTCHA_SECRET_KEY,
NEXT_PUBLIC_RECAPTCHA_KEY: process.env.NEXT_PUBLIC_RECAPTCHA_KEY,
RESEND_API_KEY: process.env.RESEND_API_KEY,
ADMIN_EMAIL: process.env.ADMIN_EMAIL,
},
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function useController({ slug }: { slug: string}) {
const userIsLoggedIn = !!sessionData;

const utils = api.useContext();
// const createCommentMutation = api.comments.createComment.useMutation();

useEffect(() => {
if (commentsData) {
Expand Down
3 changes: 0 additions & 3 deletions src/server/api/routers/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { z } from "zod";
import { LangCall } from "~/utils/langCall";
import { getPostBySlug } from "lib/blogApi";
import { type NonNullablePostOptions } from "~/interfaces/post";
import markdownToHtml from "lib/markdownToHtml";
import BadWordsFilter from "bad-words";

export const defaultCommentSelect = Prisma.validator<Prisma.CommentSelect>()({
Expand Down Expand Up @@ -100,8 +99,6 @@ export const translationRouter = createTRPCRouter({
message: "No post found!",
});
}
// parse markdown from postData.content to string utf8
const postContent =

console.log(postData.content);
newCommentContent = await LangCall(cleanedComment, caseType, postData.content);
Expand Down

0 comments on commit a706693

Please sign in to comment.