Skip to content

Commit

Permalink
refactor: public squad request requirement (#3190)
Browse files Browse the repository at this point in the history
  • Loading branch information
sshanzel committed Jun 5, 2024
1 parent b06573d commit 6d71a53
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import { ActionType } from '../../graphql/actions';
import { useLazyModal } from '../../hooks/useLazyModal';
import { LazyModal } from '../modals/common/types';
import { anchorDefaultRel } from '../../lib/strings';
import {
MIN_SQUAD_POSTS,
SquadPostsProgressBar,
} from './SquadPostsProgressBar';
import { SquadPostsProgressBar } from './SquadPostsProgressBar';
import { squadsPublicGuide } from '../../lib/constants';
import { SquadStatus } from './settings';
import { PlaceholderCard } from '../cards/PlaceholderCard';
import { PUBLIC_SQUAD_REQUEST_REQUIREMENT } from '../../lib/config';

export function PublicSquadEligibilityCard(): ReactElement {
const router = useRouter();
Expand Down Expand Up @@ -53,7 +51,7 @@ export function PublicSquadEligibilityCard(): ReactElement {
return <PlaceholderCard />;
}

const isEligible = postsCount >= MIN_SQUAD_POSTS;
const isEligible = postsCount >= PUBLIC_SQUAD_REQUEST_REQUIREMENT;
const CardComponent = shouldUseListFeedLayout ? CardV1 : Card;

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { ReactElement } from 'react';
import classNames from 'classnames';
import { ProgressBar } from '../fields/ProgressBar';

export const MIN_SQUAD_POSTS = 3;
import { PUBLIC_SQUAD_REQUEST_REQUIREMENT } from '../../lib/config';

interface ClassName {
container?: string;
Expand All @@ -21,7 +20,7 @@ interface Props {

export const SquadPostsProgressBar = ({
className,
goal = MIN_SQUAD_POSTS,
goal = PUBLIC_SQUAD_REQUEST_REQUIREMENT,
postsCount = 0,
}: Props): ReactElement => {
const effectivePostsCount = Math.min(postsCount, goal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { badge, SquadStatus, StatusDescription } from './common';
import { Anchor } from '../../text';
import { squadsPublicGuide } from '../../../lib/constants';
import { PublicStatusPanel } from './PublicStatusPanel';
import { PUBLIC_SQUAD_REQUEST_REQUIREMENT } from '../../../lib/config';

export interface SettingsPublicSectionProps {
totalPosts: number;
status: string;
}

const PUBLIC_SQUAD_REQUIRED_POSTS = 3;

export function SettingsPublicSection({
status,
totalPosts,
Expand Down Expand Up @@ -51,8 +50,8 @@ export function SettingsPublicSection({
{/* it seems to be a bit unusual to show 50/3, hence we max the count at 3 so the progress will always be 3/3 */}
{isInProgress && (
<PublicStatusPanel
count={Math.min(totalPosts, PUBLIC_SQUAD_REQUIRED_POSTS)}
required={PUBLIC_SQUAD_REQUIRED_POSTS}
count={Math.min(totalPosts, PUBLIC_SQUAD_REQUEST_REQUIREMENT)}
required={PUBLIC_SQUAD_REQUEST_REQUIREMENT}
/>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/hooks/useSquadChecklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import { SquadEditWelcomePostChecklistStep } from '../components/checklist/Squad
import { usePushNotificationContext } from '../contexts/PushNotificationContext';
import { EditSquadStep } from '../components/checklist/EditSquadStep';
import { GoPublicStep } from '../components/checklist/GoPublicStep';
import { MIN_SQUAD_POSTS } from '../components/squads/SquadPostsProgressBar';
import {
getEditActions,
getPublicActions,
} from '../components/checklist/actionUtils';
import { PUBLIC_SQUAD_REQUEST_REQUIREMENT } from '../lib/config';

type UseSquadChecklistProps = {
squad: Squad;
Expand Down Expand Up @@ -143,7 +143,7 @@ const useSquadChecklist = ({
type: ActionType.MakeSquadPublic,
step: {
title: 'Get more traffic by going public',
description: `To get your Squad posts exposed in the daily.dev feed, create at least ${MIN_SQUAD_POSTS} posts and apply for a public Squad status`,
description: `To get your Squad posts exposed in the daily.dev feed, create at least ${PUBLIC_SQUAD_REQUEST_REQUIREMENT} posts and apply for a public Squad status`,
component: (props) => <GoPublicStep {...props} squad={squad} />,
},
actions: getPublicActions(squad),
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export const fallbackImages = {
export const MAX_VISIBLE_PRIVILEGED_MEMBERS_LAPTOP = 3;
export const MAX_VISIBLE_PRIVILEGED_MEMBERS_MOBILE = 1;
export const PUBLIC_SQUAD_REQUEST_COOLDOWN = 14;
export const PUBLIC_SQUAD_REQUEST_REQUIREMENT = 5;

0 comments on commit 6d71a53

Please sign in to comment.