Merge branch 'develop' into feature/MED-129
This commit is contained in:
@@ -5,11 +5,9 @@ import { useContext } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
import { AccountSelector } from '@kit/accounts/account-selector';
|
||||
import { featureFlagsConfig, pathsConfig } from '@kit/shared/config';
|
||||
import { SidebarContext } from '@kit/ui/shadcn-sidebar';
|
||||
|
||||
import { pathsConfig, featureFlagsConfig } from '@kit/shared/config';
|
||||
|
||||
|
||||
const features = {
|
||||
enableTeamCreation: featureFlagsConfig.enableTeamCreation,
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
'use client';
|
||||
|
||||
import DropdownLink from '@kit/shared/components/ui/dropdown-link';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
import SignOutDropdownItem from '@kit/shared/components/sign-out-dropdown-item';
|
||||
import { Home, Menu } from 'lucide-react';
|
||||
|
||||
import { AccountSelector } from '@kit/accounts/account-selector';
|
||||
import SignOutDropdownItem from '@kit/shared/components/sign-out-dropdown-item';
|
||||
import DropdownLink from '@kit/shared/components/ui/dropdown-link';
|
||||
import {
|
||||
featureFlagsConfig,
|
||||
getTeamAccountSidebarConfig,
|
||||
@@ -93,8 +93,6 @@ export const TeamAccountLayoutMobileNavigation = (
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
function TeamAccountsModal(props: {
|
||||
accounts: Accounts;
|
||||
userId: string;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { NavigationConfigSchema } from '@kit/ui/navigation-schema';
|
||||
import { SidebarNavigation } from '@kit/ui/shadcn-sidebar';
|
||||
|
||||
export function TeamAccountLayoutSidebarNavigation({
|
||||
config,
|
||||
}: React.PropsWithChildren<{
|
||||
config: z.infer<typeof NavigationConfigSchema>;
|
||||
}>) {
|
||||
return <SidebarNavigation config={config} />;
|
||||
}
|
||||
@@ -1,20 +1,12 @@
|
||||
import type { User } from '@supabase/supabase-js';
|
||||
|
||||
import { ApplicationRole } from '@kit/accounts/types/accounts';
|
||||
import { ProfileAccountDropdownContainer } from '@kit/shared/components/personal-account-dropdown-container';
|
||||
import { getTeamAccountSidebarConfig } from '@kit/shared/config';
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarHeader,
|
||||
SidebarNavigation,
|
||||
} from '@kit/ui/shadcn-sidebar';
|
||||
|
||||
import { TeamAccountNotifications } from '~/home/[account]/_components/team-account-notifications';
|
||||
|
||||
import { TeamAccountAccountsSelector } from '../_components/team-account-accounts-selector';
|
||||
import { TeamAccountLayoutSidebarNavigation } from './team-account-layout-sidebar-navigation';
|
||||
|
||||
type AccountModel = {
|
||||
label: string | null;
|
||||
value: string | null;
|
||||
@@ -26,14 +18,12 @@ export function TeamAccountLayoutSidebar(props: {
|
||||
account: string;
|
||||
accountId: string;
|
||||
accounts: AccountModel[];
|
||||
user: User;
|
||||
}) {
|
||||
return (
|
||||
<SidebarContainer
|
||||
account={props.account}
|
||||
accountId={props.accountId}
|
||||
accounts={props.accounts}
|
||||
user={props.user}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -42,45 +32,26 @@ function SidebarContainer(props: {
|
||||
account: string;
|
||||
accountId: string;
|
||||
accounts: AccountModel[];
|
||||
user: User;
|
||||
}) {
|
||||
const { account, accounts, user } = props;
|
||||
const userId = user.id;
|
||||
const { account, accounts } = props;
|
||||
|
||||
const config = getTeamAccountSidebarConfig(account);
|
||||
const collapsible = config.sidebarCollapsedStyle;
|
||||
|
||||
const selectedAccount = accounts.find(({ value }) => value === account);
|
||||
const accountName = selectedAccount?.label || account;
|
||||
|
||||
return (
|
||||
<Sidebar collapsible={collapsible}>
|
||||
<SidebarHeader className="h-16 justify-center">
|
||||
<div className="flex items-center justify-between gap-x-3">
|
||||
<TeamAccountAccountsSelector
|
||||
userId={userId}
|
||||
selectedAccount={account}
|
||||
accounts={accounts}
|
||||
/>
|
||||
|
||||
<div className="group-data-[minimized=true]:hidden">
|
||||
<TeamAccountNotifications
|
||||
userId={userId}
|
||||
accountId={props.accountId}
|
||||
/>
|
||||
</div>
|
||||
<SidebarHeader className="h-24 justify-center">
|
||||
<div className="mt-24 flex items-center">
|
||||
<h5>{accountName}</h5>
|
||||
</div>
|
||||
</SidebarHeader>
|
||||
|
||||
<SidebarContent className={`mt-5 h-[calc(100%-160px)] overflow-y-auto`}>
|
||||
<TeamAccountLayoutSidebarNavigation config={config} />
|
||||
<SidebarContent>
|
||||
<SidebarNavigation config={config} />
|
||||
</SidebarContent>
|
||||
|
||||
<SidebarFooter>
|
||||
<SidebarContent>
|
||||
<ProfileAccountDropdownContainer
|
||||
user={props.user}
|
||||
accounts={accounts}
|
||||
/>
|
||||
</SidebarContent>
|
||||
</SidebarFooter>
|
||||
</Sidebar>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { NotificationsPopover } from '@kit/notifications/components';
|
||||
|
||||
import { featureFlagsConfig } from '@kit/shared/config';
|
||||
|
||||
|
||||
export function TeamAccountNotifications(params: {
|
||||
userId: string;
|
||||
accountId: string;
|
||||
|
||||
@@ -4,11 +4,10 @@ import { cache } from 'react';
|
||||
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { pathsConfig } from '@kit/shared/config';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
import { createTeamAccountsApi } from '@kit/team-accounts/api';
|
||||
|
||||
import { pathsConfig } from '@kit/shared/config';
|
||||
|
||||
import { requireUserInServerComponent } from '~/lib/server/require-user-in-server-component';
|
||||
|
||||
export type TeamAccountWorkspace = Awaited<
|
||||
@@ -29,7 +28,7 @@ export const loadTeamWorkspace = cache(workspaceLoader);
|
||||
async function workspaceLoader(accountSlug: string) {
|
||||
const client = getSupabaseServerClient();
|
||||
const api = createTeamAccountsApi(client);
|
||||
const user = await requireUserInServerComponent();
|
||||
const user = await requireUserInServerComponent();
|
||||
const workspace = await api.getAccountWorkspace(accountSlug, user.id);
|
||||
// we cannot find any record for the selected account
|
||||
// so we redirect the user to the home page
|
||||
@@ -39,7 +38,9 @@ async function workspaceLoader(accountSlug: string) {
|
||||
|
||||
return {
|
||||
...workspace.data,
|
||||
accounts: workspace.data.accounts.map(({ user_accounts }) => ({...user_accounts})),
|
||||
accounts: workspace.data.accounts.map(({ user_accounts }) => ({
|
||||
...user_accounts,
|
||||
})),
|
||||
user,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const HealthBenefitFields = () => {
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<FormField
|
||||
name="occurance"
|
||||
name="occurrence"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>
|
||||
@@ -30,20 +30,22 @@ const HealthBenefitFields = () => {
|
||||
<Select {...field} onValueChange={field.onChange}>
|
||||
<SelectTrigger>
|
||||
<SelectValue
|
||||
placeholder={<Trans i18nKey="common:formField:occurance" />}
|
||||
placeholder={
|
||||
<Trans i18nKey="common:formField:occurrence" />
|
||||
}
|
||||
/>
|
||||
</SelectTrigger>
|
||||
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem value="yearly">
|
||||
<Trans i18nKey="billing:occurance.yearly" />
|
||||
<Trans i18nKey="billing:occurrence.yearly" />
|
||||
</SelectItem>
|
||||
<SelectItem value="quarterly">
|
||||
<Trans i18nKey="billing:occurance.quarterly" />
|
||||
<Trans i18nKey="billing:occurrence.quarterly" />
|
||||
</SelectItem>
|
||||
<SelectItem value="monthly">
|
||||
<Trans i18nKey="billing:occurance.monthly" />
|
||||
<Trans i18nKey="billing:occurrence.monthly" />
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
|
||||
@@ -39,13 +39,13 @@ const HealthBenefitForm = ({
|
||||
resolver: zodResolver(UpdateHealthBenefitSchema),
|
||||
mode: 'onChange',
|
||||
defaultValues: {
|
||||
occurance: currentCompanyParams.benefit_occurance || 'yearly',
|
||||
occurrence: currentCompanyParams.benefit_occurance || 'yearly',
|
||||
amount: currentCompanyParams.benefit_amount || 0,
|
||||
},
|
||||
});
|
||||
const isDirty = form.formState.isDirty;
|
||||
|
||||
const onSubmit = (data: { occurance: string; amount: number }) => {
|
||||
const onSubmit = (data: { occurrence: string; amount: number }) => {
|
||||
const promise = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
@@ -53,7 +53,7 @@ const HealthBenefitForm = ({
|
||||
setCurrentCompanyParams((prev) => ({
|
||||
...prev,
|
||||
benefit_amount: data.amount,
|
||||
benefit_occurance: data.occurance,
|
||||
benefit_occurance: data.occurrence,
|
||||
}));
|
||||
} finally {
|
||||
form.reset(data);
|
||||
@@ -78,7 +78,7 @@ const HealthBenefitForm = ({
|
||||
<h4>
|
||||
<Trans
|
||||
i18nKey="billing:pageTitle"
|
||||
values={{ companyName: account.slug }}
|
||||
values={{ companyName: account.name }}
|
||||
/>
|
||||
</h4>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
|
||||
@@ -6,6 +6,7 @@ import dynamic from 'next/dynamic';
|
||||
import { useParams } from 'next/navigation';
|
||||
|
||||
import { PlanPicker } from '@kit/billing-gateway/components';
|
||||
import { billingConfig } from '@kit/shared/config';
|
||||
import { useAppEvents } from '@kit/shared/events';
|
||||
import {
|
||||
Card,
|
||||
@@ -16,8 +17,6 @@ import {
|
||||
} from '@kit/ui/card';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import { billingConfig } from '@kit/shared/config';
|
||||
|
||||
import { createTeamAccountCheckoutSession } from '../_lib/server/server-actions';
|
||||
|
||||
const EmbeddedCheckout = dynamic(
|
||||
|
||||
@@ -6,7 +6,6 @@ import { PageBody } from '@kit/ui/page';
|
||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
|
||||
|
||||
import HealthBenefitForm from './_components/health-benefit-form';
|
||||
|
||||
interface TeamAccountBillingPageProps {
|
||||
|
||||
@@ -5,10 +5,10 @@ import { BillingSessionStatus } from '@kit/billing-gateway/components';
|
||||
import { billingConfig } from '@kit/shared/config';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
import { requireUserInServerComponent } from '~/lib/server/require-user-in-server-component';
|
||||
|
||||
import { EmbeddedCheckoutForm } from '../_components/embedded-checkout-form';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
|
||||
interface SessionPageProps {
|
||||
searchParams: Promise<{
|
||||
|
||||
@@ -15,7 +15,6 @@ import { SidebarProvider } from '@kit/ui/shadcn-sidebar';
|
||||
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
|
||||
// local imports
|
||||
import { TeamAccountLayoutMobileNavigation } from './_components/team-account-layout-mobile-navigation';
|
||||
import { TeamAccountLayoutSidebar } from './_components/team-account-layout-sidebar';
|
||||
import { TeamAccountNavigationMenu } from './_components/team-account-navigation-menu';
|
||||
@@ -57,13 +56,12 @@ function SidebarLayout({
|
||||
return (
|
||||
<TeamAccountWorkspaceContextProvider value={data}>
|
||||
<SidebarProvider defaultOpen={state.open}>
|
||||
<Page style={'sidebar'}>
|
||||
<Page style={'header'}>
|
||||
<PageNavigation>
|
||||
<TeamAccountLayoutSidebar
|
||||
account={account}
|
||||
accountId={data.account.id}
|
||||
accounts={accounts}
|
||||
user={data.user}
|
||||
/>
|
||||
</PageNavigation>
|
||||
|
||||
@@ -129,23 +127,8 @@ function HeaderLayout({
|
||||
account={account}
|
||||
accountId={data.account.id}
|
||||
accounts={accounts}
|
||||
user={data.user}
|
||||
/>
|
||||
</PageNavigation>
|
||||
|
||||
<PageMobileNavigation
|
||||
className={'flex items-center justify-between'}
|
||||
>
|
||||
<AppLogo href={pathsConfig.app.home} />
|
||||
<div className={'flex space-x-4'}>
|
||||
<TeamAccountLayoutMobileNavigation
|
||||
userId={data.user.id}
|
||||
accounts={accounts}
|
||||
account={account}
|
||||
/>
|
||||
</div>
|
||||
</PageMobileNavigation>
|
||||
|
||||
{children}
|
||||
</Page>
|
||||
</SidebarProvider>
|
||||
|
||||
@@ -22,8 +22,6 @@ import { Trans } from '@kit/ui/trans';
|
||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
|
||||
|
||||
// local imports
|
||||
import { TeamAccountLayoutPageHeader } from '../_components/team-account-layout-page-header';
|
||||
import { loadMembersPageData } from './_lib/server/members-page.loader';
|
||||
|
||||
@@ -57,8 +55,9 @@ async function TeamAccountMembersPage({ params }: TeamAccountMembersPageProps) {
|
||||
<>
|
||||
<TeamAccountLayoutPageHeader
|
||||
title={<Trans i18nKey={'common:routes.members'} />}
|
||||
description={<AppBreadcrumbs />}
|
||||
account={account.slug}
|
||||
description={
|
||||
<AppBreadcrumbs values={{ [account.slug]: account.name }} />
|
||||
}
|
||||
/>
|
||||
|
||||
<PageBody>
|
||||
|
||||
@@ -5,9 +5,9 @@ import { use } from 'react';
|
||||
import { CompanyGuard } from '@/packages/features/team-accounts/src/components';
|
||||
import { createTeamAccountsApi } from '@/packages/features/team-accounts/src/server/api';
|
||||
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
||||
import { createUserAnalysesApi } from '@kit/user-analyses/api';
|
||||
|
||||
import { PageBody } from '@kit/ui/page';
|
||||
import { createUserAnalysesApi } from '@kit/user-analyses/api';
|
||||
|
||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
|
||||
@@ -8,7 +8,6 @@ import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||
|
||||
// local imports
|
||||
import { TeamAccountLayoutPageHeader } from '../_components/team-account-layout-page-header';
|
||||
|
||||
export const generateMetadata = async () => {
|
||||
@@ -48,9 +47,10 @@ async function TeamAccountSettingsPage(props: TeamAccountSettingsPageProps) {
|
||||
return (
|
||||
<>
|
||||
<TeamAccountLayoutPageHeader
|
||||
account={account.slug}
|
||||
title={<Trans i18nKey={'teams:settings.pageTitle'} />}
|
||||
description={<AppBreadcrumbs />}
|
||||
description={
|
||||
<AppBreadcrumbs values={{ [account.slug]: account.name }} />
|
||||
}
|
||||
/>
|
||||
|
||||
<PageBody>
|
||||
|
||||
Reference in New Issue
Block a user