refactor: remove authentication check and unused imports from CreatePost and EditPost pages
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 17s

This commit is contained in:
2025-10-26 18:33:31 +08:00
parent 1f6bb77691
commit 9c263d0f51
2 changed files with 2 additions and 14 deletions

View File

@@ -1,18 +1,16 @@
import { useState, useRef } from 'react'; import { useState, useRef } from 'react';
import { Navigate, useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import Layout from '../components/Layout'; import Layout from '../components/Layout';
import BlogEditor, { type BlogEditorRef } from '../blog/BlogEditor'; import BlogEditor, { type BlogEditorRef } from '../blog/BlogEditor';
import { uploadImage, createBlogPost } from '../blog/api'; import { uploadImage, createBlogPost } from '../blog/api';
import { Toast } from '../components/Toast'; import { Toast } from '../components/Toast';
import { useToast } from '../hooks/useToast'; import { useToast } from '../hooks/useToast';
import { useAuth } from '../contexts/AuthContext';
import '../App.css'; import '../App.css';
function CreatePost() { function CreatePost() {
const navigate = useNavigate(); const navigate = useNavigate();
const editorRef = useRef<BlogEditorRef>(null); const editorRef = useRef<BlogEditorRef>(null);
const { toasts, removeToast, success, error } = useToast(); const { toasts, removeToast, success, error } = useToast();
const { isAuthenticated } = useAuth();
const [title, setTitle] = useState(''); const [title, setTitle] = useState('');
const [coverImage, setCoverImage] = useState<string | null>(null); const [coverImage, setCoverImage] = useState<string | null>(null);
const [coverImageKey, setCoverImageKey] = useState<string>(''); const [coverImageKey, setCoverImageKey] = useState<string>('');
@@ -101,10 +99,6 @@ function CreatePost() {
} }
}; };
if (!isAuthenticated) {
return <Navigate to="/blog" replace />;
}
return ( return (
<Layout currentPage="blog"> <Layout currentPage="blog">
<Toast toasts={toasts} onRemove={removeToast} /> <Toast toasts={toasts} onRemove={removeToast} />

View File

@@ -1,11 +1,10 @@
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { Navigate, useNavigate, useParams } from 'react-router-dom'; import { useNavigate, useParams } from 'react-router-dom';
import Layout from '../components/Layout'; import Layout from '../components/Layout';
import BlogEditor, { type BlogEditorRef } from '../blog/BlogEditor'; import BlogEditor, { type BlogEditorRef } from '../blog/BlogEditor';
import { getBlogPost, updateBlogPost, uploadImage } from '../blog/api'; import { getBlogPost, updateBlogPost, uploadImage } from '../blog/api';
import { Toast } from '../components/Toast'; import { Toast } from '../components/Toast';
import { useToast } from '../hooks/useToast'; import { useToast } from '../hooks/useToast';
import { useAuth } from '../contexts/AuthContext';
import '../App.css'; import '../App.css';
function EditPost() { function EditPost() {
@@ -14,7 +13,6 @@ function EditPost() {
const editorRef = useRef<BlogEditorRef>(null); const editorRef = useRef<BlogEditorRef>(null);
const fileInputRef = useRef<HTMLInputElement>(null); const fileInputRef = useRef<HTMLInputElement>(null);
const { toasts, removeToast, success, error } = useToast(); const { toasts, removeToast, success, error } = useToast();
const { isAuthenticated } = useAuth();
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [loadError, setLoadError] = useState<string | null>(null); const [loadError, setLoadError] = useState<string | null>(null);
@@ -138,10 +136,6 @@ function EditPost() {
} }
}; };
if (!isAuthenticated) {
return <Navigate to="/blog" replace />;
}
return ( return (
<Layout currentPage="blog"> <Layout currentPage="blog">
<Toast toasts={toasts} onRemove={removeToast} /> <Toast toasts={toasts} onRemove={removeToast} />