-
Notifications
You must be signed in to change notification settings - Fork 4
Dis 186 settings plan upgrade frontend #228
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
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aa7e486
update/calendar-upgrade
ChloeXiao0409 0cfc8f5
update/company-info-upgrade
ChloeXiao0409 24b88e9
Update src/app/admin/settings/CompanyInfo.tsx
ChloeXiao0409 fd86478
Update src/app/admin/settings/CalendarIntegrations.tsx
ChloeXiao0409 be07ccd
update/resolve-unused
ChloeXiao0409 e8b3243
fix/type-check
ChloeXiao0409 640d886
fix/lint-1
ChloeXiao0409 66b3b9e
fix-handle-edit
ChloeXiao0409 7e88999
fix/info-lint
ChloeXiao0409 ccd891c
delete-unused
ChloeXiao0409 ef5d8eb
fix-type-value
ChloeXiao0409 f796a5b
save-value-type
ChloeXiao0409 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ import type { CalendarItem } from '@/app/admin/settings/components/CalendarForm' | |
| import CalendarOptionsList from '@/app/admin/settings/components/CalendarForm'; | ||
| import SectionDivider from '@/app/admin/settings/components/SectionDivider'; | ||
| import SectionHeader from '@/app/admin/settings/components/SectionHeader'; | ||
| import ProFeatureModal from '@/components/ui/ProFeatureModal'; | ||
| import { useAppSelector } from '@/redux/hooks'; | ||
| import theme from '@/theme'; | ||
|
|
||
| const InfoRow = styled(Box)({ | ||
|
|
@@ -45,15 +47,18 @@ const IconAndContentRow = styled(Box)({ | |
| gap: theme.spacing(1.5), | ||
| }); | ||
|
|
||
| const ConnectButton = styled(Button)({ | ||
| backgroundColor: '#000000', | ||
| const ConnectButton = styled(Button, { | ||
| shouldForwardProp: prop => prop !== '$disabled', | ||
| })<{ $disabled?: boolean }>(({ $disabled }) => ({ | ||
| backgroundColor: $disabled ? '#e0e0e0' : '#000000', | ||
| color: 'white', | ||
| padding: `${theme.spacing(1)} ${theme.spacing(2)}`, | ||
| textTransform: 'none', | ||
| boxShadow: 'none', | ||
| '&:hover': { | ||
| backgroundColor: '#374151', | ||
| backgroundColor: $disabled ? '#e0e0e0' : '#374151', | ||
| }, | ||
| }); | ||
| })); | ||
|
|
||
| const RemoveButton = styled(Button)({ | ||
| backgroundColor: 'transparent', | ||
|
|
@@ -87,7 +92,18 @@ const CustomCheckbox = styled(Checkbox)({ | |
| }, | ||
| }); | ||
|
|
||
| export default function IntegrationsSection() { | ||
| interface IntegrationsSectionProps { | ||
| editable?: boolean; | ||
| showProBadge?: boolean; | ||
| user?: { email?: string }; | ||
| } | ||
|
|
||
ChloeXiao0409 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| export default function IntegrationsSection({ | ||
| editable = false, | ||
| showProBadge = false, | ||
| }: IntegrationsSectionProps) { | ||
| const user = useAppSelector(state => state.auth.user); | ||
| const [showProModal, setShowProModal] = useState(false); | ||
| const [isConnected, setIsConnected] = useState(false); | ||
| const [showGoogleEvents, setShowGoogleEvents] = useState(true); | ||
| const [calendars, setCalendars] = useState<CalendarItem[]>([ | ||
|
|
@@ -107,12 +123,21 @@ export default function IntegrationsSection() { | |
| }, | ||
| ]); | ||
|
|
||
| const handleUnlockPro = () => setShowProModal(true); | ||
| const handleCloseProModal = () => setShowProModal(false); | ||
| const handleUpgrade = () => { | ||
| // Redirect to billing or upgrade page | ||
| window.location.href = '/admin/billing'; | ||
| }; | ||
|
|
||
| const handleConnect = () => { | ||
| if (!editable) return; | ||
| // TODO: Implement Google Calendar OAuth connection | ||
| setIsConnected(true); | ||
| }; | ||
|
|
||
| const handleRemove = () => { | ||
| if (!editable) return; | ||
| setIsConnected(false); | ||
| setShowGoogleEvents(true); | ||
| setCalendars(prev => | ||
|
|
@@ -124,6 +149,7 @@ export default function IntegrationsSection() { | |
| }; | ||
|
|
||
| const handleCalendarToggle = (calendarId: string) => { | ||
| if (!editable) return; | ||
| setCalendars(prev => | ||
| prev.map(cal => | ||
| cal.id === calendarId ? { ...cal, checked: !cal.checked } : cal, | ||
|
|
@@ -134,7 +160,29 @@ export default function IntegrationsSection() { | |
| return ( | ||
| <> | ||
| <SectionDivider /> | ||
| <SectionHeader title="Integrations" /> | ||
| <Box display="flex" alignItems="center" gap={1} mb={1}> | ||
| <SectionHeader title="Integrations" /> | ||
| {showProBadge && !editable && ( | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| gap: 0.5, | ||
| backgroundColor: '#fff2d0', | ||
| padding: '2px 6px', | ||
| borderRadius: '8px', | ||
| fontSize: '10px', | ||
| fontWeight: 'bold', | ||
| color: '#333', | ||
| border: '1px solid #ffd700', | ||
| mb: '20px', | ||
| }} | ||
| > | ||
| <Image src="/plan/pro.svg" alt="Pro" width={12} height={12} /> | ||
| <span style={{ fontSize: '10px', fontWeight: 'bold' }}>PRO</span> | ||
| </Box> | ||
| )} | ||
| </Box> | ||
| <InfoRow> | ||
| <IntegrationItem> | ||
| <LeftSection> | ||
|
|
@@ -151,7 +199,7 @@ export default function IntegrationsSection() { | |
| /> | ||
| <ContentSection> | ||
| <Typography variant="body2" color="text.primary" sx={{ mb: 1 }}> | ||
| [email protected] | ||
| {user?.email ?? ''} | ||
| </Typography> | ||
| <Typography variant="body2" color="text.secondary"> | ||
| Sync your appointments to Google Calendar. Online booking | ||
|
|
@@ -163,9 +211,39 @@ export default function IntegrationsSection() { | |
| </LeftSection> | ||
|
|
||
| {isConnected ? ( | ||
| <RemoveButton onClick={handleRemove}>Remove</RemoveButton> | ||
| <RemoveButton onClick={handleRemove} disabled={!editable}> | ||
| Remove | ||
| </RemoveButton> | ||
| ) : editable ? ( | ||
| <ConnectButton | ||
| onClick={handleConnect} | ||
| disabled={!editable} | ||
| $disabled={!editable} | ||
ChloeXiao0409 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| > | ||
| Connect | ||
| </ConnectButton> | ||
| ) : ( | ||
| <ConnectButton onClick={handleConnect}>Connect</ConnectButton> | ||
| <Button | ||
| variant="contained" | ||
| color="warning" | ||
| onClick={handleUnlockPro} | ||
| sx={{ | ||
| backgroundColor: '#fff2d0', | ||
| color: '#333', | ||
| fontWeight: 600, | ||
| textTransform: 'none', | ||
| borderRadius: 2, | ||
| boxShadow: 'none', | ||
| '&:hover': { | ||
| backgroundColor: '#ffd54f', | ||
| }, | ||
| }} | ||
| startIcon={ | ||
| <Image src="/plan/pro.svg" alt="Pro" width={16} height={16} /> | ||
| } | ||
| > | ||
| Unlock with Pro | ||
| </Button> | ||
| )} | ||
| </IntegrationItem> | ||
|
|
||
|
|
@@ -175,15 +253,18 @@ export default function IntegrationsSection() { | |
| Connected account: | ||
| </Typography> | ||
| <Typography variant="body2" color="text.primary" sx={{ mb: 2 }}> | ||
| [email protected] | ||
| {user?.email ?? ''} | ||
| </Typography> | ||
|
|
||
| <FormControlLabel | ||
| control={ | ||
| <CustomCheckbox | ||
| checked={showGoogleEvents} | ||
| onChange={e => setShowGoogleEvents(e.target.checked)} | ||
| onChange={e => { | ||
| if (editable) setShowGoogleEvents(e.target.checked); | ||
| }} | ||
| size="small" | ||
| disabled={!editable} | ||
| /> | ||
| } | ||
| label={ | ||
|
|
@@ -202,10 +283,19 @@ export default function IntegrationsSection() { | |
| <CalendarOptionsList | ||
| calendars={calendars} | ||
| onToggle={handleCalendarToggle} | ||
| editable={editable} | ||
| /> | ||
| </ConnectedInfo> | ||
| )} | ||
| </InfoRow> | ||
|
|
||
| {/* Render the modal here */} | ||
| <ProFeatureModal | ||
| open={showProModal} | ||
| onClose={handleCloseProModal} | ||
| onUpgrade={handleUpgrade} | ||
| featureName="Calendar Integrations" | ||
| /> | ||
| </> | ||
| ); | ||
| } | ||
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
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.