Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
svitlanak31 committed Nov 19, 2024
1 parent 4ee4e7e commit a12fc2c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const App = () => {
const fetchedUsers = await client.get<User[]>('/users');

if (fetchedUsers.length === 0) {
throw new Error('No users found');
throw new Error('No users found. Please try a different search.');
}

setUsers(fetchedUsers);
Expand All @@ -46,7 +46,7 @@ export const App = () => {

setPosts(fetchedPosts);
} catch (err) {
setError('Failed to load posts');
setError('Failed to load posts due to network issues');
} finally {
setIsLoading(false);
}
Expand Down Expand Up @@ -131,4 +131,4 @@ export const App = () => {
</div>
</main>
);
};
};
6 changes: 3 additions & 3 deletions src/components/NewCommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export const NewCommentForm: React.FC<Props> = ({
setNameError('Name is required');
}

if (!trimmedEmail) {
if (!trimmedEmail.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)) {
hasValidationErrors = true;
setEmailError('Email is required');
setEmailError('Invalid email format');
}

if (!trimmedText) {
Expand Down Expand Up @@ -208,4 +208,4 @@ export const NewCommentForm: React.FC<Props> = ({
</div>
</form>
);
};
};
2 changes: 1 addition & 1 deletion src/components/PostDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ export const PostDetails: React.FC<Props> = ({ post }) => {
</div>
</div>
);
};
};
2 changes: 1 addition & 1 deletion src/components/PostsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ export const PostsList: React.FC<Props> = ({ posts, openedPost, onOpen }) => (
</tbody>
</table>
</div>
);
);
2 changes: 1 addition & 1 deletion src/components/UserSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ export const UserSelector: React.FC<Props> = ({
</div>
</div>
);
};
};
1 change: 0 additions & 1 deletion src/types/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export interface Post {
title: string;
body: string;
}

2 changes: 1 addition & 1 deletion src/types/User.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Post } from "./Post";
import { Post } from './Post';

export interface User {
id: number;
Expand Down

0 comments on commit a12fc2c

Please sign in to comment.