-
-
Notifications
You must be signed in to change notification settings - Fork 225
filter occupation #1979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
filter occupation #1979
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
mcpjam-inspector/client/src/components/signup/OccupationGate.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| import { FormEvent, useState } from "react"; | ||
| import { useMutation } from "convex/react"; | ||
| import { usePostHog } from "posthog-js/react"; | ||
| import { ArrowRight, Check, Loader2 } from "lucide-react"; | ||
| import { Button } from "@mcpjam/design-system/button"; | ||
| import { Input } from "@mcpjam/design-system/input"; | ||
| import { standardEventProps } from "@/lib/PosthogUtils"; | ||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| const OCCUPATION_SUGGESTIONS = [ | ||
| "Software Engineer", | ||
| "Product Manager", | ||
| "Engineering Manager", | ||
| "Platform Engineer", | ||
| "Other", | ||
| ]; | ||
|
|
||
| interface OccupationGateProps { | ||
| userId?: string | null; | ||
| email?: string | null; | ||
| } | ||
|
|
||
| export function OccupationGate({ userId, email }: OccupationGateProps) { | ||
| const posthog = usePostHog(); | ||
| const updateOccupation = useMutation("users:updateOccupation" as any); | ||
| const [occupation, setOccupation] = useState(""); | ||
| const [error, setError] = useState<string | null>(null); | ||
| const [isSubmitting, setIsSubmitting] = useState(false); | ||
|
|
||
| const trimmedOccupation = occupation.trim(); | ||
| const canSubmit = trimmedOccupation.length > 0 && !isSubmitting; | ||
|
|
||
| const handleSubmit = async (event: FormEvent<HTMLFormElement>) => { | ||
| event.preventDefault(); | ||
| if (!trimmedOccupation) { | ||
| setError("Enter your role to continue."); | ||
| return; | ||
| } | ||
|
|
||
| setIsSubmitting(true); | ||
| setError(null); | ||
|
|
||
| try { | ||
| await updateOccupation({ occupation: trimmedOccupation }); | ||
| posthog.setPersonProperties({ occupation: trimmedOccupation }); | ||
| posthog.capture("signup_occupation_submitted", { | ||
| ...standardEventProps("signup_occupation_gate"), | ||
| occupation: trimmedOccupation, | ||
| }); | ||
| posthog.register({ occupation: trimmedOccupation }); | ||
| } catch (err) { | ||
| console.error("[signup] Failed to save occupation", err); | ||
| setError("Could not save your occupation. Please try again."); | ||
| } finally { | ||
| setIsSubmitting(false); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <main className="min-h-screen bg-background text-foreground"> | ||
| <div className="mx-auto flex min-h-screen w-full max-w-lg flex-col justify-center px-6 py-12"> | ||
| <div className="mb-10"> | ||
| <img src="/mcp_jam.svg" alt="MCPJam" className="mb-8 h-9 w-auto" /> | ||
| <h1 className="text-3xl font-semibold tracking-normal"> | ||
| What is your role? | ||
| </h1> | ||
| <p className="mt-3 text-sm text-muted-foreground"> | ||
| This helps us understand who is using MCPJam. | ||
| </p> | ||
| </div> | ||
|
|
||
| <form onSubmit={handleSubmit}> | ||
| <Input | ||
| value={occupation} | ||
| onChange={(event) => { | ||
| setOccupation(event.target.value); | ||
| if (error) setError(null); | ||
| }} | ||
| placeholder="Type your role" | ||
| autoComplete="organization-title" | ||
| className="mb-4 h-11 text-base md:text-sm" | ||
| autoFocus | ||
| /> | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| <p className="mb-3 text-xs font-semibold uppercase tracking-widest text-muted-foreground"> | ||
| Suggestions | ||
| </p> | ||
|
|
||
| <div className="flex flex-wrap gap-2"> | ||
| {OCCUPATION_SUGGESTIONS.map((suggestion) => { | ||
| const isSelected = | ||
| occupation.trim().toLowerCase() === suggestion.toLowerCase(); | ||
| return ( | ||
| <button | ||
| key={suggestion} | ||
| type="button" | ||
| onClick={() => { | ||
| setOccupation(suggestion); | ||
| if (error) setError(null); | ||
| }} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| className={cn( | ||
| "flex items-center gap-1.5 rounded-full border px-4 py-2 text-sm font-medium transition-all duration-150", | ||
| isSelected | ||
| ? "border-primary bg-primary text-primary-foreground shadow-sm" | ||
| : "border-border bg-background text-foreground hover:-translate-y-px hover:border-primary hover:bg-primary hover:text-primary-foreground hover:shadow-md", | ||
| )} | ||
| > | ||
| {isSelected && <Check className="h-3.5 w-3.5" />} | ||
| {suggestion} | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
|
|
||
| {error ? ( | ||
| <p className="mt-3 text-sm text-destructive">{error}</p> | ||
| ) : null} | ||
|
|
||
| <hr className="my-6 border-border" /> | ||
|
|
||
| <Button type="submit" disabled={!canSubmit} className="w-full"> | ||
| {isSubmitting ? ( | ||
| <Loader2 className="h-4 w-4 animate-spin" /> | ||
| ) : ( | ||
| <ArrowRight className="h-4 w-4" /> | ||
| )} | ||
| Continue | ||
| </Button> | ||
| </form> | ||
|
|
||
| {email ? ( | ||
| <p className="mt-6 text-xs text-muted-foreground"> | ||
| Signed in as {email} | ||
| </p> | ||
| ) : userId ? ( | ||
| <p className="mt-6 text-xs text-muted-foreground"> | ||
| Signed in to MCPJam | ||
| </p> | ||
| ) : null} | ||
| </div> | ||
| </main> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.