diff --git a/src/services/newsletter.service.ts b/src/services/newsletter.service.ts index 36f49da2f3ff535266f0ec60d7f326b3065daff9..7a27ccca1665cc7fe6e2ddcf29df11ea89f3b18c 100644 --- a/src/services/newsletter.service.ts +++ b/src/services/newsletter.service.ts @@ -31,8 +31,14 @@ export class NewsletterService { } ) toast.success('Monthly info succesfully saved !') - } catch (e) { - toast.error('Failed to create monthly info') + } catch (e: any) { + if (e.response.status === 403) { + toast.error( + "Unauthorized : You don't have the rights to do this operation" + ) + } else { + toast.error('Failed to create monthly info') + } console.error(e) } } @@ -56,7 +62,7 @@ export class NewsletterService { } ) return data as IMonthlyInfo - } catch (e) { + } catch (e: any) { console.error('error', e) return null } @@ -81,8 +87,14 @@ export class NewsletterService { } ) toast.success('Monthly info succesfully deleted !') - } catch (e) { - toast.error('Failed to delete monthly info') + } catch (e: any) { + if (e.response.status === 403) { + toast.error( + "Unauthorized : You don't have the rights to do this operation" + ) + } else { + toast.error('Failed to delete monthly info') + } console.error(e) } } @@ -115,8 +127,14 @@ export class NewsletterService { } ) toast.success('Monthly news succesfully saved !') - } catch (e) { - toast.error('Failed to create monthly news') + } catch (e: any) { + if (e.response.status === 403) { + toast.error( + "Unauthorized : You don't have the rights to do this operation" + ) + } else { + toast.error('Failed to save monthly news') + } console.error(e) } } @@ -165,8 +183,14 @@ export class NewsletterService { } ) toast.success('Monthly news succesfully deleted !') - } catch (e) { - toast.error('Failed to delete monthly news') + } catch (e: any) { + if (e.response.status === 403) { + toast.error( + "Unauthorized : You don't have the rights to do this operation" + ) + } else { + toast.error('Failed to delete monthly news') + } console.error(e) } } @@ -199,8 +223,14 @@ export class NewsletterService { } ) toast.success('Poll successfully saved !') - } catch (e) { - toast.error('Failed to create poll') + } catch (e: any) { + if (e.response.status === 403) { + toast.error( + "Unauthorized : You don't have the rights to do this operation" + ) + } else { + toast.error('Failed to create poll') + } console.error(e) } } @@ -246,8 +276,14 @@ export class NewsletterService { } ) toast.success('Poll succesfully deleted !') - } catch (e) { - toast.error('Failed to delete poll') + } catch (e: any) { + if (e.response.status === 403) { + toast.error( + "Unauthorized : You don't have the rights to do this operation" + ) + } else { + toast.error('Failed to delete poll') + } console.error(e) } }