From a72fb6b12c1513f37582c9eb02270e353e1b4c14 Mon Sep 17 00:00:00 2001 From: wrzesinski-hubert Date: Mon, 25 Jan 2021 17:34:52 +0100 Subject: [PATCH] transfer fix --- src/components/Administrator.tsx | 5 +++-- src/components/Dropdown.tsx | 5 +++-- src/components/Rightbar.tsx | 5 +++-- src/components/Topbar.tsx | 2 +- src/components/Transfer.tsx | 6 ++++-- src/contexts/CoursesProvider.tsx | 5 +++++ 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/Administrator.tsx b/src/components/Administrator.tsx index 5404707..008888b 100644 --- a/src/components/Administrator.tsx +++ b/src/components/Administrator.tsx @@ -58,12 +58,12 @@ const Wrap = styled.div` flex: 1; flex-direction: column; justify-content: center; - align-items: center; + align-items: center; + margin:20px; `; const LogoWrapper = styled.div` display: flex; - flex: 1; flex-direction: column; justify-content: center; align-items: center; @@ -74,6 +74,7 @@ const Text = styled.div` font-family: 'Roboto', sans-serif; font-size: 5rem; user-select: none; + margin-bottom:60px; `; const Logo = styled.img` diff --git a/src/components/Dropdown.tsx b/src/components/Dropdown.tsx index 8bdefb8..1db2ad6 100644 --- a/src/components/Dropdown.tsx +++ b/src/components/Dropdown.tsx @@ -120,9 +120,10 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D <> {selectedOption === 'studenci' ? (
- {filteredStudents.map(({ surname, name, id }, index) => ( + {filteredStudents.map(({ surname, name, email, id }, index) => ( -

{name} {surname}

+ {name=== ''?

{email}

:

{name} {surname}

} +
))}
diff --git a/src/components/Rightbar.tsx b/src/components/Rightbar.tsx index 518eb1a..1f1588f 100644 --- a/src/components/Rightbar.tsx +++ b/src/components/Rightbar.tsx @@ -3,6 +3,7 @@ import { CourseCard } from './CourseCard'; import { coursesContext } from '../contexts/CoursesProvider'; import styled from 'styled-components'; import { debounce } from '../utils/index'; +import { SyncLoader } from 'react-spinners'; const RightbarWrapper = styled.div` padding: 15px; @@ -46,13 +47,13 @@ const SaveButton = styled.div` `; export const Rightbar = () => { - const { selectBasketCourses, saveBasket, userID } = useContext(coursesContext)!; + const { selectBasketCourses, saveBasket, userID, isSavingLoading } = useContext(coursesContext)!; const basketCourses = selectBasketCourses(); const handleSave = debounce(() => saveBasket(userID), 500); return ( - ZAPISZ + {isSavingLoading ? : "ZAPISZ"} {basketCourses.map((course) => ( ))} diff --git a/src/components/Topbar.tsx b/src/components/Topbar.tsx index 27d24f6..6337fc9 100644 --- a/src/components/Topbar.tsx +++ b/src/components/Topbar.tsx @@ -214,7 +214,7 @@ export default function ({ handleTransfer }: TopbarProps) { - {selectedStudent?.surname} + {selectedStudent?.surname === '' ? selectedStudent?.email.replace(/@st.amu.edu.pl/, '') : selectedStudent?.surname} {/* Maciej GÅ‚owacki */} {userPrivilige === 'STUDENT' && ( diff --git a/src/components/Transfer.tsx b/src/components/Transfer.tsx index eeca9ad..c7a5bcd 100644 --- a/src/components/Transfer.tsx +++ b/src/components/Transfer.tsx @@ -39,7 +39,6 @@ const TransferStyled = styled.div` background: white; margin: 0 auto; border-radius: 5px; - letter-spacing: 0.1ch; `; const BinIcon = styled(DeleteIcon)` @@ -166,17 +165,20 @@ const Exchange = styled.div` align-items: center; justify-content: center; padding: 0.5rem; - line-height: 0; + line-height:2; `; const ExchangeTitle = styled.p` font-size: 16px; font-weight: bold; + + margin:0; `; const ExchangeParagraph = styled.p` font-size: 13px; color: #1a1a1a; + margin:0; `; export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => { diff --git a/src/contexts/CoursesProvider.tsx b/src/contexts/CoursesProvider.tsx index 820d9e2..264b64a 100644 --- a/src/contexts/CoursesProvider.tsx +++ b/src/contexts/CoursesProvider.tsx @@ -22,6 +22,7 @@ interface CourseContext { isDataLoading: boolean; historyBasket: Array; tour: string; + isSavingLoading: boolean; getCurrentTour: () => void; addCourseToBasket: (courses: Course) => void; changeHoveredGroup: (group: Group | null) => void; @@ -60,6 +61,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => { const [hoveredGroup, setHoveredGroup] = useState(null); const [isDataLoading, setIsDataLoading] = useState(false); const [tour, setTour] = useState(''); + const [isSavingLoading, setIsSavingLoading] = useState(false); const selectBasketIds = () => { const classesIds = basket.map((course) => course?.classes?.id).filter((course) => course !== undefined); @@ -143,6 +145,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => { }; const saveBasket = async (userID: string) => { + setIsSavingLoading(true); const basketIds = selectBasketIds(); const action = (key: any) => ( <> @@ -171,6 +174,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => { }); } getStudentTimetablesHistory(userID); + setIsSavingLoading(false); }; const changeGroupInBasket = (choosenGroup: any, courseId: number) => { @@ -308,6 +312,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => { isDataLoading, historyBasket, tour, + isSavingLoading, getCurrentTour, addCourseToBasket, changeHoveredGroup,