(false);
+ const accordeonLabel = useMemo(
+ () => (visible ? 'Ocultar itens doados' : 'Mostrar itens doados'),
+ [visible]
+ );
+ const AccordeonIcon = useMemo(
+ () => (visible ? ChevronUp : ChevronDown),
+ [visible]
+ );
+
+ return (
+
+
+
+
+
+
+ Doação para
+
+
{donation.shelter.name}
+
+ às {format(new Date(donation.createdAt), "HH'h'mm 'de' dd/MM/yy")}
+
+
+
+
+ {donation.donationOrderSupplies.map((s, idx) => (
+ -
+
+ {s.quantity}
+ {SupplyMeasureMap[s.supply.measure]} de {s.supply.name}
+
+ ))}
+
+
+
+
+
+
+ );
+};
+
+export { DonationHistoryListItem };
diff --git a/src/pages/DonationsHistory/components/DonationHistoryListItem/index.ts b/src/pages/DonationsHistory/components/DonationHistoryListItem/index.ts
new file mode 100644
index 00000000..498912cb
--- /dev/null
+++ b/src/pages/DonationsHistory/components/DonationHistoryListItem/index.ts
@@ -0,0 +1,3 @@
+import { DonationHistoryListItem } from './DonationHistoryListItem';
+
+export { DonationHistoryListItem };
diff --git a/src/pages/DonationsHistory/components/DonationHistoryListItem/types.ts b/src/pages/DonationsHistory/components/DonationHistoryListItem/types.ts
new file mode 100644
index 00000000..9b2c6927
--- /dev/null
+++ b/src/pages/DonationsHistory/components/DonationHistoryListItem/types.ts
@@ -0,0 +1,8 @@
+import { IDonationsData } from '@/hooks/useDonations/types';
+
+export interface IDonationHistoryListItem {
+ data: IDonationsData;
+ onConfirm?: () => void;
+ onCancel?: () => void;
+ loading?: boolean;
+}
diff --git a/src/pages/DonationsHistory/components/DonationHistoryStatus/DonationHistoryStatus.tsx b/src/pages/DonationsHistory/components/DonationHistoryStatus/DonationHistoryStatus.tsx
new file mode 100644
index 00000000..1466288e
--- /dev/null
+++ b/src/pages/DonationsHistory/components/DonationHistoryStatus/DonationHistoryStatus.tsx
@@ -0,0 +1,41 @@
+import React from 'react';
+import { cva } from 'class-variance-authority';
+
+import { IDonationHistoryStatus } from './types';
+import { DonationStatusMap, cn } from '@/lib/utils';
+import { DonateOrderStatus } from '@/service/donationOrder/types';
+
+const DonationHistoryStatus = React.forwardRef<
+ HTMLDivElement,
+ IDonationHistoryStatus
+>((props, ref) => {
+ const { status, className = '', children, chipProps = {}, ...rest } = props;
+ const { className: chipClassName, ...restChipProps } = chipProps;
+
+ const variants = cva('px-2 py-1 font-medium text-xs rounded-2xl', {
+ variants: {
+ variant: {
+ [DonateOrderStatus.Pending]: 'bg-light-yellow',
+ [DonateOrderStatus.Canceled]: 'bg-gray-300',
+ [DonateOrderStatus.Complete]: 'bg-light-green',
+ },
+ },
+ defaultVariants: {
+ variant: status,
+ },
+ });
+
+ return (
+
+
+ {DonationStatusMap[status]}
+
+ {children}
+
+ );
+});
+
+export { DonationHistoryStatus };
diff --git a/src/pages/DonationsHistory/components/DonationHistoryStatus/index.ts b/src/pages/DonationsHistory/components/DonationHistoryStatus/index.ts
new file mode 100644
index 00000000..ea6f681c
--- /dev/null
+++ b/src/pages/DonationsHistory/components/DonationHistoryStatus/index.ts
@@ -0,0 +1,3 @@
+import { DonationHistoryStatus } from './DonationHistoryStatus';
+
+export { DonationHistoryStatus };
diff --git a/src/pages/DonationsHistory/components/DonationHistoryStatus/types.ts b/src/pages/DonationsHistory/components/DonationHistoryStatus/types.ts
new file mode 100644
index 00000000..abbd3925
--- /dev/null
+++ b/src/pages/DonationsHistory/components/DonationHistoryStatus/types.ts
@@ -0,0 +1,8 @@
+import { DonateOrderStatus } from '@/service/donationOrder/types';
+import React from 'react';
+
+export interface IDonationHistoryStatus
+ extends React.ComponentPropsWithoutRef<'div'> {
+ status: DonateOrderStatus;
+ chipProps?: React.ComponentPropsWithoutRef<'div'>;
+}
diff --git a/src/pages/DonationsHistory/components/DonationsPerDay.tsx b/src/pages/DonationsHistory/components/DonationsPerDay.tsx
deleted file mode 100644
index 4e694967..00000000
--- a/src/pages/DonationsHistory/components/DonationsPerDay.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { IDonationsPerDayProps } from '../types';
-import { Donation } from './Donation';
-
-const DonationsPerDay = ({ donations, viewOption }: IDonationsPerDayProps) => {
- const donationsOfDay = donations.map((donation) => {
- donation = {
- donationId: donation.id,
- donatorName: donation.shelter.name,
- donatorId: donation.userId,
- shelterId: donation.shelter.id,
- shelterName: donation.shelter.name,
- status: donation.status,
- createdAt: donation.createdAt,
- updatedAt: donation.updatedAt || null,
- items: donation.donationOrderSupplies,
- };
-
- return (
-
- );
- });
-
- return (
-
- );
-};
-export { DonationsPerDay };
diff --git a/src/pages/DonationsHistory/components/index.ts b/src/pages/DonationsHistory/components/index.ts
new file mode 100644
index 00000000..0e6453de
--- /dev/null
+++ b/src/pages/DonationsHistory/components/index.ts
@@ -0,0 +1,4 @@
+import { DonationHistoryListItem } from './DonationHistoryListItem';
+import { DonationHistoryStatus } from './DonationHistoryStatus';
+
+export { DonationHistoryListItem, DonationHistoryStatus };
diff --git a/src/pages/DonationsHistory/types.ts b/src/pages/DonationsHistory/types.ts
index 1229f76a..cb0ff5c3 100644
--- a/src/pages/DonationsHistory/types.ts
+++ b/src/pages/DonationsHistory/types.ts
@@ -1,25 +1 @@
-import { IDonationsData } from '@/hooks/useDonations/types';
-
-export type IDonations = IDonationsData[];
-
-export interface IDonationsPerDay {
- [date: string]: IDonations;
-}
-
-export interface IDonationsInGivenDay {
- donations: IDonations;
-}
-
-export enum ViewOptions {
- Donated = 'donated',
- Received = 'received',
-}
-export interface IDonationsPerDayProps {
- donations: IDonations;
- viewOption: ViewOptions;
-}
-
-export interface IDonationProps {
- viewOption: ViewOptions;
- donation: IDonationProps;
-}
+export {};
diff --git a/src/pages/Home/components/Filter/Filter.tsx b/src/pages/Home/components/Filter/Filter.tsx
index d19ebf1b..b8cfab6e 100644
--- a/src/pages/Home/components/Filter/Filter.tsx
+++ b/src/pages/Home/components/Filter/Filter.tsx
@@ -21,20 +21,11 @@ import {
IFilterProps,
ShelterAvailabilityStatus,
} from './types';
-import { priorityOptions } from '@/lib/utils';
+import { ShelterAvailabilityStatusMap, priorityOptions } from '@/lib/utils';
import CitiesFilter from './CitiesFilter';
import { IUseSuppliesData } from '@/hooks/useSupplies/types';
import { SupplyPriority } from '@/service/supply/types';
-const ShelterAvailabilityStatusMapped: Record<
- ShelterAvailabilityStatus,
- string
-> = {
- available: 'Abrigo Disponivel',
- unavailable: 'Abrigo Indisponivel',
- waiting: 'Sem informação de disponibilidade',
-};
-
const priorityOpts = Object.entries(priorityOptions).reduce(
(prev, [priority, label]) =>
priority === `${SupplyPriority.NotNeeded}`
@@ -71,7 +62,7 @@ const Filter = (props: IFilterProps) => {
})),
search: data.search,
shelterStatus: data.shelterStatus.map((s) => ({
- label: ShelterAvailabilityStatusMapped[s],
+ label: ShelterAvailabilityStatusMap[s],
value: s,
})),
supplyCategories: data.supplyCategoryIds.map((id) => ({
@@ -134,7 +125,7 @@ const Filter = (props: IFilterProps) => {
checked
? [
...values.shelterStatus,
- { label: ShelterAvailabilityStatusMapped[status], value: status },
+ { label: ShelterAvailabilityStatusMap[status], value: status },
]
: values.shelterStatus.filter((s) => s.value !== status)
);
diff --git a/src/pages/Shelter/Shelter.tsx b/src/pages/Shelter/Shelter.tsx
index 7b41487c..e8e64f66 100644
--- a/src/pages/Shelter/Shelter.tsx
+++ b/src/pages/Shelter/Shelter.tsx
@@ -211,6 +211,7 @@ const Shelter = () => {
quantity: l.quantity,
}))}
onDonate={handleDonate}
+ shelterId={shelterId}
/>
{!isLastElement && }
diff --git a/src/pages/Shelter/components/ShelterCategoryList/ShelterCategoryList.tsx b/src/pages/Shelter/components/ShelterCategoryList/ShelterCategoryList.tsx
index a5ac597a..7a0f14a2 100644
--- a/src/pages/Shelter/components/ShelterCategoryList/ShelterCategoryList.tsx
+++ b/src/pages/Shelter/components/ShelterCategoryList/ShelterCategoryList.tsx
@@ -1,12 +1,20 @@
+import { useContext, useMemo } from 'react';
import clsx from 'clsx';
import { SupplyMeasureMap, cn, getSupplyPriorityProps } from '@/lib/utils';
import { ShelterCategoryListProps } from './types';
import { CircleStatus } from '@/components';
import { SupplyPriority } from '@/service/supply/types';
+import { DonationCartContext } from '@/contexts';
+import { IDonationCartItem } from '@/contexts/DonationCartContext/types';
const ShelterCategoryList = (props: ShelterCategoryListProps) => {
- const { items, name, onDonate } = props;
+ const { items, name, onDonate, shelterId } = props;
+ const { carts } = useContext(DonationCartContext);
+ const cart: IDonationCartItem[] = useMemo(
+ () => carts[shelterId] ?? [],
+ [carts, shelterId]
+ );
return (
@@ -36,8 +44,9 @@ const ShelterCategoryList = (props: ShelterCategoryListProps) => {