Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unnecessary type assertions #148

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading