diff --git a/src/app/(admin)/(others-pages)/profile/applications/page.tsx b/src/app/(admin)/(others-pages)/profile/applications/page.tsx new file mode 100644 index 0000000..7d3fc6b --- /dev/null +++ b/src/app/(admin)/(others-pages)/profile/applications/page.tsx @@ -0,0 +1,38 @@ +"use client"; +import { useSelector } from "react-redux"; +import { RootState } from "@/store/store"; +import { SafeHTMLRenderer } from "@/components/ui/parse/SafeHTMLRenderer"; + +export default function ApplicationDetailPage() { + const application = useSelector((state: RootState) => state.user.selectedApplication); + + if (!application) { + return
{application.verify_type}
+ bọc ngoài nếu API trả về dư thừa
+ decoded = decoded.replace(/]*>/g, "").replace(/<\/pre>/g, "");
+
+ // 3. Khởi tạo Shadow DOM (nếu chưa có)
+ const shadowRoot = containerRef.current.shadowRoot || containerRef.current.attachShadow({ mode: "open" });
+
+ // 4. Render nội dung vào trong vùng cô lập
+ shadowRoot.innerHTML = decoded;
+ }
+ }, [html]);
+
+ return ;
+}
\ No newline at end of file
diff --git a/src/components/user-profile/ApplicationList.tsx b/src/components/user-profile/ApplicationList.tsx
new file mode 100644
index 0000000..bd414f5
--- /dev/null
+++ b/src/components/user-profile/ApplicationList.tsx
@@ -0,0 +1,32 @@
+"use client";
+
+import { setSelectedApplication } from "@/store/features/userSlice";
+import { useRouter } from "next/navigation";
+import { useDispatch } from "react-redux";
+
+export default function ApplicationList({ applications }: { applications: any[] }) {
+ const router = useRouter();
+ const dispatch = useDispatch();
+
+ const handleViewDetail = (app: any) => {
+ dispatch(setSelectedApplication(app));
+ router.push(`/profile/applications`);
+};
+
+ return (
+
+ {applications.map((app) => (
+ handleViewDetail(app)}
+ className="p-4 border rounded-lg cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition"
+ >
+
+ Loại: {app.verify_type}
+ Xem chi tiết →
+
+
+ ))}
+
+ );
+}
\ No newline at end of file
diff --git a/src/store/features/userSlice.ts b/src/store/features/userSlice.ts
index df0381a..d966dfe 100644
--- a/src/store/features/userSlice.ts
+++ b/src/store/features/userSlice.ts
@@ -1,13 +1,25 @@
import { UserData } from '@/interface/user';
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
+// Hàm helper để đọc dữ liệu an toàn từ storage
+const getStoredApplication = () => {
+ if (typeof window !== "undefined") {
+ const saved = sessionStorage.getItem('selected_application');
+ return saved ? JSON.parse(saved) : null;
+ }
+ return null;
+};
+
interface UserState {
data: UserData | null;
isAuthenticated: boolean;
+ selectedApplication: any | null;
}
+
const initialState: UserState = {
data: null,
isAuthenticated: false,
+ selectedApplication: getStoredApplication(), // Khởi tạo từ storage
};
const userSlice = createSlice({
@@ -18,12 +30,21 @@ const userSlice = createSlice({
state.data = action.payload;
state.isAuthenticated = true;
},
- clearUserData: (state) => {
- state.data = null;
- state.isAuthenticated = false;
+ setSelectedApplication: (state, action: PayloadAction) => {
+ state.selectedApplication = action.payload;
+ // Lưu vào sessionStorage để khi reload trang không bị mất
+ if (typeof window !== "undefined") {
+ sessionStorage.setItem('selected_application', JSON.stringify(action.payload));
+ }
+ },
+ clearSelectedApplication: (state) => {
+ state.selectedApplication = null;
+ if (typeof window !== "undefined") {
+ sessionStorage.removeItem('selected_application');
+ }
},
},
});
-export const { setUserData, clearUserData } = userSlice.actions;
+export const { setUserData, setSelectedApplication, clearSelectedApplication } = userSlice.actions;
export default userSlice.reducer;
\ No newline at end of file