@salesforce/webapp-template-app-react-vibe-coding-starter-experimental 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +82 -0
- package/dist/.a4drules/build-validation.md +81 -0
- package/dist/.a4drules/code-quality.md +150 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-explore-graphql-schema.md +227 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-mutationquery.md +211 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-readquery.md +185 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +205 -0
- package/dist/.a4drules/graphql/tools/schemas/shared.graphqls +1150 -0
- package/dist/.a4drules/graphql.md +98 -0
- package/dist/.a4drules/images.md +13 -0
- package/dist/.a4drules/react.md +361 -0
- package/dist/.a4drules/react_image_processing.md +45 -0
- package/dist/.a4drules/typescript.md +224 -0
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/CHANGELOG.md +11 -0
- package/dist/README.md +18 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/force-app/main/default/digitalExperienceConfigs/appreactvibecodingstarter1.digitalExperienceConfig +8 -0
- package/dist/force-app/main/default/digitalExperiences/site/appreactvibecodingstarter1/appreactvibecodingstarter1.digitalExperience-meta.xml +11 -0
- package/dist/force-app/main/default/digitalExperiences/site/appreactvibecodingstarter1/sfdc_cms__site/appreactvibecodingstarter1/_meta.json +5 -0
- package/dist/force-app/main/default/digitalExperiences/site/appreactvibecodingstarter1/sfdc_cms__site/appreactvibecodingstarter1/content.json +10 -0
- package/dist/force-app/main/default/networks/appreactvibecodingstarter.network +60 -0
- package/dist/force-app/main/default/package.xml +20 -0
- package/dist/force-app/main/default/sites/appreactvibecodingstarter.site +31 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/.prettierignore +9 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/.prettierrc +11 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/appreactvibecodingstarter.webapplication-meta.xml +7 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/eslint.config.js +113 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/index.html +13 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/package.json +42 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/api/graphql-operations-types.ts +127 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/api/utils/query/highRevenueAccountsQuery.graphql +29 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/app.tsx +16 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/appLayout.tsx +9 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/assets/icons/book.svg +3 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/assets/icons/copy.svg +4 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/assets/icons/rocket.svg +3 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/assets/icons/star.svg +3 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/assets/images/vibe-codey.svg +194 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/AccountsTable.tsx +134 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/Footer.test.tsx +35 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/Footer.tsx +68 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/Hero.test.tsx +44 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/Hero.tsx +61 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/PromptCard.test.tsx +57 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/PromptCard.tsx +301 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/PromptHighlight.test.tsx +85 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/PromptHighlight.tsx +73 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/alerts/status-alert.tsx +45 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/auth/authentication-route.tsx +21 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/auth/private-route.tsx +36 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/footers/footer-link.tsx +36 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/forms/auth-form.tsx +79 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/forms/submit-button.tsx +49 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/layout/card-layout.tsx +23 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/layout/centered-page-layout.tsx +73 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/layout/loading-page.tsx +46 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/alert.tsx +65 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/button.tsx +56 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/card.tsx +77 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/field.tsx +111 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/index.ts +71 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/input.tsx +19 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/label.tsx +19 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/pagination.tsx +99 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/select.tsx +151 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/skeleton.tsx +7 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/spinner.tsx +21 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/table.tsx +114 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/components/ui/tabs.tsx +115 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/context/AuthContext.tsx +83 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/hooks/form.tsx +116 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/index.tsx +229 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/pages/ChangePassword.tsx +105 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/pages/ForgotPassword.tsx +67 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/pages/Home.tsx +12 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/pages/Login.tsx +84 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/pages/NotFound.tsx +18 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/pages/Profile.tsx +146 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/pages/Register.tsx +117 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/pages/ResetPassword.tsx +101 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/routes.tsx +71 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/styles/global.css +270 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/testCmp.tsx +9 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/utils/authenticationConfig.ts +52 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/utils/helpers.ts +161 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/tsconfig.json +36 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/vite-env.d.ts +1 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/vite.config.ts +82 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/vitest-env.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/vitest.config.ts +11 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/vitest.setup.ts +1 -0
- package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/webapplication.json +7 -0
- package/dist/jest.config.js +6 -0
- package/dist/package.json +37 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +34 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shadcn-style Table components
|
|
6
|
+
* These components follow shadcn/ui patterns for consistent styling
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
|
|
10
|
+
({ className, ...props }, ref) => (
|
|
11
|
+
<div className="relative w-full overflow-auto">
|
|
12
|
+
<table ref={ref} className={cn("w-full caption-bottom text-sm", className)} {...props} />
|
|
13
|
+
</div>
|
|
14
|
+
),
|
|
15
|
+
);
|
|
16
|
+
Table.displayName = "Table";
|
|
17
|
+
|
|
18
|
+
const TableHeader = React.forwardRef<
|
|
19
|
+
HTMLTableSectionElement,
|
|
20
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
21
|
+
>(({ className, ...props }, ref) => (
|
|
22
|
+
<thead
|
|
23
|
+
ref={ref}
|
|
24
|
+
className={cn(
|
|
25
|
+
// 1. Existing border style
|
|
26
|
+
"[&_tr]:border-b",
|
|
27
|
+
|
|
28
|
+
// 2. Make headers sticky
|
|
29
|
+
// We apply this to the 'th' children using the [&_th] selector
|
|
30
|
+
// This is often more robust across browsers than applying sticky to the <thead> itself
|
|
31
|
+
"[&_th]:sticky [&_th]:top-0 [&_th]:z-10",
|
|
32
|
+
// 3. CRITICAL: Add background color
|
|
33
|
+
// Without this, content scrolls "under" the transparent text
|
|
34
|
+
"[&_th]:bg-background",
|
|
35
|
+
|
|
36
|
+
// 4. Optional: Add a subtle shadow for better visual separation when scrolling
|
|
37
|
+
"[&_th]:shadow-[0_1px_0_0_theme(colors.border)]",
|
|
38
|
+
className,
|
|
39
|
+
)}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
));
|
|
43
|
+
TableHeader.displayName = "TableHeader";
|
|
44
|
+
|
|
45
|
+
const TableBody = React.forwardRef<
|
|
46
|
+
HTMLTableSectionElement,
|
|
47
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
48
|
+
>(({ className, ...props }, ref) => (
|
|
49
|
+
<tbody ref={ref} className={cn("[&_tr:last-child]:border-0", className)} {...props} />
|
|
50
|
+
));
|
|
51
|
+
TableBody.displayName = "TableBody";
|
|
52
|
+
|
|
53
|
+
const TableFooter = React.forwardRef<
|
|
54
|
+
HTMLTableSectionElement,
|
|
55
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
56
|
+
>(({ className, ...props }, ref) => (
|
|
57
|
+
<tfoot
|
|
58
|
+
ref={ref}
|
|
59
|
+
className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
));
|
|
63
|
+
TableFooter.displayName = "TableFooter";
|
|
64
|
+
|
|
65
|
+
const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(
|
|
66
|
+
({ className, ...props }, ref) => (
|
|
67
|
+
<tr
|
|
68
|
+
ref={ref}
|
|
69
|
+
className={cn(
|
|
70
|
+
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
71
|
+
className,
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
TableRow.displayName = "TableRow";
|
|
78
|
+
|
|
79
|
+
const TableHead = React.forwardRef<
|
|
80
|
+
HTMLTableCellElement,
|
|
81
|
+
React.ThHTMLAttributes<HTMLTableCellElement>
|
|
82
|
+
>(({ className, ...props }, ref) => (
|
|
83
|
+
<th
|
|
84
|
+
ref={ref}
|
|
85
|
+
className={cn(
|
|
86
|
+
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
87
|
+
className,
|
|
88
|
+
)}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
));
|
|
92
|
+
TableHead.displayName = "TableHead";
|
|
93
|
+
|
|
94
|
+
const TableCell = React.forwardRef<
|
|
95
|
+
HTMLTableCellElement,
|
|
96
|
+
React.TdHTMLAttributes<HTMLTableCellElement>
|
|
97
|
+
>(({ className, ...props }, ref) => (
|
|
98
|
+
<td
|
|
99
|
+
ref={ref}
|
|
100
|
+
className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
));
|
|
104
|
+
TableCell.displayName = "TableCell";
|
|
105
|
+
|
|
106
|
+
const TableCaption = React.forwardRef<
|
|
107
|
+
HTMLTableCaptionElement,
|
|
108
|
+
React.HTMLAttributes<HTMLTableCaptionElement>
|
|
109
|
+
>(({ className, ...props }, ref) => (
|
|
110
|
+
<caption ref={ref} className={cn("mt-4 text-sm text-muted-foreground", className)} {...props} />
|
|
111
|
+
));
|
|
112
|
+
TableCaption.displayName = "TableCaption";
|
|
113
|
+
|
|
114
|
+
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
|
|
4
|
+
interface TabsContextValue {
|
|
5
|
+
value: string;
|
|
6
|
+
onValueChange: (value: string) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const TabsContext = React.createContext<TabsContextValue | undefined>(undefined);
|
|
10
|
+
|
|
11
|
+
interface TabsProps extends React.ComponentProps<"div"> {
|
|
12
|
+
value?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function Tabs({ value, defaultValue, onValueChange, className, children, ...props }: TabsProps) {
|
|
18
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue || "");
|
|
19
|
+
const controlled = value !== undefined;
|
|
20
|
+
const currentValue = controlled ? value : internalValue;
|
|
21
|
+
|
|
22
|
+
const handleValueChange = React.useCallback(
|
|
23
|
+
(newValue: string) => {
|
|
24
|
+
if (!controlled) {
|
|
25
|
+
setInternalValue(newValue);
|
|
26
|
+
}
|
|
27
|
+
onValueChange?.(newValue);
|
|
28
|
+
},
|
|
29
|
+
[controlled, onValueChange],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<TabsContext.Provider value={{ value: currentValue, onValueChange: handleValueChange }}>
|
|
34
|
+
<div data-slot="tabs" className={cn("w-full", className)} {...props}>
|
|
35
|
+
{children}
|
|
36
|
+
</div>
|
|
37
|
+
</TabsContext.Provider>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function useTabsContext() {
|
|
42
|
+
const context = React.useContext(TabsContext);
|
|
43
|
+
if (!context) {
|
|
44
|
+
throw new Error("Tabs components must be used within a Tabs component");
|
|
45
|
+
}
|
|
46
|
+
return context;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function TabsList({ className, ...props }: React.ComponentProps<"div">) {
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
data-slot="tabs-list"
|
|
53
|
+
className={cn(
|
|
54
|
+
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
|
55
|
+
className,
|
|
56
|
+
)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface TabsTriggerProps extends React.ComponentProps<"button"> {
|
|
63
|
+
value: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function TabsTrigger({ className, value, ...props }: TabsTriggerProps) {
|
|
67
|
+
const { value: selectedValue, onValueChange } = useTabsContext();
|
|
68
|
+
const isSelected = selectedValue === value;
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<button
|
|
72
|
+
data-slot="tabs-trigger"
|
|
73
|
+
data-selected={isSelected}
|
|
74
|
+
type="button"
|
|
75
|
+
role="tab"
|
|
76
|
+
aria-selected={isSelected}
|
|
77
|
+
className={cn(
|
|
78
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
79
|
+
isSelected
|
|
80
|
+
? "bg-background text-foreground shadow-sm"
|
|
81
|
+
: "text-muted-foreground hover:bg-background/50",
|
|
82
|
+
className,
|
|
83
|
+
)}
|
|
84
|
+
onClick={() => onValueChange(value)}
|
|
85
|
+
{...props}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface TabsContentProps extends React.ComponentProps<"div"> {
|
|
91
|
+
value: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function TabsContent({ className, value, children, ...props }: TabsContentProps) {
|
|
95
|
+
const { value: selectedValue } = useTabsContext();
|
|
96
|
+
if (selectedValue !== value) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div
|
|
102
|
+
data-slot="tabs-content"
|
|
103
|
+
role="tabpanel"
|
|
104
|
+
className={cn(
|
|
105
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
106
|
+
className,
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
>
|
|
110
|
+
{children}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createContext, useContext, useState, useEffect, useCallback, type ReactNode } from "react";
|
|
2
|
+
import { getCurrentUser } from "@salesforce/webapp-experimental/api";
|
|
3
|
+
|
|
4
|
+
interface User {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface AuthContextType {
|
|
10
|
+
user: User | null;
|
|
11
|
+
isAuthenticated: boolean;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
error: string | null;
|
|
14
|
+
checkAuth: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
|
18
|
+
|
|
19
|
+
interface AuthProviderProps {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function AuthProvider({ children }: AuthProviderProps) {
|
|
24
|
+
const [user, setUser] = useState<User | null>(null);
|
|
25
|
+
const [loading, setLoading] = useState(true);
|
|
26
|
+
const [error, setError] = useState<string | null>(null);
|
|
27
|
+
|
|
28
|
+
const checkAuth = useCallback(async () => {
|
|
29
|
+
setLoading(true);
|
|
30
|
+
setError(null);
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const userData = await getCurrentUser();
|
|
34
|
+
setUser(userData);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
const errorMessage = err instanceof Error ? err.message : "Authentication failed";
|
|
37
|
+
setError(errorMessage);
|
|
38
|
+
setUser(null);
|
|
39
|
+
} finally {
|
|
40
|
+
setLoading(false);
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
checkAuth();
|
|
46
|
+
}, [checkAuth]);
|
|
47
|
+
|
|
48
|
+
const value: AuthContextType = {
|
|
49
|
+
user,
|
|
50
|
+
isAuthenticated: user !== null,
|
|
51
|
+
loading,
|
|
52
|
+
error,
|
|
53
|
+
checkAuth,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Hook to access the authentication context.
|
|
61
|
+
* @returns {AuthContextType} Authentication state (user, isAuthenticated, loading, error, checkAuth)
|
|
62
|
+
* @throws {Error} If used outside of an AuthProvider
|
|
63
|
+
*/
|
|
64
|
+
export function useAuth(): AuthContextType {
|
|
65
|
+
const context = useContext(AuthContext);
|
|
66
|
+
if (context === undefined) {
|
|
67
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
68
|
+
}
|
|
69
|
+
return context;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Returns the current authenticated user.
|
|
74
|
+
* @returns {User} The authenticated user object
|
|
75
|
+
* @throws {Error} If not used within AuthProvider or user is not authenticated
|
|
76
|
+
*/
|
|
77
|
+
export function getUser(): User {
|
|
78
|
+
const context = useAuth();
|
|
79
|
+
if (!context.user) {
|
|
80
|
+
throw new Error("Authenticated context not established");
|
|
81
|
+
}
|
|
82
|
+
return context.user;
|
|
83
|
+
}
|
package/dist/force-app/main/default/webapplications/appreactvibecodingstarter/src/hooks/form.tsx
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useId } from "react";
|
|
2
|
+
import { createFormHookContexts, createFormHook } from "@tanstack/react-form";
|
|
3
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "../components/ui/field";
|
|
4
|
+
import { Input } from "../components/ui/input";
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
import { AUTH_PLACEHOLDERS } from "../utils/authenticationConfig";
|
|
7
|
+
|
|
8
|
+
// Create form hook contexts
|
|
9
|
+
export const { fieldContext, formContext, useFieldContext, useFormContext } =
|
|
10
|
+
createFormHookContexts();
|
|
11
|
+
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Field Components
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
interface TextFieldProps
|
|
17
|
+
extends Omit<
|
|
18
|
+
React.ComponentProps<typeof Input>,
|
|
19
|
+
"name" | "value" | "onBlur" | "onChange" | "aria-invalid"
|
|
20
|
+
> {
|
|
21
|
+
label: string;
|
|
22
|
+
labelAction?: React.ReactNode;
|
|
23
|
+
description?: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function TextField({
|
|
27
|
+
label,
|
|
28
|
+
id: providedId,
|
|
29
|
+
labelAction,
|
|
30
|
+
description,
|
|
31
|
+
type = "text",
|
|
32
|
+
...props
|
|
33
|
+
}: TextFieldProps) {
|
|
34
|
+
const field = useFieldContext<string>();
|
|
35
|
+
const generatedId = useId();
|
|
36
|
+
const id = providedId ?? generatedId;
|
|
37
|
+
const descriptionId = `${id}-description`;
|
|
38
|
+
const errorId = `${id}-error`;
|
|
39
|
+
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0;
|
|
40
|
+
|
|
41
|
+
// Deduplicate errors by message
|
|
42
|
+
const errors = field.state.meta.errors;
|
|
43
|
+
const uniqueErrors = [...new Map(errors.map((item: any) => [item["message"], item])).values()];
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Field data-invalid={isInvalid}>
|
|
47
|
+
<div className="flex items-center">
|
|
48
|
+
<FieldLabel htmlFor={id}>{label}</FieldLabel>
|
|
49
|
+
{labelAction && <div className="ml-auto">{labelAction}</div>}
|
|
50
|
+
</div>
|
|
51
|
+
{description && <FieldDescription id={descriptionId}>{description}</FieldDescription>}
|
|
52
|
+
<Input
|
|
53
|
+
id={id}
|
|
54
|
+
name={field.name as string}
|
|
55
|
+
type={type}
|
|
56
|
+
value={field.state.value ?? ""}
|
|
57
|
+
onBlur={field.handleBlur}
|
|
58
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => field.handleChange(e.target.value)}
|
|
59
|
+
aria-invalid={isInvalid}
|
|
60
|
+
aria-describedby={cn(description && descriptionId, isInvalid && errorId)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
{isInvalid && uniqueErrors.length > 0 && <FieldError errors={uniqueErrors} />}
|
|
64
|
+
</Field>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Password field with preset type and autocomplete */
|
|
69
|
+
function PasswordField({
|
|
70
|
+
label,
|
|
71
|
+
autoComplete = "current-password",
|
|
72
|
+
placeholder = AUTH_PLACEHOLDERS.PASSWORD,
|
|
73
|
+
...props
|
|
74
|
+
}: Omit<TextFieldProps, "type">) {
|
|
75
|
+
return (
|
|
76
|
+
<TextField
|
|
77
|
+
label={label}
|
|
78
|
+
type="password"
|
|
79
|
+
autoComplete={autoComplete}
|
|
80
|
+
placeholder={placeholder}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Email field with preset type and autocomplete */
|
|
87
|
+
function EmailField({
|
|
88
|
+
label,
|
|
89
|
+
placeholder = AUTH_PLACEHOLDERS.EMAIL,
|
|
90
|
+
...props
|
|
91
|
+
}: Omit<TextFieldProps, "type">) {
|
|
92
|
+
return (
|
|
93
|
+
<TextField
|
|
94
|
+
label={label}
|
|
95
|
+
type="email"
|
|
96
|
+
autoComplete="username"
|
|
97
|
+
placeholder={placeholder}
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ============================================================================
|
|
104
|
+
// Create Form Hook
|
|
105
|
+
// ============================================================================
|
|
106
|
+
|
|
107
|
+
export const { useAppForm } = createFormHook({
|
|
108
|
+
fieldContext,
|
|
109
|
+
formContext,
|
|
110
|
+
fieldComponents: {
|
|
111
|
+
TextField,
|
|
112
|
+
PasswordField,
|
|
113
|
+
EmailField,
|
|
114
|
+
},
|
|
115
|
+
formComponents: {},
|
|
116
|
+
});
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import codey1 from "@assets/images/codey-1.png";
|
|
3
|
+
import codey3 from "@assets/images/codey-3.png";
|
|
4
|
+
import AccountsTable from "@components/AccountsTable";
|
|
5
|
+
// import Footer from '@components/Footer';
|
|
6
|
+
import Hero from "@components/Hero";
|
|
7
|
+
import PromptCard from "@components/PromptCard";
|
|
8
|
+
import PromptHighlight from "@components/PromptHighlight";
|
|
9
|
+
import { getHighRevenueAccounts } from "@salesforce/webapp-experimental/api";
|
|
10
|
+
|
|
11
|
+
const styles: Record<string, React.CSSProperties> = {
|
|
12
|
+
container: {
|
|
13
|
+
position: "relative",
|
|
14
|
+
width: "100%",
|
|
15
|
+
minHeight: "100vh",
|
|
16
|
+
overflow: "hidden",
|
|
17
|
+
background: "linear-gradient(180deg, #EDF4FF 0%, #F6F2FB 50%, #E5B9FE 100%)",
|
|
18
|
+
},
|
|
19
|
+
content: {
|
|
20
|
+
position: "relative",
|
|
21
|
+
zIndex: 1,
|
|
22
|
+
width: "100%",
|
|
23
|
+
maxWidth: "1100px",
|
|
24
|
+
margin: "0 auto",
|
|
25
|
+
padding: "0 2rem",
|
|
26
|
+
},
|
|
27
|
+
agentforceText: {
|
|
28
|
+
background: "linear-gradient(135deg, #5867E8 0%, #E5B9FE 100%)",
|
|
29
|
+
WebkitBackgroundClip: "text",
|
|
30
|
+
WebkitTextFillColor: "transparent",
|
|
31
|
+
backgroundClip: "text",
|
|
32
|
+
},
|
|
33
|
+
newProjectLink: {
|
|
34
|
+
color: "var(--on-surface-3)",
|
|
35
|
+
textDecoration: "underline",
|
|
36
|
+
fontWeight: 500,
|
|
37
|
+
},
|
|
38
|
+
promptsSection: {
|
|
39
|
+
display: "flex",
|
|
40
|
+
flexDirection: "column",
|
|
41
|
+
gap: "100px",
|
|
42
|
+
paddingBottom: "4rem",
|
|
43
|
+
},
|
|
44
|
+
toast: {
|
|
45
|
+
position: "fixed" as const,
|
|
46
|
+
bottom: "2rem",
|
|
47
|
+
left: "50%",
|
|
48
|
+
transform: "translateX(-50%)",
|
|
49
|
+
background: "#c62828",
|
|
50
|
+
color: "white",
|
|
51
|
+
padding: "1rem 2rem",
|
|
52
|
+
borderRadius: "8px",
|
|
53
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
54
|
+
zIndex: 1000,
|
|
55
|
+
display: "flex",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
gap: "0.75rem",
|
|
58
|
+
animation: "slideUp 0.3s ease",
|
|
59
|
+
},
|
|
60
|
+
toastCloseButton: {
|
|
61
|
+
background: "transparent",
|
|
62
|
+
border: "none",
|
|
63
|
+
color: "white",
|
|
64
|
+
cursor: "pointer",
|
|
65
|
+
fontSize: "1.25rem",
|
|
66
|
+
padding: "0",
|
|
67
|
+
lineHeight: 1,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default function Home(): React.ReactElement {
|
|
72
|
+
const [toastMessage, setToastMessage] = useState<string | null>(null);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
async function fetchAccounts(): Promise<void> {
|
|
76
|
+
try {
|
|
77
|
+
await getHighRevenueAccounts({ minRevenue: 100000 });
|
|
78
|
+
} catch (error) {
|
|
79
|
+
setToastMessage("Data fetching failed.");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
void fetchAccounts();
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
const dismissToast = (): void => {
|
|
86
|
+
setToastMessage(null);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div style={styles.container}>
|
|
91
|
+
<div style={styles.content}>
|
|
92
|
+
<Hero
|
|
93
|
+
heading={
|
|
94
|
+
<>
|
|
95
|
+
Try Building React with <span style={styles.agentforceText}>Agentforce</span>
|
|
96
|
+
</>
|
|
97
|
+
}
|
|
98
|
+
subtext={
|
|
99
|
+
<>
|
|
100
|
+
Get started with the example prompts below or start fresh with a{" "}
|
|
101
|
+
<a href="#new-project" style={styles.newProjectLink}>
|
|
102
|
+
new project
|
|
103
|
+
</a>
|
|
104
|
+
</>
|
|
105
|
+
}
|
|
106
|
+
/>
|
|
107
|
+
|
|
108
|
+
<section style={styles.promptsSection}>
|
|
109
|
+
<PromptHighlight
|
|
110
|
+
image={codey1}
|
|
111
|
+
imageAlt="Dark Mode Example"
|
|
112
|
+
imagePosition="right"
|
|
113
|
+
imageSize="landscape"
|
|
114
|
+
>
|
|
115
|
+
<PromptCard
|
|
116
|
+
title="Create a Dark Mode"
|
|
117
|
+
description="Instantly add a Dark Mode switch that updates your app's background, text, and accent colors."
|
|
118
|
+
promptText="Add a Dark Mode to my app that updates background, text, and accent colors when toggled, with a smooth, polished animation for the transition.
|
|
119
|
+
|
|
120
|
+
### Dark Mode Toggle
|
|
121
|
+
|
|
122
|
+
A sliding switch should be placed in the top right of the index page. The switch should slide between sun and moon icons. When the moon icon is selected, Dark Mode should be displayed, and when the sun icon is selected, Light Mode (the current color scheme) should be selected.
|
|
123
|
+
|
|
124
|
+
### Colors
|
|
125
|
+
|
|
126
|
+
The word **Agentforce** in the heading is a gradient. The app's background is also a gradient. In Dark Mode these two gradients should complement each other, as they do in light mode. Also keep in mind the colors of the various SVG images on the page. These images need to look good in Dark mode.
|
|
127
|
+
|
|
128
|
+
Be sure to also change the footer background. Remember to change every component's foreground and background color to appropriately contrast with the Dark mode background."
|
|
129
|
+
/>
|
|
130
|
+
</PromptHighlight>
|
|
131
|
+
|
|
132
|
+
<PromptHighlight
|
|
133
|
+
image={
|
|
134
|
+
<div
|
|
135
|
+
style={{
|
|
136
|
+
background: "#c9cffd",
|
|
137
|
+
borderRadius: "20px",
|
|
138
|
+
padding: "20px",
|
|
139
|
+
width: "100%",
|
|
140
|
+
height: "100%",
|
|
141
|
+
display: "flex",
|
|
142
|
+
flexDirection: "column",
|
|
143
|
+
gap: "10px",
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<div
|
|
147
|
+
style={{
|
|
148
|
+
background: "rgba(255, 255, 255, 0.2)",
|
|
149
|
+
border: "1px dashed #f8f8f8",
|
|
150
|
+
borderRadius: "10px",
|
|
151
|
+
height: "277px",
|
|
152
|
+
width: "100%",
|
|
153
|
+
position: "relative",
|
|
154
|
+
overflow: "hidden",
|
|
155
|
+
boxShadow: "0px 4px 14px 0px rgba(0, 0, 0, 0.1)",
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
<AccountsTable />
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
}
|
|
162
|
+
imageAlt="Table with Salesforce data Example"
|
|
163
|
+
imagePosition="left"
|
|
164
|
+
imageSize="landscape"
|
|
165
|
+
>
|
|
166
|
+
<PromptCard
|
|
167
|
+
title="Create a table with real Salesforce data"
|
|
168
|
+
description="Pulling data into your React app from your org is seamless when using GraphQL. Send the prompt to the agent to see the magic happen."
|
|
169
|
+
promptText="Update the AccountsTable component to fetch and display all Account records from my Salesforce org using GraphQL.
|
|
170
|
+
|
|
171
|
+
### Requirements
|
|
172
|
+
|
|
173
|
+
1. Query the following fields for all Account records:
|
|
174
|
+
- Account Name
|
|
175
|
+
- Billing City
|
|
176
|
+
- Industry
|
|
177
|
+
- Annual Revenue
|
|
178
|
+
|
|
179
|
+
2. Display the data in a table with three columns matching those fields.
|
|
180
|
+
|
|
181
|
+
3. The table should use the existing table structure with:
|
|
182
|
+
- Purple header cells (#e5e3ff background)
|
|
183
|
+
- White data cells
|
|
184
|
+
- 1px borders between cells
|
|
185
|
+
- Proper styling to match the current design
|
|
186
|
+
|
|
187
|
+
4. Include loading, error, and empty states with appropriate messages.
|
|
188
|
+
|
|
189
|
+
5. Format the Annual Revenue as USD currency with no decimal places.
|
|
190
|
+
|
|
191
|
+
6. Limit the query to the first 20 accounts for performance.
|
|
192
|
+
|
|
193
|
+
7. Use the existing executeGraphQL utility function from @/api/graphql for the GraphQL query."
|
|
194
|
+
/>
|
|
195
|
+
</PromptHighlight>
|
|
196
|
+
|
|
197
|
+
<PromptHighlight
|
|
198
|
+
image={codey3}
|
|
199
|
+
imageAlt="Animations Example"
|
|
200
|
+
imagePosition="right"
|
|
201
|
+
imageSize="square"
|
|
202
|
+
>
|
|
203
|
+
<PromptCard
|
|
204
|
+
title="Add animations to give personality"
|
|
205
|
+
description="Bring your UI to life and give it personality with animations. Send the prompt to the agent to see the magic happen."
|
|
206
|
+
promptText="Animate the sections of this page to fly in from the sides on load. when you finish reload the page to show the animations"
|
|
207
|
+
/>
|
|
208
|
+
</PromptHighlight>
|
|
209
|
+
</section>
|
|
210
|
+
|
|
211
|
+
{/* <Footer /> */}
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
{/* Toast notification */}
|
|
215
|
+
{toastMessage && (
|
|
216
|
+
<div style={styles.toast}>
|
|
217
|
+
<span>{toastMessage}</span>
|
|
218
|
+
<button
|
|
219
|
+
style={styles.toastCloseButton}
|
|
220
|
+
onClick={dismissToast}
|
|
221
|
+
aria-label="Dismiss notification"
|
|
222
|
+
>
|
|
223
|
+
×
|
|
224
|
+
</button>
|
|
225
|
+
</div>
|
|
226
|
+
)}
|
|
227
|
+
</div>
|
|
228
|
+
);
|
|
229
|
+
}
|