Skip to content

Commit

Permalink
Merge branch 'dev' into bal3482
Browse files Browse the repository at this point in the history
  • Loading branch information
r4zendev authored Feb 5, 2025
2 parents bc0f8bd + 94cbce8 commit ef94288
Show file tree
Hide file tree
Showing 8 changed files with 528 additions and 7 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { ctw } from '@ballerine/ui';
import { ArrowRightIcon, CrownIcon, XIcon } from 'lucide-react';
import { useState } from 'react';

import { env } from '@/common/env/env';
import { useCustomerQuery } from '@/domains/customer/hooks/queries/useCustomerQuery/useCustomerQuery';
import { Button } from '../../atoms/Button/Button';
import { DataListImage } from './DataListImage';

export const GetFullAccessCard = () => {
const [isHidden, setIsHidden] = useState(false);

const { data: customer, isLoading } = useCustomerQuery();

if (
env.VITE_ENVIRONMENT_NAME === 'production' ||
isLoading ||
!customer?.config?.showFullAccessPopup
) {
return null;
}

return (
<div
className={ctw(
'fixed bottom-8 right-8 flex max-w-lg flex-nowrap items-center justify-between gap-2 rounded-md border border-purple-500 bg-white px-6 py-4',
isHidden && 'hidden',
)}
style={{
boxShadow: 'inset 0 24px 12px rgba(247, 241, 250, 1), 0 2px 6px rgba(208, 161, 255, 0.7)',
}}
>
<div className="shrink-0 basis-7/12 space-y-4">
<div className="flex items-center gap-2">
<CrownIcon className="rounded-full bg-purple-200 p-[6px] font-bold text-purple-700 d-7" />
<span className="text-lg font-medium">Get Full Access</span>
</div>

<p className="leading-relaxed">
Unlock additional features and continue effective risk management with Ballerine.
</p>

<Button
asChild
variant="link"
className="h-6 justify-start space-x-2 p-0 text-base text-blue-500"
>
<a
href="https://calendly.com/d/cp53-ryw-4s3/ballerine-intro"
target="_blank"
rel="noreferrer"
>
<span>Talk to us</span>
<ArrowRightIcon className="d-4" />
</a>
</Button>
</div>

<div className="h-full grow-0 basis-5/12">
<DataListImage className="h-full" />
</div>

<button
onClick={() => setIsHidden(true)}
className="absolute right-2 top-2 p-2 text-purple-400 transition-colors hover:text-purple-600"
>
<XIcon className="d-4" />
</button>
</div>
);
};
2 changes: 2 additions & 0 deletions apps/backoffice-v2/src/domains/customer/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ const CustomerSchema = z.object({
isMerchantMonitoringEnabled: z.boolean().default(false),
isExample: z.boolean().default(false),
isDemo: z.boolean().default(false),
showFullAccessPopup: z.boolean().default(false),
})
.nullable()
.default({
isMerchantMonitoringEnabled: false,
isExample: false,
showFullAccessPopup: false,
}),
});

Expand Down
3 changes: 3 additions & 0 deletions apps/backoffice-v2/src/pages/Home/Home.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useHomeLogic } from '@/common/hooks/useHomeLogic/useHomeLogic';
import { t } from 'i18next';
import { FullScreenLoader } from '@/common/components/molecules/FullScreenLoader/FullScreenLoader';
import { WelcomeCard } from '@/pages/Home/components/WelcomeCard/WelcomeCard';
import { GetFullAccessCard } from '@/common/components/molecules/GetFullAccessCard/GetFullAccessCard';

