Skip to content

Commit

Permalink
Remove ramda from SessionsList, fix padding, fix default value
Browse files Browse the repository at this point in the history
  • Loading branch information
VerboseCat committed Nov 21, 2024
1 parent 8dbd0d6 commit 9255afc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const MarkingDefinitions = () => {
orderAsc: params.orderAsc !== false,
searchTerm: params.searchTerm ?? '',
view: params.view ?? 'lines',
sortBy: params.sortBy ?? 'name',
sortBy: params.sortBy ?? 'definition',
});

function saveView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const useStyles = makeStyles(() => ({
},
parameters: {
float: 'left',
marginTop: -10,
marginBottom: 10,
},
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useEffect, useState } from 'react';
import * as R from 'ramda';
import { Link } from 'react-router-dom';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
Expand Down Expand Up @@ -117,16 +116,11 @@ const SessionsListComponent = ({ relay, data, keyword }) => {
});
};

const sortByNameCaseInsensitive = R.sortBy(
R.compose(R.toLower, R.path(['user', 'name'])),
);
const sortByNameCaseInsensitive = (a, b) => a.user.name.toLowerCase().localeCompare(b.user.name.toLowerCase());
const filterByKeyword = (n) => keyword === ''
|| n.user.name.toLowerCase().indexOf(keyword.toLowerCase()) !== -1;
const sessions = R.pipe(
R.propOr([], 'sessions'),
R.filter(filterByKeyword),
sortByNameCaseInsensitive,
)(data);
const sessions = (data.sessions ?? []).filter(filterByKeyword).toSorted(sortByNameCaseInsensitive);

return (
<>
<List
Expand All @@ -136,9 +130,8 @@ const SessionsListComponent = ({ relay, data, keyword }) => {
>
{sessions.map((session) => {
const { user, sessions: userSessions } = session;
const orderedSessions = R.sort(
const orderedSessions = userSessions.toSorted(
(a, b) => timestamp(a.created) - timestamp(b.created),
userSessions,
);
return (
<div key={session.user.id}>
Expand Down

0 comments on commit 9255afc

Please sign in to comment.