Skip to content

Commit f719b5e

Browse files
committed
Added freeplay quick action
1 parent f4ca06f commit f719b5e

File tree

3 files changed

+77
-16
lines changed

3 files changed

+77
-16
lines changed

src/dashboard/components/AdminWelcome.tsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import { Box, Container, Grid, Typography } from "@mui/material";
3-
import { Image, Language, VolunteerActivism, MusicNote, Person, Groups, LiveTv, Lock, CameraAlt } from "@mui/icons-material";
3+
import { Image, Language, VolunteerActivism, MusicNote, Person, Groups, LiveTv, Lock, CameraAlt, SmartDisplay } from "@mui/icons-material";
44
import { ApiHelper, UserHelper } from "@churchapps/apphelper";
55
import { PageHeader } from "@churchapps/apphelper";
66
import { FeatureCard } from "./FeatureCard";
@@ -16,11 +16,13 @@ export const AdminWelcome: React.FC = () => {
1616
const [hasTeams, setHasTeams] = React.useState<boolean | null>(null);
1717
const [hasPages, setHasPages] = React.useState<boolean | null>(null);
1818
const [hasGroups, setHasGroups] = React.useState<boolean | null>(null);
19+
const [hasPlanTypes, setHasPlanTypes] = React.useState<boolean | null>(null);
1920

2021
React.useEffect(() => {
2122
ApiHelper.get("/groups/tag/team", "MembershipApi").then((data) => setHasTeams(data?.length > 0)).catch(() => setHasTeams(false));
2223
ApiHelper.get("/pages", "ContentApi").then((data) => setHasPages(data?.length > 0)).catch(() => setHasPages(false));
2324
ApiHelper.get("/groups/tag/standard", "MembershipApi").then((data) => setHasGroups(data?.length > 0)).catch(() => setHasGroups(false));
25+
ApiHelper.get("/planTypes", "DoingApi").then((data) => setHasPlanTypes(data?.length > 0)).catch(() => setHasPlanTypes(false));
2426
}, []);
2527

2628
const handleCardClick = (wizardKey: WizardType, existsAlready: boolean | null, fallbackUrl: string) => {
@@ -47,33 +49,49 @@ export const AdminWelcome: React.FC = () => {
4749
<Typography variant="body1" color="text.secondary" sx={{ mb: 3 }}>
4850
Click any card below to get started. You can always find these in the menu later.
4951
</Typography>
50-
<Grid container spacing={3}>
52+
<Typography variant="subtitle1" sx={{ fontWeight: 700, mb: 1.5 }}>Your Church</Typography>
53+
<Grid container spacing={2} sx={{ mb: 3 }}>
5154
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
52-
<FeatureCard icon={<Image fontSize="large" />} title="Add Your Church Logo" description="Upload your logo and update your church's contact information so everything looks right from day one." linkUrl="/site/appearance#logo" />
55+
<FeatureCard icon={<Image fontSize="small" />} title="Add Your Church Logo" description="Upload your logo and update your church's contact information." linkUrl="/site/appearance#logo" />
5356
</Grid>
5457
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
55-
<FeatureCard icon={<Language fontSize="large" />} title="Create Your First Webpage" description="Build a public website for your church where visitors can learn about you and find service times." onClick={() => handleCardClick("webpage", hasPages, "/site/pages")} />
58+
<FeatureCard icon={<Language fontSize="small" />} title="Create Your First Webpage" description="Build a public website where visitors can learn about you." onClick={() => handleCardClick("webpage", hasPages, "/site/pages")} />
5659
</Grid>
5760
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
58-
<FeatureCard icon={<VolunteerActivism fontSize="large" />} title="Set Up Online Giving" description="Connect your Stripe account so your congregation can give online through your website and app." linkUrl="/settings#giving" />
61+
<FeatureCard icon={<VolunteerActivism fontSize="small" />} title="Set Up Online Giving" description="Connect Stripe so your congregation can give online." linkUrl="/settings#giving" />
62+
</Grid>
63+
</Grid>
64+
65+
<Typography variant="subtitle1" sx={{ fontWeight: 700, mb: 1.5 }}>Serving & Content</Typography>
66+
<Grid container spacing={2} sx={{ mb: 3 }}>
67+
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
68+
<FeatureCard icon={<MusicNote fontSize="small" />} title="Set Up FreeShow Backups" description="Connect FreeShow to back up your songs and service plans." onClick={() => handleCardClick("freeshow", hasTeams, "/serving")} />
5969
</Grid>
6070
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
61-
<FeatureCard icon={<MusicNote fontSize="large" />} title="Set Up FreeShow Backups" description="If you use FreeShow for presentations, connect it to B1.church to back up your songs and service plans." onClick={() => handleCardClick("freeshow", hasTeams, "/serving")} />
71+
<FeatureCard icon={<SmartDisplay fontSize="small" />} title="Set Up Your FreePlay Classroom" description="Create a ministry and classroom for FreePlay lessons on your TV." onClick={() => handleCardClick("freeplay", hasPlanTypes, "/serving")} />
6272
</Grid>
6373
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
64-
<FeatureCard icon={<Person fontSize="large" />} title="Add Your Congregation" description="Import or manually add the people in your church so you can track attendance, groups, and giving." linkUrl="/people" />
74+
<FeatureCard icon={<LiveTv fontSize="small" />} title="Upload a Sermon" description="Share your sermons online so people can watch anytime." linkUrl="/sermons" />
6575
</Grid>
76+
</Grid>
77+
78+
<Typography variant="subtitle1" sx={{ fontWeight: 700, mb: 1.5 }}>People & Groups</Typography>
79+
<Grid container spacing={2} sx={{ mb: 3 }}>
6680
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
67-
<FeatureCard icon={<Groups fontSize="large" />} title="Create Your First Group" description="Set up small groups, classes, or serving teams so people can connect and get involved." onClick={() => handleCardClick("group", hasGroups, "/groups")} />
81+
<FeatureCard icon={<Person fontSize="small" />} title="Add Your Congregation" description="Import or add your people to track attendance, groups, and giving." linkUrl="/people" />
6882
</Grid>
6983
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
70-
<FeatureCard icon={<LiveTv fontSize="large" />} title="Upload a Sermon" description="Share your sermons online so members and visitors can watch or listen anytime." linkUrl="/sermons" />
84+
<FeatureCard icon={<Groups fontSize="small" />} title="Create Your First Group" description="Set up small groups, classes, or serving teams." onClick={() => handleCardClick("group", hasGroups, "/groups")} />
7185
</Grid>
7286
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
73-
<FeatureCard icon={<Lock fontSize="large" />} title="Invite Team Members" description="Add staff and volunteers as admins so they can help manage people, groups, and content." linkUrl="/settings#roles" />
87+
<FeatureCard icon={<Lock fontSize="small" />} title="Invite Team Members" description="Add staff and volunteers as admins to help manage things." linkUrl="/settings#roles" />
7488
</Grid>
89+
</Grid>
90+
91+
<Typography variant="subtitle1" sx={{ fontWeight: 700, mb: 1.5 }}>Your Profile</Typography>
92+
<Grid container spacing={2}>
7593
<Grid size={{ xs: 12, sm: 6, md: 4 }}>
76-
<FeatureCard icon={<CameraAlt fontSize="large" />} title="Set Your Avatar" description="Upload a profile photo so your team and congregation can recognize you." linkUrl={b1Url + "/my/community?id=" + UserHelper.person?.id + "#edit"} external />
94+
<FeatureCard icon={<CameraAlt fontSize="small" />} title="Set Your Avatar" description="Upload a profile photo so your team can recognize you." linkUrl={b1Url + "/my/community?id=" + UserHelper.person?.id + "#edit"} external />
7795
</Grid>
7896
</Grid>
7997
</Box>

src/dashboard/components/FeatureCard.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ export const FeatureCard: React.FC<Props> = ({ icon, title, description, linkUrl
2626

2727
return (
2828
<Card variant="outlined" sx={{ height: "100%" }}>
29-
<CardActionArea onClick={handleClick} sx={{ p: 3, height: "100%", display: "flex", flexDirection: "column", alignItems: "flex-start", justifyContent: "flex-start" }}>
30-
<Box sx={{ color: "var(--c1)", mb: 2, display: "flex", alignItems: "center", justifyContent: "center", width: 48, height: 48, borderRadius: 2, backgroundColor: "rgba(var(--c1-rgb, 0,0,0), 0.08)" }}>
29+
<CardActionArea onClick={handleClick} sx={{ p: 2, height: "100%", display: "flex", alignItems: "flex-start" }}>
30+
<Box sx={{ color: "var(--c1)", mr: 2, display: "flex", alignItems: "center", justifyContent: "center", width: 36, height: 36, borderRadius: 1.5, backgroundColor: "rgba(var(--c1-rgb, 0,0,0), 0.08)", flexShrink: 0 }}>
3131
{icon}
3232
</Box>
33-
<Typography variant="h6" sx={{ mb: 0.5 }}>{title}</Typography>
34-
<Typography variant="body2" color="text.secondary">{description}</Typography>
33+
<Box>
34+
<Typography variant="subtitle2" sx={{ fontWeight: 600, lineHeight: 1.3 }}>{title}</Typography>
35+
<Typography variant="caption" color="text.secondary" sx={{ lineHeight: 1.4 }}>{description}</Typography>
36+
</Box>
3537
</CardActionArea>
3638
</Card>
3739
);

src/dashboard/components/QuickSetupModal.tsx

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ApiHelper } from "@churchapps/apphelper";
44
import { type GroupInterface, type GroupMemberInterface } from "@churchapps/helpers";
55
import UserContext from "../../UserContext";
66

7-
export type WizardType = "freeshow" | "webpage" | "group";
7+
export type WizardType = "freeshow" | "freeplay" | "webpage" | "group";
88

99
interface Props {
1010
wizardType: WizardType;
@@ -18,6 +18,10 @@ const wizardConfig: Record<WizardType, { title: string; description: string }> =
1818
title: "Set Up FreeShow Backups",
1919
description: "To back up your FreeShow data, we need to create a ministry and a team. You'll then be redirected to add team members."
2020
},
21+
freeplay: {
22+
title: "Set Up Your FreePlay Classroom",
23+
description: "To get started with FreePlay, we need to create a ministry and a classroom. You'll then be redirected to pair a content provider."
24+
},
2125
webpage: {
2226
title: "Create Your First Webpage",
2327
description: "Enter a title for your first page. You'll be redirected to the page editor to add content."
@@ -40,6 +44,9 @@ export const QuickSetupModal: React.FC<Props> = ({ wizardType, open, onClose, on
4044
// Webpage field
4145
const [pageTitle, setPageTitle] = React.useState("Home");
4246

47+
// FreePlay fields
48+
const [classroomName, setClassroomName] = React.useState("");
49+
4350
// Group field
4451
const [groupName, setGroupName] = React.useState("");
4552

@@ -53,6 +60,9 @@ export const QuickSetupModal: React.FC<Props> = ({ wizardType, open, onClose, on
5360
case "freeshow":
5461
await handleFreeshowSetup();
5562
break;
63+
case "freeplay":
64+
await handleFreeplaySetup();
65+
break;
5666
case "webpage":
5767
await handleWebpageSetup();
5868
break;
@@ -97,6 +107,30 @@ export const QuickSetupModal: React.FC<Props> = ({ wizardType, open, onClose, on
97107
onComplete(`/groups/${teamResult[0].id}`);
98108
};
99109

110+
const handleFreeplaySetup = async () => {
111+
if (!ministryName.trim() || !classroomName.trim()) {
112+
setError("Please enter both a ministry name and a classroom name.");
113+
return;
114+
}
115+
116+
// Create ministry
117+
const ministry: GroupInterface = { name: ministryName.trim(), tags: "ministry", categoryName: "Ministry" };
118+
const ministryResult = await ApiHelper.post("/groups", [ministry], "MembershipApi");
119+
const ministryId = ministryResult[0].id;
120+
121+
// Auto-add creator as ministry member
122+
if (context?.person?.id) {
123+
const member: GroupMemberInterface = { groupId: ministryId, personId: context.person.id };
124+
await ApiHelper.post("/groupMembers", [member], "MembershipApi");
125+
}
126+
127+
// Create planType (classroom) under ministry
128+
const planType = { name: classroomName.trim(), ministryId };
129+
await ApiHelper.post("/planTypes", [planType], "DoingApi");
130+
131+
onComplete("/serving");
132+
};
133+
100134
const handleWebpageSetup = async () => {
101135
if (!pageTitle.trim()) {
102136
setError("Please enter a page title.");
@@ -138,6 +172,13 @@ export const QuickSetupModal: React.FC<Props> = ({ wizardType, open, onClose, on
138172
</Stack>
139173
)}
140174

175+
{wizardType === "freeplay" && (
176+
<Stack spacing={2}>
177+
<TextField label="Ministry Name" value={ministryName} onChange={(e) => setMinistryName(e.target.value)} fullWidth autoFocus />
178+
<TextField label="Classroom Name" value={classroomName} onChange={(e) => setClassroomName(e.target.value)} fullWidth />
179+
</Stack>
180+
)}
181+
141182
{wizardType === "webpage" && (
142183
<TextField label="Page Title" value={pageTitle} onChange={(e) => setPageTitle(e.target.value)} fullWidth autoFocus />
143184
)}

0 commit comments

Comments
 (0)