Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 5x 5x 5x 6x 4x | import { TravelExplore } from "@mui/icons-material";
import { styled, Typography } from "@mui/material";
import Alert from "components/Alert";
import CardTrack, { useCardTrack } from "components/CardTrack";
import { useTranslation } from "i18n";
import { DASHBOARD } from "i18n/namespaces";
import { CARD_WIDTH, DashboardPublicTripCard, DashboardPublicTripCardSkeleton } from "./DashboardPublicTripCard";
import DashboardSectionHeader from "./DashboardSectionHeader";
import useGetDashboard, { Dashboard } from "./useGetDashboard";
const EmptyStateRow = styled("div")(({ theme }) => ({
display: "flex",
alignItems: "center",
gap: theme.spacing(2),
padding: "16px 18px",
border: "1px dashed var(--mui-palette-grey-300)",
borderRadius: "10px",
background: "var(--mui-palette-grey-50)",
}));
const selectCommunityPublicTrips = (dashboard: Dashboard) => dashboard.communityPublicTrips?.publicTripsList ?? [];
export default function DashboardCommunityPublicTrips() {
const {
t,
i18n: { language: locale },
} = useTranslation([DASHBOARD]);
const { data: trips = [], isLoading, error } = useGetDashboard(selectCommunityPublicTrips);
const track = useCardTrack();
return (
<section>
<DashboardSectionHeader
icon={TravelExplore}
title={t("dashboard:public_trips.community_trips_header")}
{...track.navProps}
/>
{error && <Alert severity="error">{error.message}</Alert>}
{isLoading ? (
<CardTrack cardWidth={CARD_WIDTH}>
{[0, 1, 2].map((i) => (
<DashboardPublicTripCardSkeleton key={i} showCommunityName />
))}
</CardTrack>
) : trips.length > 0 ? (
<CardTrack track={track} cardWidth={CARD_WIDTH}>
{trips.map((trip) => (
<DashboardPublicTripCard
key={trip.tripId}
trip={trip}
locale={locale}
isOwnTrip={false}
showCommunityName
/>
))}
</CardTrack>
) : (
!error && (
<EmptyStateRow>
<TravelExplore sx={{ fontSize: 26, color: "var(--mui-palette-grey-400)", flexShrink: 0 }} />
<Typography variant="body2" sx={{ flex: 1, color: "var(--mui-palette-text-secondary)" }}>
{t("dashboard:public_trips.community_trips_empty_description")}
</Typography>
</EmptyStateRow>
)
)}
</section>
);
}
|