Skip to content

Commit

Permalink
refactor(sidebar): improve class order in Sidebar components
Browse files Browse the repository at this point in the history
- Reorganize class names for better readability and consistency
- Maintain functionality while optimizing CSS class arrangements

feat(user): add endpoint to retrieve user details by ID

- Implement new API route to fetch user information based on user ID
- Enhance user management features for better admin interactions
  • Loading branch information
alonp99 committed Mar 1, 2025
1 parent 2eb95f9 commit 5705dbd
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const SidebarGroupAction = React.forwardRef<
ref={ref}
data-sidebar="group-action"
className={ctw(
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&>svg]:size-4 absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:shrink-0',
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
// Increases the hit area of the button on mobile.
'after:absolute after:-inset-2 after:md:hidden',
'group-data-[collapsible=icon]:hidden',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const SidebarGroupLabel = React.forwardRef<
ref={ref}
data-sidebar="group-label"
className={ctw(
'text-sidebar-foreground/70 ring-sidebar-ring [&>svg]:size-4 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-none transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:shrink-0',
'text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-none transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
className,
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const SidebarInset = React.forwardRef<HTMLDivElement, React.ComponentProp
<main
ref={ref}
className={ctw(
'min-h-svh relative flex flex-1 flex-col bg-background',
'relative flex min-h-svh flex-1 flex-col bg-background',
'peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow',
className,
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const SidebarMenuAction = React.forwardRef<
ref={ref}
data-sidebar="menu-action"
className={ctw(
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:shrink-0',
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
// Increases the hit area of the button on mobile.
'after:absolute after:-inset-2 after:md:hidden',
'peer-data-[size=sm]/menu-button:top-1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const SidebarMenuBadge = React.forwardRef<HTMLDivElement, React.Component
ref={ref}
data-sidebar="menu-badge"
className={ctw(
'text-sidebar-foreground min-w-5 pointer-events-none absolute right-1 flex h-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums',
'text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums',
'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground',
'peer-data-[size=sm]/menu-button:top-1',
'peer-data-[size=default]/menu-button:top-1.5',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const SidebarMenuSubButton = React.forwardRef<
data-size={size}
data-active={isActive}
className={ctw(
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground [&>svg]:size-4 flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0',
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground',
size === 'sm' && 'text-xs',
size === 'md' && 'text-sm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const SidebarProvider = React.forwardRef<
} as React.CSSProperties
}
className={ctw(
'group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar min-h-svh flex w-full',
'group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full',
className,
)}
ref={ref}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const Sidebar = React.forwardRef<
{/* This is what handles the sidebar gap on desktop */}
<div
className={ctw(
'h-svh relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear 2xl:w-[--sidebar-width-xl]',
'relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear 2xl:w-[--sidebar-width-xl]',
'group-data-[collapsible=offcanvas]:w-0',
'group-data-[side=right]:rotate-180',
variant === 'floating' || variant === 'inset'
Expand All @@ -107,7 +107,7 @@ const Sidebar = React.forwardRef<
/>
<div
className={ctw(
'h-svh fixed inset-y-0 z-10 hidden w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex 2xl:w-[--sidebar-width-xl]',
'fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex 2xl:w-[--sidebar-width-xl]',
side === 'left'
? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
: 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ShortcutKey = React.forwardRef<HTMLSpanElement, ShortcutKeyProps>(
<kbd
key={shortcut.symbol}
className={ctw(
'min-w-2.5 inline-block text-center align-baseline font-sans text-xs font-medium capitalize text-[rgb(156,157,160)]',
'inline-block min-w-2.5 text-center align-baseline font-sans text-xs font-medium capitalize text-[rgb(156,157,160)]',

className,
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const LinkBubbleMenu: React.FC<LinkBubbleMenuProps> = ({ editor }) => {
defaultText={selectedText}
defaultIsNewTab={linkAttrs.target === '_blank'}
onSave={onSetLink}
className="min-w-80 w-full rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none"
className="w-full min-w-80 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none"
/>
) : (
<LinkPopoverBlock onClear={onUnsetLink} url={linkAttrs.href} onEdit={handleEdit} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const LinkEditPopover = ({ editor, size, variant }: LinkEditPopoverProps) => {
<Link2Icon className="size-5" />
</ToolbarButton>
</PopoverTrigger>
<PopoverContent className="min-w-80 w-full" align="end" side="bottom">
<PopoverContent className="w-full min-w-80" align="end" side="bottom">
<LinkEditBlock onSave={onSetLink} defaultText={text} />
</PopoverContent>
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const MemoizedColorButton = React.memo<{
<Tooltip>
<TooltipTrigger asChild>
<ToggleGroupItem
className="size-7 relative rounded-md p-0"
className="relative size-7 rounded-md p-0"
value={color.cssVar}
aria-label={label}
style={{ backgroundColor: color.cssVar }}
Expand All @@ -89,7 +89,7 @@ const MemoizedColorButton = React.memo<{
}}
>
{isSelected && (
<CheckIcon className="size-6 absolute inset-0 m-auto" style={{ color: inverse }} />
<CheckIcon className="absolute inset-0 m-auto size-6" style={{ color: inverse }} />
)}
</ToggleGroupItem>
</TooltipTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const ImageViewBlock: React.FC<NodeViewProps> = ({
},
)}
>
<div className="contain-paint h-full">
<div className="h-full contain-paint">
<div className="relative h-full">
{!imageState.imageLoaded && !imageState.error && (
<div className="absolute inset-0 flex items-center justify-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const Actions: FunctionComponent<IActionsProps> = ({
/>
<CaseOptions />
</div>
<div className={`min-h-20 flex justify-between gap-4`}>
<div className={`flex min-h-20 justify-between gap-4`}>
<div className={`flex flex-col space-y-3`}>
<div className={`flex space-x-4`}>
<Avatar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AppLoggerService } from '@/common/app-logger/app-logger.service';
import { CustomerService } from '@/customer/customer.service';
import { BusinessService } from '@/business/business.service';
import { CurrentProject } from '@/common/decorators/current-project.decorator';
import type { TProjectId } from '@/types';
import type { AuthenticatedEntity, TProjectId } from '@/types';
import { GetLatestBusinessReportDto } from '@/business-report/get-latest-business-report.dto';
import {
BusinessReportListRequestParamDto,
Expand All @@ -41,6 +41,7 @@ import {
} from '@/business-report/dtos/business-report-metrics.dto';
import { BusinessReportMetricsDto } from './dtos/business-report-metrics-dto';
import { BusinessReportStatusUpdateRequestParamsDto } from '@/business-report/dtos/business-report-status-update.dto';
import { UserData } from '@/user/user-data.decorator';

@ApiBearerAuth()
@swagger.ApiTags('Business Reports')
Expand Down Expand Up @@ -263,6 +264,7 @@ export class BusinessReportControllerExternal {
};
}

@common.Post()
@swagger.ApiOperation({
summary: 'Create business report',
description: 'Create a new business report for a merchant',
Expand All @@ -271,7 +273,6 @@ export class BusinessReportControllerExternal {
type: CreateBusinessReportDto,
description: 'Business report creation parameters',
})
@common.Post()
@swagger.ApiOkResponse({
description: 'Business report created successfully',
})
Expand All @@ -293,6 +294,7 @@ export class BusinessReportControllerExternal {
workflowVersion,
}: CreateBusinessReportDto,
@CurrentProject() currentProjectId: TProjectId,
@UserData() user: AuthenticatedEntity,
) {
const customer = await this.customerService.getByProjectId(currentProjectId);
await this.businessReportService.checkBusinessReportsLimit(customer);
Expand Down Expand Up @@ -340,6 +342,7 @@ export class BusinessReportControllerExternal {
workflowVersion,
withQualityControl: customer.config?.withQualityControl ?? false,
customerId: customer.id,
requestedByUserId: user.user?.id,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class BusinessReportService {
compareToReportId,
withQualityControl,
customerId,
requestedByUserId,
}: {
reportType: MerchantReportType;
business: Pick<Business, 'id' | 'correlationId'>;
Expand All @@ -65,6 +66,7 @@ export class BusinessReportService {
workflowVersion: MerchantReportVersion;
withQualityControl: boolean;
customerId: string;
requestedByUserId: string | undefined;
}) {
await this.merchantMonitoringClient.create({
reportType,
Expand All @@ -76,6 +78,7 @@ export class BusinessReportService {
parentCompanyName: merchantName,
...(countryCode && { countryCode }),
...(compareToReportId && { compareToReportId }),
requestedByUserId,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class VerifyUnifiedApiSignatureGuard implements CanActivate {
if (
!verifySignature({
payload: request.body,
signature,
key: env.UNIFIED_API_SHARED_SECRET ?? '',
signature,
})
) {
throw new UnauthorizedException('Invalid signature');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class MerchantMonitoringClient {
compareToReportId,
withQualityControl,
workflowRuntimeDataId,
requestedByUserId,
}: {
websiteUrl: string;
countryCode?: CountryCode;
Expand All @@ -75,6 +76,7 @@ export class MerchantMonitoringClient {
compareToReportId?: string;
withQualityControl?: boolean;
workflowRuntimeDataId?: string;
requestedByUserId?: string;
}) {
const response = await this.axios.post(`merchants/analysis`, {
websiteUrl,
Expand All @@ -85,9 +87,11 @@ export class MerchantMonitoringClient {
...(compareToReportId && { compareToReportId }),
withQualityControl,
merchantId: businessId,
// TODO: Check if we can depreacte it, as we get the report infomration from the unified api - we dont need to ge this callback with the data.
callbackUrl: `${env.APP_API_URL}/api/v1/internal/business-reports/hook?businessId=${businessId}`,
metadata: {
...(workflowRuntimeDataId && { workflowRuntimeDataId }),
requestedByUserId,
},
customerId,
});
Expand Down
22 changes: 22 additions & 0 deletions services/workflows-service/src/user/user.controller.internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ export class UserControllerInternal {
);
}

@common.Get(':id')
@UseGuards(AdminAuthGuard)
@swagger.ApiParam({ name: 'id', type: String, description: 'User ID' })
@swagger.ApiOkResponse({ type: UserModel })
@swagger.ApiNotFoundResponse({ description: 'User not found' })
@swagger.ApiForbiddenResponse()
async getById(@common.Param('id') id: string): Promise<UserModel> {
return this.service.getByIdUnscoped(id, {
select: {
id: true,
firstName: true,
lastName: true,
email: true,
phone: true,
avatarUrl: true,
updatedAt: true,
createdAt: true,
roles: true,
},
});
}

@common.Post()
@swagger.ApiCreatedResponse({ type: [UserModel] })
@UseGuards(AdminAuthGuard)
Expand Down

0 comments on commit 5705dbd

Please sign in to comment.