Skip to content

Commit

Permalink
better card
Browse files Browse the repository at this point in the history
  • Loading branch information
Zajaczkowskim committed Sep 28, 2024
1 parent 7b2fec8 commit 452796d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
6 changes: 4 additions & 2 deletions parent_app/src/app/list/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
'use client'
import { useEffect, useState } from 'react';
import Card from '../../components/Card';
import { convertISOToDateTime } from '@/utils/dateTimeConverter';
import { convertISOToTime } from '@/utils/dateTimeConverter';
import { convertISOToDate } from '@/utils/dateTimeConverter';


type ImageData = {
_id: string;
Expand Down Expand Up @@ -53,7 +55,7 @@ const ImageGallery = () => {
</li>
))} */}
{images.map((image) => (
<Card image={image} waga={image.weight} godzina={convertISOToDateTime(image.submittedAt)} />
<Card image={image} waga={image.weight} godzina={convertISOToTime(image.submittedAt)} data={convertISOToDate(image.submittedAt)} />
))}
</ul>
</div>
Expand Down
4 changes: 2 additions & 2 deletions parent_app/src/components/Card.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import smile from '../icons/smile.svg';
import sad from '../icons/sad.svg';

const Card = ({ image, waga, godzina }) => {
const Card = ({ image, waga, godzina, data }) => {
return ( <>

<div className="bg-white rounded-lg p-4 mb-4 shadow-md items-center" style={{ width: '350px', height: '150px' }}>
<div>
<p className="text-black">10.05.2024</p>
<p className="text-black">{data}</p>
</div>
<div className="w-full h-full flex">
{/* Left side: Image */}
Expand Down
18 changes: 16 additions & 2 deletions parent_app/src/utils/dateTimeConverter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const convertISOToDateTime = (isoString: string): string => {
export const convertISOToDate = (isoString: string): string => {
const date = new Date(isoString);

const year = date.getFullYear();
Expand All @@ -9,5 +9,19 @@ export const convertISOToDateTime = (isoString: string): string => {
const minutes = String(date.getMinutes()).padStart(2, '0');
//const seconds = String(date.getSeconds()).padStart(2, '0');

return `${year}-${month}-${day} ${hours}:${minutes}`;
return `${day}-${month}-${year}`;
};

export const convertISOToTime = (isoString: string): string => {
const date = new Date(isoString);

const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');

const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
//const seconds = String(date.getSeconds()).padStart(2, '0');

return `${hours}:${minutes}`;
};

0 comments on commit 452796d

Please # to comment.