From e63e08dd81cf806796e5d6371b85a7a042ad7cc6 Mon Sep 17 00:00:00 2001 From: Flacial Date: Wed, 24 Aug 2022 04:38:12 +0400 Subject: [PATCH 1/4] fix: Dismissing alert not working --- components/Alert/Alert.tsx | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/components/Alert/Alert.tsx b/components/Alert/Alert.tsx index d20be45d1..96120d2d4 100644 --- a/components/Alert/Alert.tsx +++ b/components/Alert/Alert.tsx @@ -1,9 +1,10 @@ -import React from 'react' +import React, { useState } from 'react' import NavLink from '../NavLink' import { Alert as AlertType } from '../../graphql/' import _ from 'lodash' import styles from './alerts.module.scss' import Image from 'next/image' +import { Alert as AlertBS } from 'react-bootstrap' type Props = { alert: AlertType @@ -21,16 +22,20 @@ const alertIconMap: { [type: string]: string } = { } const Alert: React.FC = ({ alert, onDismiss }) => { + const [show, setShow] = useState(true) + const { text, type, url, urlCaption, id } = alert const icon = alertIconMap[_.defaultTo(type, '-1')] - const alertClasses = - type === 'urgent' ? 'alert alert-danger' : `alert alert-primary` const imageClass = type === 'urgent' ? '' : styles.info_image - return ( -
{ + setShow(false) + onDismiss && onDismiss(id) + }} + dismissible={!!onDismiss} >
@@ -43,21 +48,9 @@ const Alert: React.FC = ({ alert, onDismiss }) => { )}
- {onDismiss && ( - - )} -
+ + ) : ( + <> ) } From d957a9a1426b19de4727d42a3a7d9593f7f0f160 Mon Sep 17 00:00:00 2001 From: Flacial Date: Wed, 24 Aug 2022 04:53:05 +0400 Subject: [PATCH 2/4] test: Update snapshots --- .../__snapshots__/storyshots.test.js.snap | 50 +++++-------- .../pages/__snapshots__/login.test.js.snap | 2 +- .../pages/__snapshots__/signup.test.js.snap | 2 +- .../__snapshots__/[lessonSlug].test.js.snap | 72 +++++++------------ .../__snapshots__/AdminNewAlert.test.js.snap | 36 ++++------ 5 files changed, 56 insertions(+), 106 deletions(-) diff --git a/__tests__/__snapshots__/storyshots.test.js.snap b/__tests__/__snapshots__/storyshots.test.js.snap index f274ffb0e..22339fd96 100644 --- a/__tests__/__snapshots__/storyshots.test.js.snap +++ b/__tests__/__snapshots__/storyshots.test.js.snap @@ -908,7 +908,7 @@ exports[`Storyshots Components/AdminLessonSideNav Basic 1`] = ` exports[`Storyshots Components/Alert Info 1`] = `
+
`; exports[`Storyshots Components/Alert Urgent 1`] = `
+
`; @@ -28050,7 +28036,7 @@ exports[`Storyshots Pages/Login Login Error 1`] = ` className="form-group" >