Skip to content

Commit 568be6f

Browse files
committed
Updated uoi funcs
1 parent 1f6a28b commit 568be6f

File tree

7 files changed

+89
-53
lines changed

7 files changed

+89
-53
lines changed

Services/AuthService.Api/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ await publishEndpoint.Publish(new UserCreatedEvent(
196196
return Results.NotFound("User not found");
197197
}
198198

199+
user.LastName = string.IsNullOrEmpty(userDto.LastName) ? userDto.LastName : user.LastName;
200+
user.FirstName = string.IsNullOrEmpty(userDto.FirstName) ? userDto.FirstName : user.FirstName;
201+
user.MiddleName = string.IsNullOrEmpty(userDto.MiddleName) ? userDto.MiddleName : user.MiddleName;
202+
199203
var result = await userService.UpdateUserAsync(userId, userDto);
200204
if (!result.Succeeded)
201205
{

frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Practices Service</title>
88
</head>
9-
<body>
9+
<body style="background-color: #ffffff">
1010
<div id="root"></div>
1111
<script type="module" src="/src/app/main.tsx"></script>
1212
</body>

frontend/src/app/main.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import ReactDOM from 'react-dom/client'
2-
import '../index.css'
3-
import {RouterProvider} from 'react-router-dom'
4-
import {routes} from "./routes/routes";
1+
import ReactDOM from 'react-dom/client'; // Correct import for React 18
2+
import '../index.css';
3+
import { RouterProvider } from 'react-router-dom';
4+
import { routes } from './routes/routes';
5+
import { ThemeProvider } from '@mui/material/styles';
6+
import { lightTheme } from '@/shared/ui/theme';
7+
import { CssBaseline } from '@mui/material';
58

6-
ReactDOM.createRoot(document.getElementById('root')!).render(
7-
<RouterProvider router={routes}/>,
8-
)
9+
10+
const root = ReactDOM.createRoot(document.getElementById('root')!);
11+
12+
root.render(
13+
<ThemeProvider theme={lightTheme}>
14+
<CssBaseline />
15+
<RouterProvider router={routes} />
16+
</ThemeProvider>
17+
);

frontend/src/pages/Practices/PracticeCard.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ export function PracticeCard({ practice, onClick }: PracticeCardProps) {
1111
<Card
1212
sx={{
1313
cursor: 'pointer',
14+
display: 'flex',
15+
flexDirection: 'column',
16+
justifyContent: 'space-between',
17+
height: '100%',
1418
'&:hover': {
15-
boxShadow: 4
16-
}
19+
boxShadow: 4,
20+
},
1721
}}
1822
onClick={onClick}
1923
>
20-
<CardContent>
24+
<CardContent sx={{ flexGrow: 1 }}>
2125
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
2226
<Typography variant="h6">
2327
{practice.theme?.title || "Без темы"}
@@ -48,4 +52,4 @@ export function PracticeCard({ practice, onClick }: PracticeCardProps) {
4852
</CardContent>
4953
</Card>
5054
);
51-
}
55+
}

