Skip to content

Commit

Permalink
Add partnership condition (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrine-ds authored Jun 12, 2024
1 parent b3312b9 commit 3ed3e98
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
6 changes: 4 additions & 2 deletions clients/banking/src/components/AccountArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
} from "react-native";
import { P, match } from "ts-pattern";
import logoSwan from "../assets/images/logo-swan.svg";
import { AccountAreaQuery, IdentificationFragment } from "../graphql/partner";
import { AccountAreaQuery, AccountLanguage, IdentificationFragment } from "../graphql/partner";
import { AccountActivationPage } from "../pages/AccountActivationPage";
import { AccountNotFoundPage, NotFoundPage } from "../pages/NotFoundPage";
import { ProfilePage } from "../pages/ProfilePage";
Expand Down Expand Up @@ -139,6 +139,7 @@ const styles = StyleSheet.create({
});

type Props = {
accountLanguage: AccountLanguage;
accountMembershipId: string;
accountMembership: NonNullable<AccountAreaQuery["accountMembership"]>;
user: NonNullable<AccountAreaQuery["user"]>;
Expand Down Expand Up @@ -176,6 +177,7 @@ type Props = {
};

export const AccountArea = ({
accountLanguage,
accountMembershipId,
accountMembership,
projectInfo,
Expand Down Expand Up @@ -512,11 +514,11 @@ export const AccountArea = ({
<ErrorView />
) : (
<AccountDetailsArea
accountLanguage={accountLanguage}
accountId={accountId}
accountMembershipId={accountMembershipId}
canManageAccountMembership={permissions.canManageAccountMembership}
virtualIbansVisible={features.virtualIbansVisible}
projectName={projectName}
isIndividual={isIndividual}
/>
),
Expand Down
7 changes: 4 additions & 3 deletions clients/banking/src/components/AccountDetailsArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { breakpoints, spacings } from "@swan-io/lake/src/constants/design";
import { useMemo } from "react";
import { StyleSheet } from "react-native";
import { P, match } from "ts-pattern";
import { AccountLanguage } from "../graphql/partner";
import { AccountDetailsBillingPage } from "../pages/AccountDetailsBillingPage";
import { AccountDetailsIbanPage } from "../pages/AccountDetailsIbanPage";
import { AccountDetailsSettingsPage } from "../pages/AccountDetailsSettingsPage";
Expand All @@ -21,20 +22,20 @@ const styles = StyleSheet.create({
});

type Props = {
accountLanguage: AccountLanguage;
accountId: string;
accountMembershipId: string;
canManageAccountMembership: boolean;
virtualIbansVisible: boolean;
projectName: string;
isIndividual: boolean;
};

export const AccountDetailsArea = ({
accountLanguage,
accountId,
accountMembershipId,
canManageAccountMembership,
virtualIbansVisible,
projectName,
isIndividual,
}: Props) => {
const route = Router.useRoute([
Expand Down Expand Up @@ -104,7 +105,7 @@ export const AccountDetailsArea = ({
))
.with({ name: "AccountDetailsSettings" }, () => (
<AccountDetailsSettingsPage
projectName={projectName}
accountLanguage={accountLanguage}
accountId={accountId}
largeBreakpoint={large}
canManageAccountMembership={canManageAccountMembership}
Expand Down
1 change: 1 addition & 0 deletions clients/banking/src/components/AccountMembershipArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export const AccountMembershipArea = ({ accountMembershipId }: Props) => {
sections,
}) => (
<AccountArea
accountLanguage={accountMembership.account?.language ?? "en"}
accountMembershipId={accountMembershipId}
user={user}
accountMembership={accountMembership}
Expand Down
11 changes: 10 additions & 1 deletion clients/banking/src/graphql/partner.gql
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,11 @@ query AccountDetailsBillingPage($accountId: ID!, $first: Int!, $after: String) {
}
}

query AccountDetailsSettingsPage($accountId: ID!, $filters: LegalDocumentsFilterInput) {
query AccountDetailsSettingsPage(
$accountId: ID!
$filters: LegalDocumentsFilterInput
$language: String!
) {
account(accountId: $accountId) {
id
country
Expand Down Expand Up @@ -532,6 +536,11 @@ query AccountDetailsSettingsPage($accountId: ID!, $filters: LegalDocumentsFilter
}
}
}
projectInfo {
id
tcuDocumentUri(language: $language)
name
}
}

mutation UpdateAccountLanguage($id: ID!, $language: AccountLanguage!) {
Expand Down
22 changes: 17 additions & 5 deletions clients/banking/src/pages/AccountDetailsSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ const UpdateAccountForm = ({
accountId,
account,
canManageAccountMembership,
projectInfo,
}: {
accountId: string;
account: NonNullable<AccountDetailsSettingsPageQuery["account"]>;
canManageAccountMembership: boolean;
projectInfo: NonNullable<AccountDetailsSettingsPageQuery["projectInfo"]>;
}) => {
const accountCountry = account.country ?? "FRA";
const [updateAccount] = useMutation(UpdateAccountDocument);
Expand Down Expand Up @@ -315,10 +317,18 @@ const UpdateAccountForm = ({
<LakeText>{t("accountDetails.settings.contractsDescription")}</LakeText>
<Space height={12} />

<TileGrid>
<TileGrid breakpoint={500}>
{legalDocuments.map(legalDocument => (
<Contract to={legalDocument}>{t("accountDetails.swanTermsAndConditions")}</Contract>
<Contract key={legalDocument} to={legalDocument}>
{t("accountDetails.swanTermsAndConditions")}
</Contract>
))}

<Contract to={projectInfo.tcuDocumentUri}>
{t("accountDetails.settings.partnershipConditions", {
projectName: projectInfo.name,
})}
</Contract>
</TileGrid>
</>
) : null}
Expand Down Expand Up @@ -382,36 +392,38 @@ const UpdateAccountForm = ({
};

type Props = {
projectName: string;
accountLanguage: AccountLanguage;
accountId: string;
canManageAccountMembership: boolean;
largeBreakpoint: boolean;
};

export const AccountDetailsSettingsPage = ({
// projectName,
accountLanguage,
accountId,
canManageAccountMembership,
largeBreakpoint,
}: Props) => {
const [data] = useQuery(AccountDetailsSettingsPageDocument, {
accountId,
filters: { status: "Active", type: "SwanTCU" },
language: accountLanguage,
});

return (
<ScrollView contentContainerStyle={[styles.content, largeBreakpoint && styles.contentDesktop]}>
{match(data)
.with(AsyncData.P.NotAsked, AsyncData.P.Loading, () => <TilePlaceholder />)
.with(AsyncData.P.Done(Result.P.Error(P.select())), error => <ErrorView error={error} />)
.with(AsyncData.P.Done(Result.P.Ok(P.select())), ({ account }) =>
.with(AsyncData.P.Done(Result.P.Ok(P.select())), ({ account, projectInfo }) =>
isNullish(account) ? (
<NotFoundPage />
) : (
<UpdateAccountForm
accountId={accountId}
account={account}
canManageAccountMembership={canManageAccountMembership}
projectInfo={projectInfo}
/>
),
)
Expand Down

0 comments on commit 3ed3e98

Please sign in to comment.