feat: add hooks useTitle for set title

This commit is contained in:
HasanMu 2025-02-13 09:29:01 +07:00
parent fe41e1e45a
commit 8a2a93a288
8 changed files with 27 additions and 0 deletions

7
src/hooks/useTitle.ts Normal file
View File

@ -0,0 +1,7 @@
import React from "react";
export default function useTitle(title: string) {
React.useEffect(() => {
document.title = `NAM | ${title}`
}, [title])
}

View File

@ -12,6 +12,7 @@ import ReactTable from "../components/ReactTable";
import IconButton from "../components/IconButton"; import IconButton from "../components/IconButton";
import { Edit } from "iconsax-react"; import { Edit } from "iconsax-react";
import { ColumnDef } from "@tanstack/react-table"; import { ColumnDef } from "@tanstack/react-table";
import useTitle from "../hooks/useTitle";
interface UserData { interface UserData {
backbone: string; backbone: string;
@ -22,6 +23,8 @@ interface UserData {
} }
export default function Backbone() { export default function Backbone() {
useTitle("Backbone");
const data: UserData[] = [ const data: UserData[] = [
{ backbone: "BB-BDG-SMD", device_start: "DV-CODE-1", device_end: "DV-CODE-2", total_core: "24 Core", total_fishbone: "3" }, { backbone: "BB-BDG-SMD", device_start: "DV-CODE-1", device_end: "DV-CODE-2", total_core: "24 Core", total_fishbone: "3" },
{ backbone: "BB-BDG-SBG", device_start: "DV-CODE-3", device_end: "DV-CODE-4", total_core: "24 Core", total_fishbone: "5" }, { backbone: "BB-BDG-SBG", device_start: "DV-CODE-3", device_end: "DV-CODE-4", total_core: "24 Core", total_fishbone: "5" },

View File

@ -1,4 +1,8 @@
import useTitle from "../hooks/useTitle";
export default function Dashboard() { export default function Dashboard() {
useTitle("Dashboard");
return ( return (
<div> <div>
Dashboard Dashboard

View File

@ -12,6 +12,7 @@ import ReactTable from "../components/ReactTable";
import { ColumnDef } from "@tanstack/react-table"; import { ColumnDef } from "@tanstack/react-table";
import IconButton from "../components/IconButton"; import IconButton from "../components/IconButton";
import { Edit } from "iconsax-react"; import { Edit } from "iconsax-react";
import useTitle from "../hooks/useTitle";
interface UserData { interface UserData {
device_code: string; device_code: string;
@ -22,6 +23,8 @@ interface UserData {
} }
export default function Devices() { export default function Devices() {
useTitle("Devices");
const data: UserData[] = [ const data: UserData[] = [
{ device_code: 'DV-CODE-1', device_type: "OTB", address: "Jl. Contoh 1", port_amount: '16', status: "Active" }, { device_code: 'DV-CODE-1', device_type: "OTB", address: "Jl. Contoh 1", port_amount: '16', status: "Active" },
{ device_code: 'DV-CODE-2', device_type: "OTB", address: "Jl. Contoh 2", port_amount: '16', status: "Active" }, { device_code: 'DV-CODE-2', device_type: "OTB", address: "Jl. Contoh 2", port_amount: '16', status: "Active" },

View File

@ -12,6 +12,7 @@ import ReactTable from "../components/ReactTable";
import { ColumnDef } from "@tanstack/react-table"; import { ColumnDef } from "@tanstack/react-table";
import IconButton from "../components/IconButton"; import IconButton from "../components/IconButton";
import { Edit } from "iconsax-react"; import { Edit } from "iconsax-react";
import useTitle from "../hooks/useTitle";
interface UserData { interface UserData {
backbone: string; backbone: string;
@ -21,6 +22,8 @@ interface UserData {
} }
export default function Fishbone() { export default function Fishbone() {
useTitle("Fishbone");
const data: UserData[] = [ const data: UserData[] = [
{ backbone: 'BB-BDG-SMD', device_start: "DV-CODE-1", device_end: "DV-CODE-2", total_core: '24 Core', }, { backbone: 'BB-BDG-SMD', device_start: "DV-CODE-1", device_end: "DV-CODE-2", total_core: '24 Core', },
{ backbone: 'BB-BDG-SBG', device_start: "DV-CODE-3", device_end: "DV-CODE-4", total_core: '24 Core', }, { backbone: 'BB-BDG-SBG', device_start: "DV-CODE-3", device_end: "DV-CODE-4", total_core: '24 Core', },

View File

@ -12,6 +12,7 @@ import ReactTable from "../components/ReactTable";
import { ColumnDef } from "@tanstack/react-table"; import { ColumnDef } from "@tanstack/react-table";
import IconButton from "../components/IconButton"; import IconButton from "../components/IconButton";
import { Edit } from "iconsax-react"; import { Edit } from "iconsax-react";
import useTitle from "../hooks/useTitle";
interface UserData { interface UserData {
tower_code: string; tower_code: string;
@ -20,6 +21,8 @@ interface UserData {
} }
export default function Towers() { export default function Towers() {
useTitle("Towers");
const data: UserData[] = [ const data: UserData[] = [
{ tower_code: 'TW-CODE-1', device: "DV-CODE-1", address: "Jl. Contoh 1" }, { tower_code: 'TW-CODE-1', device: "DV-CODE-1", address: "Jl. Contoh 1" },
{ tower_code: 'TW-CODE-2', device: "DV-CODE-2", address: "Jl. Contoh 2" }, { tower_code: 'TW-CODE-2', device: "DV-CODE-2", address: "Jl. Contoh 2" },

View File

@ -8,8 +8,11 @@ import Typography from "@mui/material/Typography";
import Grid from "@mui/material/Grid2"; import Grid from "@mui/material/Grid2";
import { useNavigate } from "react-router"; import { useNavigate } from "react-router";
import { useAuthStore } from "../../stores/authStore"; import { useAuthStore } from "../../stores/authStore";
import useTitle from "../../hooks/useTitle";
export default function Login() { export default function Login() {
useTitle("Login");
let navigate = useNavigate(); let navigate = useNavigate();
const { login, token, isLoading, error } = useAuthStore(); const { login, token, isLoading, error } = useAuthStore();

View File

@ -1,3 +1,4 @@
import CryptoJS from "crypto-js";
import { StateStorage } from "zustand/middleware"; import { StateStorage } from "zustand/middleware";
const KEY = import.meta.env.VITE_APP_KEY; const KEY = import.meta.env.VITE_APP_KEY;