frontend/src/pages/Practices/PracticesIndexPage.tsx

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import {Layout} from "@shared/ui/layout/Layout.tsx";
2-
import {getJWTToken} from "@/shared/services/localStorage.service.ts";
3-
import {Navigate, useNavigate} from "react-router-dom";
4-
import {useEffect, useState} from "react";
5-
import {getUserPractices} from "@/shared/services/axios.service.ts";
6-
import {Practice} from "@/entities/Practice.ts";
1+
import { Layout } from "@shared/ui/layout/Layout.tsx";
2+
import { getJWTToken } from "@/shared/services/localStorage.service.ts";
3+
import { Navigate, useNavigate } from "react-router-dom";
4+
import { useEffect, useState } from "react";
5+
import { getUserPractices, getMe } from "@/shared/services/axios.service.ts";
6+
import { Practice } from "@/entities/Practice.ts";
7+
import { User } from "@/entities/User.ts";
78
import {
89
Container,
910
Grid,
@@ -15,16 +16,10 @@ import {
1516
Tab,
1617
Box,
1718
Paper,
18-
Chip,
19-
Divider,
20-
List,
21-
ListItem,
22-
ListItemText,
23-
Link
19+
useMediaQuery,
20+
useTheme,
2421
} from "@mui/material";
25-
import AddIcon from '@mui/icons-material/Add';
26-
import { User } from "@/entities/User.ts";
27-
import { getMe } from "@/shared/services/axios.service.ts";
22+
import AddIcon from "@mui/icons-material/Add";
2823
import { HandbookTab } from "./HandbookTab";
2924
import { PracticeCard } from "./PracticeCard";
3025

@@ -35,12 +30,14 @@ export function PracticesIndexPage() {
3530
const [activeTab, setActiveTab] = useState(1);
3631
const navigate = useNavigate();
3732

33+
const theme = useTheme();
34+
const isMobile = useMediaQuery(theme.breakpoints.down("sm")); // Detect mobile
35+
3836
useEffect(() => {
39-
getMe().then(response => {
37+
getMe().then((response) => {
4038
const data: User = response.data;
4139
setMe(data);
42-
43-
getUserPractices(data.userId).then(response => {
40+
getUserPractices(data.userId).then((response) => {
4441
setPractices(response.data);
4542
});
4643
});
@@ -50,39 +47,54 @@ export function PracticesIndexPage() {
5047
setActiveTab(newValue);
5148
};
5249

53-
const activePractices = practices.filter(practice => practice.status != 'Завершено');
54-
const completedPractices = practices.filter(practice => practice.status == 'Завершено');
50+
const activePractices = practices.filter((p) => p.status !== "Завершено");
51+
const completedPractices = practices.filter((p) => p.status === "Завершено");
5552

56-
return tokenIsEmpty ? <Navigate to="/login" replace/> : (
53+
return tokenIsEmpty ? (
54+
<Navigate to="/login" replace />
55+
) : (
5756
<Layout>
58-
<Container maxWidth="lg" sx={{mt: 4, p: 4}}>
59-
<Typography variant="h4" align="center" gutterBottom>
57+
<Container maxWidth="md" sx={{ mt: 2, p: isMobile ? 1 : 4 }}>
58+
<Typography variant={isMobile ? "h5" : "h4"} align="center" gutterBottom>
6059
Мои практики
6160
</Typography>
6261

63-
<Box sx={{display: 'flex', justifyContent: 'flex-end', mb: 3}}>
62+
<Box
63+
sx={{
64+
display: "flex",
65+
justifyContent: "flex-end",
66+
mb: 2,
67+
}}
68+
>
6469
<Button
6570
variant="contained"
66-
startIcon={<AddIcon/>}
71+
startIcon={<AddIcon />}
6772
onClick={() => navigate("/create/practice")}
73+
size={isMobile ? "small" : "medium"}
6874
>
6975
Создать практику
7076
</Button>
7177
</Box>
7278

73-
<Paper sx={{mb: 3}}>
74-
<Tabs value={activeTab} onChange={handleTabChange} centered>
75-
<Tab label="Справочник"/>
76-
<Tab label="Активные практики"/>
77-
<Tab label="Завершенные практики"/>
79+
<Paper sx={{ mb: 2 }}>
80+
<Tabs
81+
value={activeTab}
82+
onChange={handleTabChange}
83+
variant={isMobile ? "scrollable" : "standard"}
84+
scrollButtons={isMobile ? "auto" : undefined}
85+
centered={!isMobile}
86+
>
87+
<Tab label="Справочник" />
88+
<Tab label="Активные практики" />
89+
<Tab label="Завершенные практики" />
7890
</Tabs>
7991
</Paper>
8092

81-
<Grid container spacing={3}>
93+
<Grid container spacing={isMobile ? 1 : 3}>
8294
{activeTab === 1 ? (
8395
activePractices.length > 0 ? (
84-
activePractices.map((practice, index) => (
85-
<Grid item xs={12} key={index}>
96+
activePractices.map((practice) => (
97+
<Grid item xs={12} sm={6} md={4} key={practice.id}>
8698
<PracticeCard
8799
practice={practice}
88100
onClick={() => navigate(`/practice/${practice.id}`)}
@@ -98,8 +110,8 @@ export function PracticesIndexPage() {
98110
)
99111
) : activeTab === 2 ? (
100112
completedPractices.length > 0 ? (
101-
completedPractices.map((practice, index) => (
102-
<Grid item xs={12} key={index}>
113+
completedPractices.map((practice) => (
114+
<Grid item xs={12} sm={6} md={4} key={practice.id}>
103115
<PracticeCard
104116
practice={practice}
105117
onClick={() => navigate(`/practices/${practice.id}`)}
@@ -115,7 +127,7 @@ export function PracticesIndexPage() {
115127
)
116128
) : (
117129
<Grid item xs={12}>
118-
<HandbookTab/>
130+
<HandbookTab />
119131
</Grid>
120132
)}
121133
</Grid>

frontend/src/pages/ProfilePage.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function ProfilePage() {
5757
const [editedStudent, setEditedStudent] = useState<Partial<Student>>({});
5858
const [editedLecturer, setEditedLecturer] = useState<Partial<Lecturer>>({});
5959
const [editedConsultant, setEditedConsultant] = useState<Partial<Consultant>>({});
60-
const [groups, setGroups] = useState([]);
60+
const [groups, setGroups] = useState<Group[]>([]);
6161

6262
useEffect(() => {
6363
fetchUserData();
@@ -113,18 +113,18 @@ export function ProfilePage() {
113113
try {
114114
// Update user basic info
115115
if (editedUser) {
116-
await updateUser(user?.userId || '', editedUser);
116+
await updateUser(editedUser);
117117
}
118118

119119
// Update role-specific info
120120
if (user?.roles.includes(UserRole.STUDENT)) {
121-
await updateStudent(studentInfo?.studentId || '', editedStudent);
121+
await updateStudent(editedStudent);
122122
}
123123
if (user?.roles.includes(UserRole.SUPERVISOR)) {
124-
await updateLecturer(lecturerInfo?.lecturerId || '', editedLecturer);
124+
await updateLecturer(editedLecturer);
125125
}
126126
if (user?.roles.includes(UserRole.CONSULTANT)) {
127-
await updateConsultant(consultantInfo?.consultantId || '', editedConsultant);
127+
await updateConsultant(editedConsultant);
128128
}
129129

130130
// Refresh data

frontend/src/shared/ui/theme.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createTheme } from "@mui/material/styles";
2+
3+
export const lightTheme = createTheme({
4+
palette: {
5+
mode: "light",
6+
},
7+
});

0 commit comments

Comments
 (0)