Skip to content

Commit

Permalink
feat(gallery): ✨ Sort by Date
Browse files Browse the repository at this point in the history
  • Loading branch information
Nudelsuppe42 committed Dec 2, 2023
1 parent 016edce commit 0d7e7be
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
39 changes: 29 additions & 10 deletions src/pages/gallery.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Box, Container } from '@mantine/core';
import { Box, Container, Group, Pagination } from '@mantine/core';

import GalleryGrid from '../components/GalleryGrid';
import { NextPage } from 'next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useState } from 'react';
import GalleryGrid from '../components/GalleryGrid';
import Page from '../components/Page';
import fetcher from '../utils/Fetcher';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';

const MePage: NextPage = ({ data }: any) => {
const [activePage, setPage] = useState(1);
return (
<Page
head={{
Expand All @@ -21,17 +23,34 @@ const MePage: NextPage = ({ data }: any) => {
<GalleryGrid
gap={0}
images={
data?.slice(0, 10).map((d: any) => ({
name: d?.title,
src: `https://cdn.buildtheearth.net/upload/${d?.image?.name}`,
date: d?.createdAt,
team: { name: d?.buildTeam.name, slug: d?.buildTeam.slug, logo: d?.buildTeam.icon },
href: `/teams/${d?.buildTeam.slug}`,
})) || [{}]
data
?.sort((a: any, b: any) => new Date(b.date).getTime() - new Date(a.date).getTime())
.slice(activePage * 4 - 4, activePage * 4)
.map((d: any) => ({
name: d?.title,
src: `https://cdn.buildtheearth.net/upload/${d?.image?.name}`,
date: d?.createdAt,
team: {
name: d?.buildTeam.name,
slug: d?.buildTeam.slug,
logo: d?.buildTeam.icon,
},
href: `/teams/${d?.buildTeam.slug}`,
})) || [{}]
}
showTooltipOnHover={true}
/>
</Container>
<Group justify="center" pt="md">
<Pagination
my="md"
total={Math.floor(data.length / 4)}
radius="xs"
value={activePage}
onChange={setPage}
siblings={1}
/>
</Group>
</Box>
</Page>
);
Expand Down
8 changes: 4 additions & 4 deletions src/pages/teams/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Avatar, Badge, Grid, Group, Pagination, Text, useMantineColorScheme, us
import { Pin, Users } from 'tabler-icons-react';

import { NextPage } from 'next';
import { useTranslation } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useRouter } from 'next/router';
import { useState } from 'react';
import Page from '../../components/Page';
import SearchInput from '../../components/SearchInput';
import fetcher from '../../utils/Fetcher';
import getCountryName from '../../utils/ISOCountries';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { useTranslation } from 'next-i18next';

const Teams: NextPage = ({ data }: any) => {
const router = useRouter();
Expand Down

0 comments on commit 0d7e7be

Please sign in to comment.