From acc958a3553f3d40873c25b5feac888abb4de74a Mon Sep 17 00:00:00 2001 From: Suraj Ramchandran <30753067+Suraj-Ram@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:54:43 -0500 Subject: [PATCH] Added temporary handling for local storage exception --- .../components/Plan/DuplicatePlanButton.tsx | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/frontend/components/Plan/DuplicatePlanButton.tsx b/packages/frontend/components/Plan/DuplicatePlanButton.tsx index a73c0dd6b..72838edb5 100644 --- a/packages/frontend/components/Plan/DuplicatePlanButton.tsx +++ b/packages/frontend/components/Plan/DuplicatePlanButton.tsx @@ -55,14 +55,19 @@ export const DuplicatePlanButton: React.FC = ({ updatedAt: new Date(), } as PlanModel; - // TODO handle QuotaExceededError exception - window.localStorage.setItem( - "student", - JSON.stringify({ - ...student, - plans: [...student.plans, planLocalStorage], - }) - ); + // TODO handle QuotaExceededError exception better + try { + window.localStorage.setItem( + "student", + JSON.stringify({ + ...student, + plans: [...student.plans, planLocalStorage], + }) + ); + } catch (error) { + toast.error("Maximum local storage quota exceed. Too many plans."); + return; + } } else { try { const createdPlan = await API.plans.create(updatedPlan);