Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alianza committed May 20, 2024
1 parent 2076add commit 5520d3c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 31 deletions.
2 changes: 1 addition & 1 deletion components/common/Filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Filters({ filters = {}, onReset, children }) {
}, []);

return (
<details ref={detailsRef} className="rounded-lg bg-neutral-50 p-4 shadow-lg dark:bg-neutral-800">
<details ref={detailsRef} className="rounded-lg bg-neutral-50 p-4 shadow-md dark:bg-neutral-800">
<summary className="cursor-pointer text-xl font-medium">Filters</summary>
<div data-contents="">
<hr className="my-4 border-neutral-800 dark:border-neutral-400" />
Expand Down
12 changes: 6 additions & 6 deletions pages/combos/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ export default function CombosPage() {
}
};

const filteredCombos =
filters.landed === 'any' ? combos : combos?.filter((combo) => filters.landed === (combo.landed ? 'yes' : 'no'));

return (
<div className="flex flex-col gap-16">
<div className="flex flex-col gap-12">
<div>
<h1 className="text-center text-5xl">Combos</h1>
<p className="mt-3 text-center">This is an overview of all the combos you've added to your account.</p>
Expand Down Expand Up @@ -101,17 +104,14 @@ export default function CombosPage() {

<TransitionScroll hiddenStyle={hiddenStyle} baseStyle={baseStyle} className="flex flex-col">
<GenericTable
objArray={
filters.landed === 'any'
? combos
: combos?.filter((combo) => filters.landed === (combo.landed ? 'yes' : 'no'))
}
objArray={filteredCombos}
columns={[{ trick: { className: 'text-sm font-bold', alias: 'Combo name' } }, landedAtCol]}
actions={getCommonActions('combos')}
onAction={handleAction}
entityName="combo"
newLink="/new-combo"
showCount
enablePagination
/>
</TransitionScroll>
</div>
Expand Down
20 changes: 14 additions & 6 deletions pages/dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import TransitionScroll from 'react-transition-scroll';
// }

export default function Index() {
const [flatgroundTricks, setFlatgroundTricks] = useState({ data: [], count: 0 });
const [grinds, setGrinds] = useState({ data: [], count: 0 });
const [manuals, setManuals] = useState({ data: [], count: 0 });
const [combos, setCombos] = useState({ data: [], count: 0 });
const [flatgroundTricks, setFlatgroundTricks] = useState({ data: null, count: 0 });
const [grinds, setGrinds] = useState({ data: null, count: 0 });
const [manuals, setManuals] = useState({ data: null, count: 0 });
const [combos, setCombos] = useState({ data: null, count: 0 });

useAsyncEffect(async () => {
const fetchAndSetData = async (endpoint, setData) => {
Expand Down Expand Up @@ -97,10 +97,10 @@ export default function Index() {
}
};

const formatAdditionalInfo = (count, data) => (count !== 0 && count !== data.length ? count + ' total' : '');
const formatAdditionalInfo = (count, data) => (count !== 0 && count !== data?.length ? count + ' total' : '');

return (
<div className="flex flex-col gap-16">
<div className="flex flex-col gap-12">
<div>
<h1 className="text-center text-5xl">Dashboard</h1>
<p className="mt-3 text-center">This is an overview of all the landed tricks you've added to your account.</p>
Expand All @@ -119,6 +119,8 @@ export default function Index() {
defaultSortColumnIndex={1}
defaultSortDirection="desc"
additionalInfo={formatAdditionalInfo(flatgroundTricks.count, flatgroundTricks.data)}
additionalInfoLink="/flatgroundtricks"
enablePagination
/>
</TransitionScroll>

Expand All @@ -136,6 +138,8 @@ export default function Index() {
defaultSortColumnIndex={1}
defaultSortDirection="desc"
additionalInfo={formatAdditionalInfo(grinds.count, grinds.data)}
additionalInfoLink="/grinds"
enablePagination
/>
</TransitionScroll>

Expand All @@ -153,6 +157,8 @@ export default function Index() {
defaultSortColumnIndex={1}
defaultSortDirection="desc"
additionalInfo={formatAdditionalInfo(manuals.count, manuals.data)}
additionalInfoLink="/manuals"
enablePagination
/>
</TransitionScroll>

Expand All @@ -170,6 +176,8 @@ export default function Index() {
defaultSortColumnIndex={1}
defaultSortDirection="desc"
additionalInfo={formatAdditionalInfo(combos.count, combos.data)}
additionalInfoLink="/combos"
enablePagination
/>
</TransitionScroll>
</div>
Expand Down
14 changes: 8 additions & 6 deletions pages/flatgroundtricks/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ export default function FlatgroundTricksPage() {
}
};

const filteredFlatgroundTricks =
filters.landed === 'any'
? flatgroundTricks
: flatgroundTricks?.filter((trick) => filters.landed === (trick.landed ? 'yes' : 'no'));

return (
<div className="flex flex-col gap-16">
<div className="flex flex-col gap-12">
<div>
<h1 className="text-center text-5xl">Flatground Tricks</h1>
<p className="mt-3 text-center">
Expand Down Expand Up @@ -69,18 +74,15 @@ export default function FlatgroundTricksPage() {

<TransitionScroll hiddenStyle={hiddenStyle} baseStyle={baseStyle} className="flex flex-col">
<GenericTable
objArray={
filters.landed === 'any'
? flatgroundTricks
: flatgroundTricks?.filter((trick) => filters.landed === (trick.landed ? 'yes' : 'no'))
}
objArray={filteredFlatgroundTricks}
columns={['stance', 'direction', 'rotation', 'name', trickCol, landedAtCol]}
actions={getCommonActions('flatgroundtricks')}
onAction={handleAction}
entityName="flatground trick"
newLink="/new-flatground-trick"
showCount
defaultSortColumnIndex={4}
enablePagination
/>
</TransitionScroll>
</div>
Expand Down
11 changes: 5 additions & 6 deletions pages/grinds/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ export default function GrindsPage() {
break;
}
};
const filteredGrinds =
filters.landed === 'any' ? grinds : grinds.filter((grind) => filters.landed === (grind.landed ? 'yes' : 'no'));

return (
<div className="flex flex-col gap-16">
<div className="flex flex-col gap-12">
<div>
<h1 className="text-center text-5xl">Grinds</h1>
<p className="mt-3 text-center">This is an overview of all the grinds you've added to your account.</p>
Expand All @@ -66,18 +68,15 @@ export default function GrindsPage() {

<TransitionScroll hiddenStyle={hiddenStyle} baseStyle={baseStyle} className="flex flex-col">
<GenericTable
objArray={
filters.landed === 'any'
? grinds
: grinds.filter((grind) => filters.landed === (grind.landed ? 'yes' : 'no'))
}
objArray={filteredGrinds}
columns={['stance', 'direction', 'name', trickCol, landedAtCol]}
actions={getCommonActions('grinds')}
entityName="grind"
onAction={handleAction}
newLink="/new-grind"
showCount
defaultSortColumnIndex={3}
enablePagination
/>
</TransitionScroll>
</div>
Expand Down
12 changes: 6 additions & 6 deletions pages/manuals/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ export default function ManualsPage() {
}
};

const filteredManuals =
filters.landed === 'any' ? manuals : manuals.filter((manual) => filters.landed === (manual.landed ? 'yes' : 'no'));

return (
<div className="flex flex-col gap-16">
<div className="flex flex-col gap-12">
<div>
<h1 className="text-center text-5xl">Manuals</h1>
<p className="mt-3 text-center">This is an overview of all the manuals you've added to your account.</p>
Expand Down Expand Up @@ -67,17 +70,14 @@ export default function ManualsPage() {

<TransitionScroll hiddenStyle={hiddenStyle} baseStyle={baseStyle} className="flex flex-col">
<GenericTable
objArray={
filters.landed === 'any'
? manuals
: manuals.filter((manual) => filters.landed === (manual.landed ? 'yes' : 'no'))
}
objArray={filteredManuals}
columns={[{ type: { className: 'text-sm font-bold' } }, landedAtCol]}
actions={getCommonActions('manuals')}
onAction={handleAction}
entityName="manual"
newLink="/new-manual"
showCount
enablePagination
/>
</TransitionScroll>
</div>
Expand Down

0 comments on commit 5520d3c

Please sign in to comment.