Skip to content

Commit

Permalink
Minor improvements.
Browse files Browse the repository at this point in the history
Signed-off-by: Aliwoto <[email protected]>
  • Loading branch information
ALiwoto committed Aug 18, 2024
1 parent aaabf88 commit 0ff6671
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
12 changes: 11 additions & 1 deletion src/components/menus/sideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,23 @@ const SideMenu: React.FC<SideMenuProps> = ({...props}) => {
href='/createUser'
>
</MenuItem>
<MenuItem
label={CurrentAppTranslation.SearchUsersText}
href='/searchUser'
>
</MenuItem>
<MenuItem
label={CurrentAppTranslation.EditUserInfoText}
href='/searchUser'
href='/searchUser?edit=true'
>
</MenuItem>
<MenuItem label={CurrentAppTranslation.ChangeUserPasswordText}></MenuItem>
</MenuItem>
<MenuItem label={CurrentAppTranslation.ManageCoursesText}>
<MenuItem label={CurrentAppTranslation.AddCourseText}></MenuItem>
<MenuItem label={CurrentAppTranslation.SearchCoursesText}></MenuItem>
<MenuItem label={CurrentAppTranslation.EditCourseText}></MenuItem>
</MenuItem>
<MenuItem label={CurrentAppTranslation.ManageExamsText}>
<MenuItem label={CurrentAppTranslation.AddExamText}></MenuItem>
<MenuItem label={CurrentAppTranslation.EditExamText}></MenuItem>
Expand Down
28 changes: 17 additions & 11 deletions src/pages/searchUserPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import DashboardContainer from '../components/containers/dashboardContainer';
import { timeAgo } from '../utils/timeUtils';
import { CurrentAppTranslation } from '../translations/appTranslation';

const RenderUsersList = (users: SearchedUserInfo[] | undefined) => {
const RenderUsersList = (users: SearchedUserInfo[] | undefined, forEdit: boolean = false) => {
if (!users || users.length === 0) {
return (
<Typography variant="body2" sx={{ textAlign: 'center', mt: 4 }}>
{CurrentAppTranslation.NoResultsFoundText}
{forEdit ? CurrentAppTranslation.EnterSearchForEdit :
CurrentAppTranslation.NoResultsFoundText}
</Typography>
);
}
Expand All @@ -42,12 +43,20 @@ const RenderUsersList = (users: SearchedUserInfo[] | undefined) => {
}>
<Grid container spacing={2}>
<Grid item xs={6}>
<Typography variant="body2">{`${CurrentAppTranslation.user_id}: ${user.user_id}`}</Typography>
<Typography variant="body2">{`${CurrentAppTranslation.email}: ${user.email}`}</Typography>
<Typography variant="body2">
{`${CurrentAppTranslation.user_id}: ${user.user_id}`}
</Typography>
<Typography variant="body2">
{`${CurrentAppTranslation.email}: ${user.email}`}
</Typography>
</Grid>
<Grid item xs={6} sx={{ textAlign: 'right' }}>
<Typography variant="body2">{`${CurrentAppTranslation.full_name}: ${user.full_name}`}</Typography>
<Typography variant="body2">{`${CurrentAppTranslation.created_at}: ${timeAgo(user.created_at!)}`}</Typography>
<Typography variant="body2">
{`${CurrentAppTranslation.full_name}: ${user.full_name}`}
</Typography>
<Typography variant="body2">
{`${CurrentAppTranslation.created_at}: ${timeAgo(user.created_at!)}`}
</Typography>
</Grid>
</Grid>
</Paper>
Expand All @@ -61,6 +70,7 @@ const SearchUserPage = () => {
const urlSearch = new URLSearchParams(window.location.search);
const providedQuery = urlSearch.get('query');
const providedPage = urlSearch.get('page');
const forEdit = (urlSearch.get('edit') ?? "false") === "true";

const [query, setQuery] = useState(providedQuery ?? '');
const [users, setUsers] = useState<SearchedUserInfo[]>([]);
Expand Down Expand Up @@ -147,11 +157,7 @@ const SearchUserPage = () => {
}}>
<CircularProgress size={60} />
</Box>
) : (
<List>
{RenderUsersList(users)}
</List>
)}
) : RenderUsersList(users, forEdit)}
</Box>
<Box sx={{ display: 'flex', justifyContent: 'center', margin: '0 auto', }}>
<Pagination
Expand Down
8 changes: 7 additions & 1 deletion src/translations/appTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ export class AppTranslationBase {
ChangePasswordText: string = "Change Password";
ManageUsersText: string = "Manage Users";
AddUserText: string = "Add User";
SearchUsersText: string = "Search Users";
EditUserInfoText: string = "Edit User Info";
ChangeUserPasswordText: string = "Change User Password";
ManageCoursesText: string = "Manage Courses";
AddCourseText: string = "Add Course";
SearchCoursesText: string = "Search Courses";
EditCourseText: string = "Edit Course";
ManageExamsText: string = "Manage Exams";
AddExamText: string = "Add Exam";
EditExamText: string = "Edit Exam";
Expand All @@ -27,7 +32,8 @@ export class AppTranslationBase {
UserNotFoundText: string = "This user doesn't seem to exist...";
CreateNewUserText: string = "Create New User";
UserCreatedSuccessfullyText: string = "User created successfully";
NoResultsFoundText: string = "No results found";
NoResultsFoundText: string = "No results found, try changing your search query";
EnterSearchForEdit: string = "Enter search query to edit the user";

//#endregion

Expand Down
7 changes: 6 additions & 1 deletion src/translations/faTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class FaTranslation extends AppTranslationBase {
AddUserText: string = "افزودن کاربر";
EditUserInfoText: string = "ویرایش اطلاعات کاربر";
ChangeUserPasswordText: string = "تغییر رمز عبور کاربر";
ManageCoursesText: string = "مدیریت دوره ها";
AddCourseText: string = "افزودن دوره";
SearchCoursesText: string = "جستجوی دوره ها";
EditCourseText: string = "ویرایش دوره";
ManageExamsText: string = "مدیریت آزمون ها";
AddExamText: string = "افزودن آزمون";
EditExamText: string = "ویرایش آزمون";
Expand All @@ -29,7 +33,8 @@ class FaTranslation extends AppTranslationBase {
UserNotFoundText: string = "این کاربر وجود ندارد...";
CreateNewUserText: string = "ایجاد کاربر جدید";
UserCreatedSuccessfullyText: string = "کاربر با موفقیت ایجاد شد";
NoResultsFoundText: string = "نتیجه ای یافت نشد";
NoResultsFoundText: string = "نتیجه ای یافت نشد، تلاش کنید تا جستجوی خود را تغییر دهید";
EnterSearchForEdit: string = "برای ویرایش کاربر جستجو کنید";

//#endregion

Expand Down

0 comments on commit 0ff6671

Please sign in to comment.