export const Home: FunctionComponent = () => {
const {
Expand Down Expand Up @@ -58,6 +59,8 @@ export const Home: FunctionComponent = () => {
{(isDemo || isExample) && <Outlet />}
{!isDemo && !isExample && <WelcomeCard />}
</div>

<GetFullAccessCard />
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { t } from 'i18next';
import { MultiSelect } from '@/common/components/atoms/MultiSelect/MultiSelect';
import { DateRangePicker } from '@/common/components/molecules/DateRangePicker/DateRangePicker';
import { Separator } from '@/common/components/atoms/Separator/Separator';
import { GetFullAccessCard } from '@/common/components/molecules/GetFullAccessCard/GetFullAccessCard';

export const MerchantMonitoring: FunctionComponent = () => {
const {
Expand Down Expand Up @@ -277,6 +278,8 @@ export const MerchantMonitoring: FunctionComponent = () => {
/>
</div>
</div>

<GetFullAccessCard />
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import * as common from '@nestjs/common';
import { NotFoundException, UseGuards } from '@nestjs/common';
import * as swagger from '@nestjs/swagger';
import { CustomerService } from '@/customer/customer.service';
import { CustomerModel } from '@/customer/customer.model';
import { InputJsonValue, type TProjectIds } from '@/types';
import { Customer, Prisma } from '@prisma/client';
import { merge } from 'lodash';
import { randomUUID } from 'node:crypto';

import { ProjectIds } from '@/common/decorators/project-ids.decorator';
import { TCustomerWithFeatures } from '@/customer/types';
import { AdminAuthGuard } from '@/common/guards/admin-auth.guard';
import { CustomerModel } from '@/customer/customer.model';
import { CustomerService } from '@/customer/customer.service';
import { CustomerCreateDto } from '@/customer/dtos/customer-create';
import { TCustomerWithFeatures } from '@/customer/types';
import { PrismaService } from '@/prisma/prisma.service';
import { InputJsonValue, type TProjectIds } from '@/types';
import { ConfigSchema } from '@/workflow/schemas/zod-schemas';
import { Customer, Prisma } from '@prisma/client';
import { randomUUID } from 'node:crypto';
import { createDemoMockData } from '../../scripts/workflows/workflow-runtime';
import { PrismaService } from '@/prisma/prisma.service';
import { CustomerUpdateDto } from './dtos/customer-update';
import { cleanUndefinedValues } from '@/common/utils/clean-undefined-values';

@swagger.ApiExcludeController()
@common.Controller('internal/customers')
Expand Down Expand Up @@ -106,4 +110,25 @@ export class CustomerControllerInternal {
apiKey,
};
}

@common.Put(':id')
@UseGuards(AdminAuthGuard)
@swagger.ApiCreatedResponse({ type: [CustomerUpdateDto] })
@swagger.ApiForbiddenResponse()
async edit(@common.Param('id') id: string, @common.Body() payload: CustomerUpdateDto) {
const { config, ...customer } = payload;

const existingCustomer = await this.service.getById(id);

if (!existingCustomer) {
throw new NotFoundException('Customer not found');
}

return this.service.updateById(id, {
data: cleanUndefinedValues({
...(config && { config: merge(existingCustomer.config, ConfigSchema.parse(config)) }),
...customer,
}),
});
}
}
55 changes: 55 additions & 0 deletions services/workflows-service/src/customer/dtos/customer-update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsObject, IsOptional, IsString } from 'class-validator';
import { CustomerStatuses } from '@prisma/client';

export class CustomerUpdateDto {
@ApiProperty({ type: String })
@IsString()
@IsOptional()
name?: string;

@ApiProperty({ type: String })
@IsString()
@IsOptional()
displayName?: string;

@ApiProperty({ type: String })
@IsString()
@IsOptional()
customerStatus?: CustomerStatuses;

@ApiProperty({ type: String })
@IsString()
@IsOptional()
logoImageUri?: string;

@ApiProperty({ type: String })
@IsString()
@IsOptional()
faviconImageUri?: string;

@ApiProperty({ type: String })
@IsString()
@IsOptional()
language?: string;

@ApiProperty({ type: String })
@IsString()
@IsOptional()
country?: string;

@ApiProperty({ type: String })
@IsString()
@IsOptional()
projectName?: string;

@ApiProperty({ type: String })
@IsString()
@IsOptional()
websiteUrl?: string;

@ApiProperty({ required: false, type: 'object' })
@IsObject()
@IsOptional()
config?: Record<string, unknown>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const ConfigSchema = z
hasUboOngoingMonitoring: z.boolean().optional(),
maxBusinessReports: z.number().nonnegative().optional(),
isMerchantMonitoringEnabled: z.boolean().optional(),
showFullAccessPopup: z.boolean().optional(),
uiOptions: z
.object({
redirectUrls: z
Expand Down

0 comments on commit ef94288

Please sign in to comment.