From eedb1558802c9b87c9f9b9b20143abb59a7c83b1 Mon Sep 17 00:00:00 2001 From: Ardeman Date: Tue, 25 Mar 2025 19:25:49 +0800 Subject: [PATCH] refactor: remove ProfileIcon component and update image handling for author profiles --- app/components/icons/profile.tsx | 23 ----------------------- app/components/ui/news-author.tsx | 18 ++++++++---------- app/layouts/admin/navbar.tsx | 21 +++++++++++---------- app/pages/dashboard-contents/index.tsx | 2 +- app/pages/dashboard-staffs/index.tsx | 18 +++++++++++++++--- app/pages/dashboard-users/index.tsx | 2 +- public/images/profile-placeholder.svg | 6 ++++++ 7 files changed, 42 insertions(+), 48 deletions(-) delete mode 100644 app/components/icons/profile.tsx create mode 100644 public/images/profile-placeholder.svg diff --git a/app/components/icons/profile.tsx b/app/components/icons/profile.tsx deleted file mode 100644 index 240c438..0000000 --- a/app/components/icons/profile.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import type { JSX, SVGProps } from 'react' - -export const ProfileIcon = ( - properties: JSX.IntrinsicAttributes & SVGProps, -) => { - return ( - - - - ) -} diff --git a/app/components/ui/news-author.tsx b/app/components/ui/news-author.tsx index 20537ae..3a3fa5f 100644 --- a/app/components/ui/news-author.tsx +++ b/app/components/ui/news-author.tsx @@ -1,5 +1,4 @@ import type { TAuthorResponse } from '~/apis/common/get-news' -import { ProfileIcon } from '~/components/icons/profile' import { formatDate } from '~/utils/formatter' type TDetailNewsAuthor = { @@ -11,15 +10,14 @@ type TDetailNewsAuthor = { export const NewsAuthor = ({ author, live_at, text }: TDetailNewsAuthor) => { return (
- {author?.profile_picture ? ( - {author?.name} - ) : ( - - )} + { + event.currentTarget.src = '/images/profile-placeholder.svg' + }} + alt={author?.name} + className="size-12 rounded-full bg-[#C4C4C4] object-cover" + />

{author?.name}

diff --git a/app/layouts/admin/navbar.tsx b/app/layouts/admin/navbar.tsx index 2e030a5..ceab65a 100644 --- a/app/layouts/admin/navbar.tsx +++ b/app/layouts/admin/navbar.tsx @@ -6,7 +6,6 @@ import { import { ChevronDownIcon } from '@heroicons/react/24/solid' import { Link, useFetcher, useRouteLoaderData } from 'react-router' -import { ProfileIcon } from '~/components/icons/profile' import { Button } from '~/components/ui/button' import { APP } from '~/configs/meta' import { useAdminContext } from '~/contexts/admin' @@ -34,15 +33,17 @@ export const Navbar = () => {
- {staffData?.profile_picture ? ( - {staffData?.name} - ) : ( - - )} + { + event.currentTarget.src = '/images/profile-placeholder.svg' + }} + alt={staffData?.name} + className="size-8 rounded-full bg-[#C4C4C4] object-cover" + /> {staffData?.name}
diff --git a/app/pages/dashboard-contents/index.tsx b/app/pages/dashboard-contents/index.tsx index 656f164..4ab7b46 100644 --- a/app/pages/dashboard-contents/index.tsx +++ b/app/pages/dashboard-contents/index.tsx @@ -72,7 +72,7 @@ export const ContentsPage = () => { 2: (value: TAuthorResponse) => ( <>
{value.name}
-
ID: {value.id.slice(0, 8)}
+
ID: {value.id.slice(0, 8)}
), 3: (value: string) => {value}, diff --git a/app/pages/dashboard-staffs/index.tsx b/app/pages/dashboard-staffs/index.tsx index 98a7313..cd6b98c 100644 --- a/app/pages/dashboard-staffs/index.tsx +++ b/app/pages/dashboard-staffs/index.tsx @@ -39,9 +39,21 @@ export const StaffsPage = () => { ] const dataSlot: DataTableSlots = { 1: (_value: unknown, _type: unknown, data: TStaffResponse) => ( -
-
{data.name}
-
ID: {data.id.slice(0, 8)}
+
+ { + event.currentTarget.src = '/images/profile-placeholder.svg' + }} + alt={data?.name} + className="size-8 rounded-full bg-[#C4C4C4] object-cover" + /> +
+
{data.name}
+
+ ID: {data.id.slice(0, 8)} +
+
), } diff --git a/app/pages/dashboard-users/index.tsx b/app/pages/dashboard-users/index.tsx index 309a5bd..ebf30ac 100644 --- a/app/pages/dashboard-users/index.tsx +++ b/app/pages/dashboard-users/index.tsx @@ -55,7 +55,7 @@ export const UsersPage = () => { 2: (_value: unknown, _type: unknown, data: TUserResponse) => (
{data.email}
-
ID: {data.id.slice(0, 8)}
+
ID: {data.id.slice(0, 8)}
), 3: (value: string) => {value}, diff --git a/public/images/profile-placeholder.svg b/public/images/profile-placeholder.svg new file mode 100644 index 0000000..76b9ccc --- /dev/null +++ b/public/images/profile-placeholder.svg @@ -0,0 +1,6 @@ + + + \ No newline at end of file