diff --git a/biome.json b/biome.json index 778d88b..4887cd4 100644 --- a/biome.json +++ b/biome.json @@ -28,7 +28,8 @@ }, "nursery": { "recommended": true, - "useConsistentMemberAccessibility": "off" + "useConsistentMemberAccessibility": "off", + "noUselessEscapeInRegex": "info" }, "correctness": { "recommended": true, diff --git a/package.json b/package.json index d573100..78785ad 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,9 @@ "description": "seamlessly integrate a comment section into your React or Astro project", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", - "files": ["dist"], + "files": [ + "dist" + ], "scripts": { "build": "rollup -c --bundleConfigAsCjs", "dev": "", @@ -24,16 +26,16 @@ "homepage": "https://github.com/atybdot/app-comment-react", "dependencies": { "appwrite": "^16.0.2", - "react": "^18.3.1", - "react-dom": "^18.3.1", "javascript-time-ago": "^2.5.11", "lucide-react": "^0.453.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", "react-hook-form": "^7.53.1", "react-hot-toast": "^2.4.1", - "react-time-ago": "^7.3.3", - "zustand": "^5.0.0" + "react-time-ago": "^7.3.3" }, "devDependencies": { + "@babel/preset-react": "^7.25.9", "@biomejs/biome": "1.9.4", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-commonjs": "^28.0.1", @@ -49,8 +51,7 @@ "rollup-plugin-dts": "^6.1.1", "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-postcss": "^4.0.2", - "tailwindcss": "^3.4.14", - "@babel/preset-react": "^7.25.9" + "tailwindcss": "^3.4.14" }, "publishConfig": { "access": "public" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02d89e4..675190e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ importers: react-time-ago: specifier: ^7.3.3 version: 7.3.3(javascript-time-ago@2.5.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - zustand: - specifier: ^5.0.0 - version: 5.0.0(react@18.3.1) devDependencies: '@babel/preset-react': specifier: ^7.25.9 @@ -1474,24 +1471,6 @@ packages: engines: {node: '>= 14'} hasBin: true - zustand@5.0.0: - resolution: {integrity: sha512-LE+VcmbartOPM+auOjCCLQOsQ05zUTp8RkgwRzefUk+2jISdMMFnxvyTjA4YNWr5ZGXYbVsEMZosttuxUBkojQ==} - engines: {node: '>=12.20.0'} - peerDependencies: - '@types/react': '>=18.0.0' - immer: '>=9.0.6' - react: '>=18.0.0' - use-sync-external-store: '>=1.2.0' - peerDependenciesMeta: - '@types/react': - optional: true - immer: - optional: true - react: - optional: true - use-sync-external-store: - optional: true - snapshots: '@alloc/quick-lru@5.2.0': {} @@ -2843,7 +2822,3 @@ snapshots: yaml@1.10.2: {} yaml@2.6.0: {} - - zustand@5.0.0(react@18.3.1): - optionalDependencies: - react: 18.3.1 diff --git a/src/components/AuthForm.jsx b/src/components/AuthForm.jsx index 22b209d..97f3779 100644 --- a/src/components/AuthForm.jsx +++ b/src/components/AuthForm.jsx @@ -1,15 +1,16 @@ import { Eye, EyeOff, X } from "lucide-react" -import { forwardRef, useEffect, useRef, useState } from "react" +import { forwardRef, useEffect, useState } from "react" import { useForm } from "react-hook-form" +import { Loading, onInvalid, onSucess } from "../utils/utils" + import toast from "react-hot-toast" import { emailLogin, emailSignup, getUser } from "../lib/appwrite" -import useCommentStore from "../store/commentsStore" -import { Loading, onInvalid, onSucess } from "../utils/utils" +import useComment from "../store/commentContext" import CustomToast from "./CustomToast" const SignupForm = () => { const [showPassword, setShowPassword] = useState(false) - const { updateUser, updateLoginState } = useCommentStore() + const { updateUser, updateLoginState } = useComment() const { register, handleSubmit, @@ -59,7 +60,9 @@ const SignupForm = () => { { } const LoginForm = () => { - const { updateUser, user, updateLoginState } = useCommentStore() + const { updateLoginState, updateUser } = useComment() const [showPassword, setShowPassword] = useState(false) const { register, @@ -271,6 +274,7 @@ const AuthForm = forwardRef((props, ref) => { ref={ref} > - + {showEdit ? ( + + ) : null} + + {showDel ? ( + + ) : null} diff --git a/src/components/CommentSection.jsx b/src/components/CommentSection.jsx index 08d09c9..b85d2ad 100644 --- a/src/components/CommentSection.jsx +++ b/src/components/CommentSection.jsx @@ -1,20 +1,17 @@ import { useEffect } from "react" import { Suspense } from "react" +import { useState } from "react" import { commentDB, getUser, logoutUser } from "../lib/appwrite" -import useCommentStore from "../store/commentsStore" +import { CommentProvider } from "../store/commentContext" import { onInvalid, onSucess } from "../utils/utils" import Comment from "./Comment" +import CustomToast from "./CustomToast" import PostComment from "./PostComment" export default function CommentSection({ postId }) { - const { - loginState, - updateUser, - updateLoginState, - user, - comments, - setComments, - } = useCommentStore() + const [loginState, updateLoginState] = useState(false) + const [user, updateUser] = useState({ id: "", name: "" }) + const [comments, setComments] = useState([]) const handleLogout = async () => { try { @@ -50,9 +47,18 @@ export default function CommentSection({ postId }) { }, []) return ( - <> - +
+

Comments

@@ -77,11 +83,12 @@ export default function CommentSection({ postId }) { timestamp={comment.$updatedAt} username={comment.username} commentId={comment.$id} + permissions={comment.$permissions} /> ))}
- +
) } diff --git a/src/components/CustomToast.jsx b/src/components/CustomToast.jsx index fef4833..08aea11 100644 --- a/src/components/CustomToast.jsx +++ b/src/components/CustomToast.jsx @@ -15,6 +15,7 @@ function CustomToast() { {message} {t.type !== "loading" && (