Skip to content

Commit

Permalink
Cart module scaffold & Minor fixes and refactoring (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
carina-akaia committed Sep 12, 2024
1 parent f55e73f commit 39e55c8
Show file tree
Hide file tree
Showing 92 changed files with 689 additions and 371 deletions.
2 changes: 1 addition & 1 deletion src/common/api/potlock/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const useAccountDonationsSent = ({
export const usePot = ({ potId }: Partial<ByPotId>) => {
const queryResult = swrHooks.useV1PotsRetrieve2(potId ?? "unknown", {
...POTLOCK_REQUEST_CONFIG,
swr: { enabled: Boolean(potId) },
swr: { enabled: Boolean(potId), refreshInterval: 3000 },
});

return { ...queryResult, data: queryResult.data?.data };
Expand Down
109 changes: 0 additions & 109 deletions src/common/assets/svgs/HomeBannerBackground.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions src/common/assets/svgs/cart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/common/assets/svgs/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as ChefHat } from "./chef-hat.svg";
export { default as ChefHatIcon } from "./chef-hat.svg";
export { default as CartIcon } from "./cart.svg";
export { WarningIcon } from "./warning";
export { GroupIcon } from "./group";
export { CopyPasteIcon } from "./CopyPasteIcon";
Expand Down
5 changes: 3 additions & 2 deletions src/common/contracts/potlock/donate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { naxiosInstance } from "@/common/api/near";
import { DONATION_CONTRACT_ID } from "@/common/constants";

import {
Config,
DirectDonation,
DirectDonationArgs,
DirectDonationConfig,
} from "./interfaces/donate.interfaces";

/**
Expand All @@ -22,7 +22,8 @@ export const contractApi = naxiosInstance.contractApi({
/**
* Get donate contract config
*/
export const getConfig = () => contractApi.view<{}, Config>("get_config");
export const getConfig = () =>
contractApi.view<{}, DirectDonationConfig>("get_config");

/**
* Get direct donations
Expand Down
1 change: 1 addition & 0 deletions src/common/contracts/potlock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as donate from "./donate";
import * as pot from "./pot";
import * as potFactory from "./pot-factory";

export * from "./interfaces/donate.interfaces";
export * from "./interfaces/pot.interfaces";
export * from "./interfaces/pot-factory.interfaces";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface Config {
export interface DirectDonationConfig {
owner: string;
protocol_fee_basis_points: number;
referral_fee_basis_points: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from "react";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
// import { ChevronDown } from "lucide-react";

import { cn } from "../utils";
import { cn } from "../../utils";

const Accordion = AccordionPrimitive.Root;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { forwardRef } from "react";

import { type VariantProps, cva } from "class-variance-authority";

import { cn } from "../utils";
import { cn } from "../../utils";

const alertVariants = cva(
cn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";

import * as AvatarPrimitive from "@radix-ui/react-avatar";

import { cn } from "../utils";
import { cn } from "../../utils";

const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { type VariantProps, cva } from "class-variance-authority";

import { cn } from "../utils";
import { cn } from "../../utils";

// TODO: add correct hover effects
const buttonVariants = cva(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { DayPicker } from "react-day-picker";

import { buttonVariants } from "./button";
import { cn } from "../utils";
import { cn } from "../../utils";

export type CalendarProps = React.ComponentProps<typeof DayPicker>;

Expand Down
86 changes: 86 additions & 0 deletions src/common/ui/components/atoms/card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import * as React from "react";

import { cn } from "../../utils";

const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"rounded-lg border bg-card text-card-foreground shadow-sm",
className,
)}
{...props}
/>
));
Card.displayName = "Card";

const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>
));
CardHeader.displayName = "CardHeader";

const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn(
"text-2xl font-semibold leading-none tracking-tight",
className,
)}
{...props}
/>
));
CardTitle.displayName = "CardTitle";

const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
CardDescription.displayName = "CardDescription";

const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
));
CardContent.displayName = "CardContent";

const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
{...props}
/>
));
CardFooter.displayName = "CardFooter";

export {
Card,
CardHeader,
CardFooter,
CardTitle,
CardDescription,
CardContent,
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { forwardRef } from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { Check } from "lucide-react";

import { cn } from "../utils";
import { cn } from "../../utils";

export const Checkbox = forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from "react";
import * as SelectPrimitive from "@radix-ui/react-select";
import { Check, ChevronDown, ChevronUp } from "lucide-react";

import { cn } from "../utils";
import { cn } from "../../utils";

const Select = SelectPrimitive.Root;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";

import * as SwitchPrimitives from "@radix-ui/react-switch";

import { cn } from "../utils";
import { cn } from "../../utils";

const Switch = React.forwardRef<
React.ElementRef<typeof SwitchPrimitives.Root>,
Expand Down
38 changes: 25 additions & 13 deletions src/common/ui/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
export * from "./accordion";
export * from "./alert";
export * from "./avatar";
export * from "./button";
export * from "./calendar";
export * from "./checkbox";
export * from "./clipboard-copy-button";
export * from "./dialog";
/**
* Yet to be sorted in accordance to the Atomic Design principles
*
* See https://atomicdesign.bradfrost.com/chapter-2/
*/
export * from "./dropdown-menu";
export * from "./Filter";
export * from "./form";
export * from "./InfiniteScroll";
export * from "./input";
Expand All @@ -16,23 +12,39 @@ export * from "./popover";
export * from "./radio-group";
export * from "./scroll-area";
export * from "./SearchBar";
export * from "./select";
export * from "./skeleton";
export * from "./SortSelect";
export * from "./Spinner";
export * from "./switch";
export * from "./textarea";
export * from "./toggle";
export * from "./toggle-group";
export * from "./typography";
export * from "./custom-avatar";

/**
* Atoms
*
* See https://atomicdesign.bradfrost.com/chapter-2/#atoms
*/
export * from "./atoms/accordion";
export * from "./atoms/alert";
export * from "./atoms/avatar";
export * from "./atoms/badge";
export * from "./atoms/button";
export * from "./atoms/calendar";
export * from "./atoms/card";
export * from "./atoms/checkbox";
export * from "./atoms/select";
export * from "./atoms/switch";

/**
* Molecules
*
* See https://atomicdesign.bradfrost.com/chapter-2/#molecules
*/
export * from "./molecules/clipboard-copy-button";
export * from "./molecules/data-loading-placeholder";
export * from "./molecules/dialog";
export * from "./molecules/filter";
export * from "./molecules/sort-select";

/**
* Organisms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { type DialogProps } from "@radix-ui/react-dialog";
import { Command as CommandPrimitive } from "cmdk";
import { Search } from "lucide-react";

import { cn } from "@/common/ui/utils";

import { Dialog, DialogContent } from "./dialog";
import { cn } from "../../utils";

const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
Expand Down
Loading

0 comments on commit 39e55c8

Please sign in to comment.