Skip to content
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

Add partnership condition #758

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -102,10 +102,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 @@ -314,10 +316,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 @@ -381,36 +391,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
Loading