Skip to content

Commit

Permalink
shimmer effect on home page
Browse files Browse the repository at this point in the history
  • Loading branch information
jitunayak committed Jun 5, 2024
1 parent b688558 commit 2fc9c5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/components/HomeResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useKindeAuth } from '@kinde-oss/kinde-auth-react';
import { styled } from '@stitches/react';
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
import { useCallback, useEffect } from 'react';
import { ShimmerSimpleGallery } from 'react-shimmer-effects';

import HomeResultItem from './HomeResultItem';

Expand Down Expand Up @@ -65,7 +66,11 @@ function HomeResults() {
}, [isLoading]);

if (isLoading || !data || !isSuccess) {
return <span style={{ fontSize: '30px' }}>loading...</span>;
return (
<div style={{ width: '80rem' }}>
<ShimmerSimpleGallery caption card imageHeight={300} />
</div>
);
}

return (
Expand All @@ -86,7 +91,7 @@ function HomeResults() {
item={item}
key={item.id}
/>
))
)),
)}
{hasNextPage &&
new Array(4)
Expand Down
11 changes: 7 additions & 4 deletions src/pages/Room/Reserve.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ const Reserve: React.FC<IProps> = ({ room }) => {
const handleReserve = async () => {
if (!reserveDates.checkIn || !reserveDates.checkOut) return;
console.log(pathname);

if (!isAuthenticated) {
setLocalStorage('redirect_to', pathname);
login();
}

sendBookingConfirmation.mutateAsync({
checkInDate: reserveDates.checkIn,
checkOutDate: reserveDates.checkOut,
});
if (isAuthenticated) {
sendBookingConfirmation.mutateAsync({
checkInDate: reserveDates.checkIn,
checkOutDate: reserveDates.checkOut,
});
}
};

return (
Expand Down
4 changes: 4 additions & 0 deletions src/types/react-shimmer-effect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ declare module 'react-shimmer-effects' {
): JSX.Element;
export function ShimmerTitle(props: ShimmerTitleProps): JSX.Element;
// Add other function declarations here

export function ShimmerSimpleGallery(
props: ShimmerSimpleGalleryProps,
): JSX.Element;
}

0 comments on commit 2fc9c5e

Please sign in to comment.