forked from Transparency/kgroad-frontend2
		
	made report message
This commit is contained in:
		
							parent
							
								
									c54131197e
								
							
						
					
					
						commit
						a520214eb9
					
				
							
								
								
									
										70
									
								
								src/features/ReportMessage/ReportMessage.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								src/features/ReportMessage/ReportMessage.scss
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | |||||||
|  | .report-message { | ||||||
|  |   padding: 16px; | ||||||
|  |   width: 100%; | ||||||
|  |   height: 100%; | ||||||
|  |   position: fixed; | ||||||
|  |   top: 0; | ||||||
|  |   left: 0; | ||||||
|  |   z-index: 30000; | ||||||
|  |   display: flex; | ||||||
|  |   align-items: center; | ||||||
|  |   justify-content: center; | ||||||
|  |   background-color: rgba(0, 0, 0, 0.6); | ||||||
|  | 
 | ||||||
|  |   &__wrapper { | ||||||
|  |     max-width: 400px; | ||||||
|  |     padding: 24px; | ||||||
|  |     display: flex; | ||||||
|  |     flex-direction: column; | ||||||
|  |     gap: 16px; | ||||||
|  |     background-color: white; | ||||||
|  |     border-radius: 12px; | ||||||
|  |     box-shadow: 0px 8px 8px -4px rgba(16, 24, 40, 0.04), | ||||||
|  |       0px 20px 24px -4px rgba(16, 24, 40, 0.1); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   &__header { | ||||||
|  |     display: flex; | ||||||
|  |     align-items: center; | ||||||
|  |     justify-content: space-between; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   &__text { | ||||||
|  |     margin-bottom: 16px; | ||||||
|  | 
 | ||||||
|  |     h4 { | ||||||
|  |       margin-bottom: 4px; | ||||||
|  |       color: rgb(16, 24, 40); | ||||||
|  |       font-family: Inter; | ||||||
|  |       font-size: 18px; | ||||||
|  |       font-weight: 600; | ||||||
|  |       line-height: 28px; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     p { | ||||||
|  |       color: rgb(71, 84, 103); | ||||||
|  |       font-family: Inter; | ||||||
|  |       font-size: 14px; | ||||||
|  |       font-weight: 400; | ||||||
|  |       line-height: 20px; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   a { | ||||||
|  |     padding: 10px 18px; | ||||||
|  |     display: flex; | ||||||
|  |     align-items: center; | ||||||
|  |     justify-content: center; | ||||||
|  |     text-align: center; | ||||||
|  |     border: 1px solid rgb(72, 159, 225); | ||||||
|  |     border-radius: 8px; | ||||||
|  |     box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05); | ||||||
|  |     background: rgb(72, 159, 225); | ||||||
|  | 
 | ||||||
|  |     color: rgb(255, 255, 255); | ||||||
|  |     font-family: Inter; | ||||||
|  |     font-size: 16px; | ||||||
|  |     font-weight: 600; | ||||||
|  |     line-height: 24px; | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										54
									
								
								src/features/ReportMessage/ReportMessage.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/features/ReportMessage/ReportMessage.tsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,54 @@ | |||||||
|  | import { Link, useRouter } from "@/shared/config/navigation"; | ||||||
|  | import "./ReportMessage.scss"; | ||||||
|  | import Image from "next/image"; | ||||||
|  | import close from "./icons/close.svg"; | ||||||
|  | import check from "./icons/check.svg"; | ||||||
|  | import { useEffect } from "react"; | ||||||
|  | 
 | ||||||
|  | interface IReportMessageProps { | ||||||
|  |   setShowMessage: (value: boolean) => void; | ||||||
|  |   showMessage: boolean; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | const ReportMessage: React.FC<IReportMessageProps> = ({ | ||||||
|  |   setShowMessage, | ||||||
|  |   showMessage, | ||||||
|  | }: IReportMessageProps) => { | ||||||
|  |   const router = useRouter(); | ||||||
|  |   useEffect(() => { | ||||||
|  |     if (showMessage) { | ||||||
|  |       setTimeout(() => { | ||||||
|  |         setShowMessage(false); | ||||||
|  |         router.push("/"); | ||||||
|  |       }, 5000); | ||||||
|  |     } | ||||||
|  |   }, [showMessage]); | ||||||
|  |   return ( | ||||||
|  |     <div | ||||||
|  |       onClick={() => setShowMessage(false)} | ||||||
|  |       className="report-message" | ||||||
|  |     > | ||||||
|  |       <div | ||||||
|  |         onClick={(e) => e.stopPropagation()} | ||||||
|  |         className="report-message__wrapper" | ||||||
|  |       > | ||||||
|  |         <div className="report-message__header"> | ||||||
|  |           <Image src={check} alt="Check Icon" /> | ||||||
|  |           <button onClick={() => setShowMessage(false)} type="button"> | ||||||
|  |             <Image src={close} alt="Close Icon" /> | ||||||
|  |           </button> | ||||||
|  |         </div> | ||||||
|  |         <div className="report-message__text"> | ||||||
|  |           <h4>Ваше обращение отправлено</h4> | ||||||
|  |           <p> | ||||||
|  |             Спасибо за ваше обращение. На данный момент оно в | ||||||
|  |             модерации. | ||||||
|  |           </p> | ||||||
|  |         </div> | ||||||
|  |         <Link href="/profile/my-reports">Смотреть мои обращения</Link> | ||||||
|  |       </div> | ||||||
|  |     </div> | ||||||
|  |   ); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | export default ReportMessage; | ||||||
							
								
								
									
										5
									
								
								src/features/ReportMessage/icons/check.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/features/ReportMessage/icons/check.svg
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | |||||||
|  | <svg width="56" height="56" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||||
|  | <rect x="4" y="4" width="48" height="48" rx="24" fill="#D1FADF"/> | ||||||
|  | <rect x="4" y="4" width="48" height="48" rx="24" stroke="#ECFDF3" stroke-width="8"/> | ||||||
|  | <path d="M23.5 28L26.5 31L32.5 25M38 28C38 33.5228 33.5228 38 28 38C22.4772 38 18 33.5228 18 28C18 22.4772 22.4772 18 28 18C33.5228 18 38 22.4772 38 28Z" stroke="#039855" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||||||
|  | </svg> | ||||||
| After Width: | Height: | Size: 491 B | 
							
								
								
									
										3
									
								
								src/features/ReportMessage/icons/close.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/features/ReportMessage/icons/close.svg
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||||
|  | <path d="M13 1L1 13M1 1L13 13" stroke="#667085" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||||||
|  | </svg> | ||||||
| After Width: | Height: | Size: 217 B | 
| @ -22,6 +22,7 @@ import { useSession } from "next-auth/react"; | |||||||
| import { IDisplayMap } from "@/shared/types/map-type"; | import { IDisplayMap } from "@/shared/types/map-type"; | ||||||
| import Loader from "@/shared/ui/components/Loader/Loader"; | import Loader from "@/shared/ui/components/Loader/Loader"; | ||||||
| import { useRouter } from "@/shared/config/navigation"; | import { useRouter } from "@/shared/config/navigation"; | ||||||
|  | import ReportMessage from "@/features/ReportMessage/ReportMessage"; | ||||||
| 
 | 
 | ||||||
| interface ILatLng { | interface ILatLng { | ||||||
|   lat: number; |   lat: number; | ||||||
| @ -34,6 +35,7 @@ const ReportForm = () => { | |||||||
|   const [latLng, setLatLng] = useState<ILatLng[]>([]); |   const [latLng, setLatLng] = useState<ILatLng[]>([]); | ||||||
|   const [displayLatLng, setDisplayLatLng] = useState<string[]>([]); |   const [displayLatLng, setDisplayLatLng] = useState<string[]>([]); | ||||||
|   const [images, setImages] = useState<File[]>([]); |   const [images, setImages] = useState<File[]>([]); | ||||||
|  |   const [showMessage, setShowMessage] = useState<boolean>(false); | ||||||
|   const position = { |   const position = { | ||||||
|     lat: 42.8746, |     lat: 42.8746, | ||||||
|     lng: 74.606, |     lng: 74.606, | ||||||
| @ -124,7 +126,7 @@ const ReportForm = () => { | |||||||
|       ); |       ); | ||||||
| 
 | 
 | ||||||
|       if ([200, 201].includes(res.status)) { |       if ([200, 201].includes(res.status)) { | ||||||
|         router.push("/"); |         setShowMessage(true); | ||||||
|       } |       } | ||||||
|     } catch (error: unknown) { |     } catch (error: unknown) { | ||||||
|       if (error instanceof AxiosError) { |       if (error instanceof AxiosError) { | ||||||
| @ -294,6 +296,12 @@ const ReportForm = () => { | |||||||
|         )} |         )} | ||||||
|       </button> |       </button> | ||||||
|       {error ? <p className="report-form__error">{error}</p> : null} |       {error ? <p className="report-form__error">{error}</p> : null} | ||||||
|  |       {showMessage ? ( | ||||||
|  |         <ReportMessage | ||||||
|  |           setShowMessage={setShowMessage} | ||||||
|  |           showMessage={showMessage} | ||||||
|  |         /> | ||||||
|  |       ) : null} | ||||||
|     </form> |     </form> | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user