Skip to content

Commit

Permalink
remove type assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
y-hsgw committed Mar 3, 2024
1 parent c2a42cb commit 918efad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
22 changes: 13 additions & 9 deletions src/components/Layout/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ type SideNavigationItem = {

const SideNavigation = () => {
const { checkAccess } = useAuthorization();
const navigation = [
const navigation: SideNavigationItem[] = [
{ name: 'Dashboard', to: '.', icon: HomeIcon },
{ name: 'Discussions', to: './discussions', icon: FolderIcon },
checkAccess({ allowedRoles: [ROLES.ADMIN] }) && {
name: 'Users',
to: './users',
icon: UsersIcon,
},
].filter(Boolean) as SideNavigationItem[];
...(checkAccess({ allowedRoles: [ROLES.ADMIN] })
? [
{
name: 'Users',
to: './users',
icon: UsersIcon,
},
]
: []),
];

return (
<>
Expand Down Expand Up @@ -69,7 +73,7 @@ type UserNavigationItem = {
const UserNavigation = () => {
const { logout } = useAuth();

const userNavigation = [
const userNavigation: UserNavigationItem[] = [
{ name: 'Your Profile', to: './profile' },
{
name: 'Sign out',
Expand All @@ -78,7 +82,7 @@ const UserNavigation = () => {
logout();
},
},
].filter(Boolean) as UserNavigationItem[];
];

return (
<Menu as="div" className="ml-3 relative">
Expand Down
4 changes: 2 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const API_URL = process.env.REACT_APP_API_URL as string;
export const JWT_SECRET = '123456' as string;
export const API_URL = process.env.REACT_APP_API_URL;
export const JWT_SECRET = '123456';
2 changes: 1 addition & 1 deletion src/lib/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function registerFn(data: RegisterCredentialsDTO) {

async function logoutFn() {
storage.clearToken();
window.location.assign(window.location.origin as unknown as string);
window.location.assign(window.location.origin);
}

const authConfig = {
Expand Down

0 comments on commit 918efad

Please sign in to comment.