|
1 | 1 | import { conform, list, requestIntent, useFieldList, useForm } from "@conform-to/react"; |
2 | 2 | import { parse } from "@conform-to/zod"; |
3 | | -import { EnvelopeIcon, LockOpenIcon, UserPlusIcon } from "@heroicons/react/20/solid"; |
| 3 | +import { |
| 4 | + ArrowUpCircleIcon, |
| 5 | + EnvelopeIcon, |
| 6 | + LockOpenIcon, |
| 7 | + UserPlusIcon, |
| 8 | +} from "@heroicons/react/20/solid"; |
4 | 9 | import type { ActionFunction, LoaderFunctionArgs } from "@remix-run/node"; |
5 | 10 | import { json } from "@remix-run/node"; |
6 | 11 | import { Form, useActionData } from "@remix-run/react"; |
@@ -28,7 +33,13 @@ import { redirectWithSuccessMessage } from "~/models/message.server"; |
28 | 33 | import { TeamPresenter } from "~/presenters/TeamPresenter.server"; |
29 | 34 | import { scheduleEmail } from "~/services/email.server"; |
30 | 35 | import { requireUserId } from "~/services/session.server"; |
31 | | -import { acceptInvitePath, organizationTeamPath, v3BillingPath } from "~/utils/pathBuilder"; |
| 36 | +import { |
| 37 | + acceptInvitePath, |
| 38 | + inviteTeamMemberPath, |
| 39 | + organizationTeamPath, |
| 40 | + v3BillingPath, |
| 41 | +} from "~/utils/pathBuilder"; |
| 42 | +import { PurchaseSeatsModal } from "../_app.orgs.$organizationSlug.settings.team/route"; |
32 | 43 |
|
33 | 44 | const Params = z.object({ |
34 | 45 | organizationSlug: z.string(), |
@@ -122,7 +133,8 @@ export const action: ActionFunction = async ({ request, params }) => { |
122 | 133 | }; |
123 | 134 |
|
124 | 135 | export default function Page() { |
125 | | - const { limits } = useTypedLoaderData<typeof loader>(); |
| 136 | + const { limits, canPurchaseSeats, seatPricing, extraSeats, maxSeatQuota, planSeatLimit } = |
| 137 | + useTypedLoaderData<typeof loader>(); |
126 | 138 | const [total, setTotal] = useState(limits.used); |
127 | 139 | const organization = useOrganization(); |
128 | 140 | const lastSubmission = useActionData(); |
@@ -150,25 +162,55 @@ export default function Page() { |
150 | 162 | title="Invite team members" |
151 | 163 | description={`Invite new team members to ${organization.title}.`} |
152 | 164 | /> |
153 | | - {total > limits.limit && ( |
154 | | - <InfoPanel |
155 | | - variant="upgrade" |
156 | | - icon={LockOpenIcon} |
157 | | - iconClassName="text-indigo-500" |
158 | | - title="Unlock more team members" |
159 | | - accessory={ |
160 | | - <LinkButton to={v3BillingPath(organization)} variant="secondary/small"> |
161 | | - Upgrade |
162 | | - </LinkButton> |
163 | | - } |
164 | | - panelClassName="mb-4" |
165 | | - > |
166 | | - <Paragraph variant="small"> |
167 | | - You've used all {limits.limit} of your available team members. Upgrade your plan to |
168 | | - add more. |
169 | | - </Paragraph> |
170 | | - </InfoPanel> |
171 | | - )} |
| 165 | + {total > limits.limit && |
| 166 | + (canPurchaseSeats && seatPricing ? ( |
| 167 | + <InfoPanel |
| 168 | + variant="upgrade" |
| 169 | + icon={LockOpenIcon} |
| 170 | + iconClassName="text-indigo-500" |
| 171 | + title="Need more seats?" |
| 172 | + accessory={ |
| 173 | + <PurchaseSeatsModal |
| 174 | + seatPricing={seatPricing} |
| 175 | + extraSeats={extraSeats} |
| 176 | + usedSeats={limits.used} |
| 177 | + maxQuota={maxSeatQuota} |
| 178 | + planSeatLimit={planSeatLimit} |
| 179 | + triggerButton={<Button variant="primary/small">Purchase more seats…</Button>} |
| 180 | + redirectTo={inviteTeamMemberPath(organization)} |
| 181 | + /> |
| 182 | + } |
| 183 | + panelClassName="mb-4" |
| 184 | + > |
| 185 | + <Paragraph variant="small"> |
| 186 | + You've used all {limits.limit} of your available team members. Purchase extra seats |
| 187 | + to add more. |
| 188 | + </Paragraph> |
| 189 | + </InfoPanel> |
| 190 | + ) : ( |
| 191 | + <InfoPanel |
| 192 | + variant="upgrade" |
| 193 | + icon={LockOpenIcon} |
| 194 | + iconClassName="text-indigo-500" |
| 195 | + title="Unlock more team members" |
| 196 | + accessory={ |
| 197 | + <LinkButton |
| 198 | + to={v3BillingPath(organization)} |
| 199 | + variant="secondary/small" |
| 200 | + LeadingIcon={ArrowUpCircleIcon} |
| 201 | + leadingIconClassName="text-indigo-500" |
| 202 | + > |
| 203 | + Upgrade |
| 204 | + </LinkButton> |
| 205 | + } |
| 206 | + panelClassName="mb-4" |
| 207 | + > |
| 208 | + <Paragraph variant="small"> |
| 209 | + You've used all {limits.limit} of your available team members. Upgrade your plan to |
| 210 | + add more. |
| 211 | + </Paragraph> |
| 212 | + </InfoPanel> |
| 213 | + ))} |
172 | 214 | <Form method="post" {...form.props}> |
173 | 215 | <Fieldset> |
174 | 216 | <InputGroup> |
|
0 commit comments