Skip to content

Commit

Permalink
feat: search flow glamping demo
Browse files Browse the repository at this point in the history
  • Loading branch information
patrikzita committed Feb 20, 2024
1 parent bc10925 commit a4ec7f9
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
Binary file modified sqlite.db
Binary file not shown.
2 changes: 1 addition & 1 deletion src/components/PreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type CardProps = React.ComponentProps<typeof Card> & {

export function PreviewCard({ className, glamp, ...props }: CardProps) {
return (
<Card className={cn("w-[380px]", className)} {...props}>
<Card className={cn(className)} {...props}>
<CardHeader>
<CardTitle className={cn({ "text-yellow-600": glamp.isLuxury })}>
{glamp.title}
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/schema/glamps/glamps.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export class GlampResolver {
if (dateRange) {
const { from, to } = dateRange;
glampsQueryBuilder = glampsQueryBuilder.where(
and(gte(dbGlamps.availableFrom, from), lte(dbGlamps.availableTo, to))
and(lte(dbGlamps.availableFrom, to), gte(dbGlamps.availableTo, from))
);
totalCountQueryBuilder = totalCountQueryBuilder.where(
and(gte(dbGlamps.availableFrom, from), lte(dbGlamps.availableTo, to))
and(lte(dbGlamps.availableFrom, to), gte(dbGlamps.availableTo, from))
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/validators/searchParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ParsedUrlQuery } from "querystring";
import { string, z } from "zod";
import { z } from "zod";

const stringToBoolean = (val: unknown) => {
if (val === "true") return true;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/glamps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import { DateRange } from "react-day-picker";
export default function GlampsSearchPage() {
const router = useRouter();

const { isLuxury } = router.query;
const validSearchParams = getValidSearchParams(router.query);

const { data, loading, refetch } = useGetSearchGlampsQuery({
variables: {
limit: 3,
offset: 0,
isLuxury: !!isLuxury,
isLuxury: validSearchParams.isLuxury,
},
fetchPolicy: "cache-first",
nextFetchPolicy: "network-only",
Expand Down Expand Up @@ -59,7 +59,7 @@ export default function GlampsSearchPage() {
<Shell as="main" variant="default">
<h1>Glamping</h1>
<SearchBar onSearch={handleSearch} />
<div className="grid grid-cols-3 gap-3">
<div className="grid md:grid-cols-3 gap-3">
{data?.searchGlamps.glamps.map((glamp) => (
<PreviewCard key={glamp.id} glamp={glamp} />
))}
Expand Down
1 change: 0 additions & 1 deletion src/pages/refetch-changing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export const ShowDealsGrandChildren = () => {
fetchPolicy: "standby",
});

console.log(data);
if (data?.deals.length)
return (
<div className="border-orange-700 border-2 p-1">
Expand Down

0 comments on commit a4ec7f9

Please sign in to comment.