Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #68 from nexlabsweb3/fix_import
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
zintarh authored Nov 27, 2024
2 parents 60d12bc + c87ce1a commit 8b29560
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 50 deletions.
37 changes: 15 additions & 22 deletions frontend/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,20 @@ const NavBar = (props: any) => {
xl:px-0 2xl:px-0 py-4 mb-12 container mx-auto font-roboto
bg-[#1e1e1e]/80 backdrop-blur-sm sticky top-0 z-10
lg:static lg:bg-none`}
{...props}
>
<div className="flex items-center gap-14">
<Link href="/">
<div className="hidden md:block">
<BrandImage />
</div>
<div className="md:hidden">
<p
onClick={() => showAlert('success', 'You clicked the scanGuard logo', 'ScanGaurd Alert')}
className="text-textPrimary text-lg font-normal font-bowlby">
ScanGuard
</p>
</div>
</Link>
<NavLinks />
</div>
<div>
<ConnectWallet />
</div>
</nav>
{...props}
>
<div className="flex items-center gap-14">
<Link href="/">
<div className="hidden md:block">
<BrandImage />
</div>
</Link>
<NavLinks />
</div>
<div>
<ConnectWallet />
</div>
</nav>
);
};

Expand All @@ -43,7 +36,7 @@ const NavLinks = () => (
className={`${roboto.variable} text-sm text-textPrimary leading-normal
font-roboto uppercase hidden py-3 gap-6 items-center lg:flex`}
>
{['home', 'anout', 'contact'].map((item, index, array) => (
{['home', 'contact', 'manufacturer'].map((item, index, array) => (
<li
key={item}
className={`${index !== array.length - 1 ? 'border-r-2 border-primary/[.12] pr-6' : ''}
Expand Down
64 changes: 36 additions & 28 deletions frontend/src/hooks/useAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useState, useCallback, createContext, useContext, } from 'react';
import { useState, useCallback, createContext, useContext } from 'react';

/**
* Alert types supported by the useAlert hook
Expand All @@ -21,7 +21,12 @@ interface AlertState {

interface AlertContextType {
alert: AlertState;
showAlert: (type: AlertType, message: string, title?: string, duration?: number) => void;
showAlert: (
type: AlertType,
message: string,
title?: string,
duration?: number
) => void;
}

const AlertContext = createContext<AlertContextType | undefined>(undefined);
Expand All @@ -34,7 +39,12 @@ export function AlertProvider({ children }: { children: React.ReactNode }) {
});

const showAlert = useCallback(
(type: AlertType, message: string, title?: string, duration: number = 5000) => {
(
type: AlertType,
message: string,
title?: string,
duration: number = 5000
) => {
setAlert({
type,
title,
Expand All @@ -56,39 +66,37 @@ export function AlertProvider({ children }: { children: React.ReactNode }) {
);
}


/**
* Custom hook for managing alert notifications in React applications.
*
* @returns {AlertContextType}
*
* @example
* // Basic usage
* function MyComponent() {
* const { alert, showAlert } = useAlert();
*
* return (
* <>
* <Alert {...alert} />
* <button onClick={() => showAlert('success', 'It worked!', 10000)}>
* Show Success
* </button>
* </>
* );
* }
*
* @example
* // All alert types
* showAlert('success', 'Operation completed successfully', 10000);
* showAlert('error', 'An error occurred', 10000);
* showAlert('warning', 'Please be careful', 10000);
* showAlert('info', 'Just so you know...');
*/
*
* @example
* // Basic usage
* function MyComponent() {
* const { alert, showAlert } = useAlert();
*
* return (
* <>
* <Alert {...alert} />
* <button onClick={() => showAlert('success', 'It worked!', 10000)}>
* Show Success
* </button>
* </>
* );
* }
*
* @example
* // All alert types
* showAlert('success', 'Operation completed successfully', 10000);
* showAlert('error', 'An error occurred', 10000);
* showAlert('warning', 'Please be careful', 10000);
* showAlert('info', 'Just so you know...');
*/
export function useAlert() {
const context = useContext(AlertContext);
if (context === undefined) {
throw new Error('useAlert must be used within an AlertProvider');
}
return context;
}

0 comments on commit 8b29560

Please sign in to comment.