mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 10:04:44 +00:00
Refactor FeatureNotAvailable component interfaces and improve code formatting
This commit is contained in:
@@ -4,14 +4,18 @@ import { Link } from 'react-router';
|
|||||||
|
|
||||||
type Reason = 'soon' | 'maintenance' | 'auth';
|
type Reason = 'soon' | 'maintenance' | 'auth';
|
||||||
|
|
||||||
type Action = { to: string; label: string; className: string };
|
interface Action {
|
||||||
|
to: string;
|
||||||
|
label: string;
|
||||||
|
className: string;
|
||||||
|
}
|
||||||
|
|
||||||
type Content = {
|
interface Content {
|
||||||
Icon: ComponentType<{ className?: string }>;
|
Icon: ComponentType<{ className?: string }>;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
actions: Action[];
|
actions: Action[];
|
||||||
};
|
}
|
||||||
|
|
||||||
const CONTENT: Record<Reason, Content> = {
|
const CONTENT: Record<Reason, Content> = {
|
||||||
soon: {
|
soon: {
|
||||||
@@ -32,7 +36,8 @@ const CONTENT: Record<Reason, Content> = {
|
|||||||
auth: {
|
auth: {
|
||||||
Icon: Lock,
|
Icon: Lock,
|
||||||
title: 'Sign in to use this feature',
|
title: 'Sign in to use this feature',
|
||||||
description: 'This feature requires a valid session. Log in or create an account to continue.',
|
description:
|
||||||
|
'This feature requires a valid session. Log in or create an account to continue.',
|
||||||
actions: [
|
actions: [
|
||||||
{ to: '/login', label: 'Login', className: 'btn-primary' },
|
{ to: '/login', label: 'Login', className: 'btn-primary' },
|
||||||
{ to: '/register', label: 'Register', className: 'btn-outline' },
|
{ to: '/register', label: 'Register', className: 'btn-outline' },
|
||||||
@@ -40,9 +45,9 @@ const CONTENT: Record<Reason, Content> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
type FeatureNotAvailableProps = {
|
interface FeatureNotAvailableProps {
|
||||||
reason?: Reason;
|
reason?: Reason;
|
||||||
};
|
}
|
||||||
|
|
||||||
const FeatureNotAvailable = ({ reason = 'soon' }: FeatureNotAvailableProps) => {
|
const FeatureNotAvailable = ({ reason = 'soon' }: FeatureNotAvailableProps) => {
|
||||||
const { Icon, title, description, actions } = CONTENT[reason];
|
const { Icon, title, description, actions } = CONTENT[reason];
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ export const meta = ({}: Route.MetaArgs) => [
|
|||||||
|
|
||||||
export const loader = async ({ request }: Route.LoaderArgs) => {
|
export const loader = async ({ request }: Route.LoaderArgs) => {
|
||||||
const auth = await getOptionalAuth(request);
|
const auth = await getOptionalAuth(request);
|
||||||
let recentBreweries: Brewery[] = [];
|
|
||||||
|
|
||||||
const randomOffset = Math.random() * 1.0
|
// The rest of the landing page stands on its own, so a brewery service
|
||||||
|
// outage degrades to the empty state instead of an error page.
|
||||||
|
let recentBreweries: Brewery[] = [];
|
||||||
try {
|
try {
|
||||||
recentBreweries = await getBreweries(PARTNER_BREWERY_COUNT, 0);
|
recentBreweries = await getBreweries(PARTNER_BREWERY_COUNT, 0);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user