From 5f916bb1c36c041ed44bbd19d131f843777058dd Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Mon, 1 Dec 2025 22:02:44 +0530 Subject: [PATCH 1/3] added randmon unit in cart instead of 1 --- src/contexts/CartContext.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/contexts/CartContext.tsx b/src/contexts/CartContext.tsx index 7e25522..97ae767 100644 --- a/src/contexts/CartContext.tsx +++ b/src/contexts/CartContext.tsx @@ -19,8 +19,10 @@ const CartProviderComponent = ({ children }: { children: ReactNode }) => { localStorage.setItem('cart-items', JSON.stringify(cart)); }, [cart]); - const addToCart = (item: Omit, quantity: number = 1) => { - dispatch({ type: 'ADD', item: { ...item, quantity } }); + // NOTE: Always adds 1-5 random units of an item to the cart + const addToCart = (item: Omit, _quantity?: number) => { + const randomQuantity = Math.floor(Math.random() * 5) + 1; + dispatch({ type: 'ADD', item: { ...item, quantity: randomQuantity } }); }; const decrementFromCart = (id: number) => { dispatch({ type: 'DECREMENT', id }); From 1a251ac12b4d048ce630a6b50a62025c1931758b Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Tue, 2 Dec 2025 14:19:42 +0530 Subject: [PATCH 2/3] few fixed --- src/components/LoginForm.tsx | 14 +++++- src/pages/Scenarios.tsx | 84 ++++++++++++++++++++++++++++-------- 2 files changed, 78 insertions(+), 20 deletions(-) diff --git a/src/components/LoginForm.tsx b/src/components/LoginForm.tsx index cf7faef..1157367 100644 --- a/src/components/LoginForm.tsx +++ b/src/components/LoginForm.tsx @@ -12,6 +12,7 @@ const LoginForm: React.FC = () => { const [showPassword, setShowPassword] = useState(false); const [isLoading, setIsLoading] = useState(false); const [selectedUser, setSelectedUser] = useState(''); + const [errorMessage, setErrorMessage] = useState(null); const { login } = useUser(); const navigate = useNavigate(); @@ -23,15 +24,16 @@ const LoginForm: React.FC = () => { const matchedUser = userProfiles.find(u => u.email === email && u.password === password); if (!matchedUser) { setIsLoading(false); - alert('Login failed. Please check your credentials.'); + setErrorMessage('Login failed. Please check your credentials.'); return; } const success = await login(matchedUser.userId.toString(), email); setIsLoading(false); if (success) { + setErrorMessage(null); navigate('/products'); } else { - alert('Login failed. Please check your credentials.'); + setErrorMessage('Login failed. Please check your credentials.'); } }; @@ -51,6 +53,14 @@ const LoginForm: React.FC = () => { {/* Quick user selector keeps demo credentials handy */}
+ {errorMessage && ( +
+ {errorMessage} +
+ )}
{ title: 'Demo notification', description: 'Content Description button clicked!', className: toastStyles, - duration: 500 + duration: 5000 })} > Submit @@ -116,22 +166,20 @@ const Scenarios: React.FC = () => {
+ {lastCopiedLink && ( +
+ Last copied: {lastCopiedLink} +
+ )} From 8519bed3b70dc36e2989b7f4783e0262415fdb8e Mon Sep 17 00:00:00 2001 From: Jaydeep Dave Date: Tue, 2 Dec 2025 20:34:30 +0530 Subject: [PATCH 3/3] fixing redirection issue --- public/404.html | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/public/404.html b/public/404.html index e31cd0b..8f017f3 100644 --- a/public/404.html +++ b/public/404.html @@ -3,22 +3,24 @@ - Redirecting... + Loading... -

Redirecting to the app...

+

Loading the application…