Skip to content

Commit

Permalink
Merge pull request #888 from BinaryStudioAcademy/staging
Browse files Browse the repository at this point in the history
staging -> development
  • Loading branch information
nikita-remeslov authored Sep 30, 2023
2 parents 3ae4fdf + 74432d6 commit 5f6771a
Show file tree
Hide file tree
Showing 30 changed files with 696 additions and 254 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ApiPath } from '~/common/enums/enums.js';
import { HttpCode } from '~/common/http/http.js';
import {
type ApiHandlerOptions,
type ApiHandlerResponse,
} from '~/common/packages/controller/controller.js';
import { type Logger } from '~/common/packages/logger/logger.js';
import { ControllerBase } from '~/common/packages/packages.js';

import { type ProxyLinkPreviewService } from './proxy-link-preview.service.js';

class ProxyLinkPreviewController extends ControllerBase {
private proxyLinkPreviewService: ProxyLinkPreviewService;

public constructor(
logger: Logger,
proxyLinkPreviewService: ProxyLinkPreviewService,
) {
super(logger, ApiPath.PROXY_LINK_PREVIEW);
this.proxyLinkPreviewService = proxyLinkPreviewService;

this.addRoute({
path: '/',
method: 'GET',
handler: (options) => {
return this.proxyLinkPreview(
options as ApiHandlerOptions<{
query: { url: string };
}>,
);
},
});
}

private async proxyLinkPreview(
options: ApiHandlerOptions<{ query: { url: string } }>,
): Promise<ApiHandlerResponse> {
return {
status: HttpCode.OK,
payload: await this.proxyLinkPreviewService.proxyLinkPreview(
options.query,
),
};
}
}

export { ProxyLinkPreviewController };
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import fetch from 'node-fetch';

class ProxyLinkPreviewService {
public async proxyLinkPreview(payload: {
url: string;
}): Promise<{ data: string }> {
const response = await fetch(payload.url);
const data = await response.text();
return { data };
}
}

export { ProxyLinkPreviewService };
12 changes: 12 additions & 0 deletions backend/src/bundles/proxy-link-preview/proxy-link-preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { logger } from '~/common/packages/packages.js';

import { ProxyLinkPreviewController } from './proxy-link-preview.controller.js';
import { ProxyLinkPreviewService } from './proxy-link-preview.service.js';

const proxyLinkPreviewService = new ProxyLinkPreviewService();
const proxyLinkPreviewController = new ProxyLinkPreviewController(
logger,
proxyLinkPreviewService,
);

export { proxyLinkPreviewController, proxyLinkPreviewService };
2 changes: 2 additions & 0 deletions backend/src/common/server-application/server-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { contactsController } from '~/bundles/contacts/contacts.js';
import { fileController } from '~/bundles/files/files.js';
import { hardSkillsController } from '~/bundles/hard-skills/hard-skills.js';
import { hiringInfoController } from '~/bundles/hiring-info/hiring-info.js';
import { proxyLinkPreviewController } from '~/bundles/proxy-link-preview/proxy-link-preview.js';
import { userDetailsController } from '~/bundles/user-details/user-details.js';
import { userController } from '~/bundles/users/users.js';
import { config, database, logger } from '~/common/packages/packages.js';
Expand All @@ -24,6 +25,7 @@ const apiV1 = new ServerAppApiBase(
...bsaBadgesController.routes,
...hiringInfoController.routes,
...chatMessagesController.routes,
...proxyLinkPreviewController.routes,
);
const serverApp = new ServerAppBase({
config,
Expand Down
209 changes: 128 additions & 81 deletions frontend/src/bundles/admin-panel/components/profile/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Grid,
Typography,
} from '~/bundles/common/components/components.js';
import { getValidClassNames } from '~/bundles/common/helpers/helpers.js';
import { mapBsaBadges } from '~/bundles/lms/helpers/map-bsa-badges.js';

import { type UserDetailsFullResponseDto } from '../../types/types.js';
Expand Down Expand Up @@ -166,101 +167,147 @@ const Profile: React.FC<Properties> = ({ userDetails, selectedRole }) => {
</Grid>
</Grid>
) : (
<Grid>
<Grid className={styles.textInfo}>
<Grid className={styles.layoutEmployer}>
<Grid className={styles.employerCard}>
<Avatar
className={styles.companyLogo}
src={userDetails.companyLogo?.url}
/>

<Grid container item className={styles.row}>
<Typography
variant="body1"
className={styles.name}
>
Employer position
</Typography>
<Typography
variant="body1"
className={styles.value}
<Grid className={styles.employerDetails}>
<Grid
container
item
className={getValidClassNames(
styles.row,
styles.position,
)}
>
{userDetails.employerPosition}
</Typography>
</Grid>
<Typography
variant="body1"
className={styles.name}
>
Employer position
</Typography>
<Typography
variant="body1"
className={styles.value}
>
{userDetails.employerPosition}
</Typography>
</Grid>

<Grid container item className={styles.row}>
<Typography
variant="body1"
className={styles.name}
>
Company name
</Typography>
<Typography
variant="body1"
className={styles.value}
<Grid
container
item
className={getValidClassNames(
styles.row,
styles.companyName,
)}
>
{userDetails.companyName}
</Typography>
</Grid>
<Typography
variant="body1"
className={styles.name}
>
Company name
</Typography>
<Typography
variant="body1"
className={styles.value}
>
{userDetails.companyName}
</Typography>
</Grid>

<Grid container item className={styles.row}>
<Typography
variant="body1"
className={styles.name}
>
Company website
</Typography>
<a
href={userDetails.companyWebsite as string}
className={styles.valueLink}
<Grid
container
item
className={getValidClassNames(
styles.row,
styles.website,
)}
>
Website link
</a>
</Grid>
<Typography
variant="body1"
className={styles.name}
>
Company website
</Typography>
<a
href={
userDetails.companyWebsite as string
}
className={styles.valueLink}
>
Website link
</a>
</Grid>

<Grid container item className={styles.row}>
<Typography
variant="body1"
className={styles.name}
<Grid
container
item
className={getValidClassNames(
styles.row,
styles.location,
)}
>
Location
</Typography>
<Typography
variant="body1"
className={styles.value}
>
{userDetails.location}
</Typography>
</Grid>

<Grid container item className={styles.row}>
<Typography
variant="body1"
className={styles.name}
>
Description
</Typography>
<Typography
variant="body1"
className={styles.value}
>
{userDetails.description}
</Typography>
</Grid>
<Typography
variant="body1"
className={styles.name}
>
Location
</Typography>
<Typography
variant="body1"
className={styles.value}
>
{userDetails.location}
</Typography>
</Grid>

<Grid container item className={styles.row}>
<Typography
variant="body1"
className={styles.name}
<Grid
container
item
className={getValidClassNames(
styles.row,
styles.employerLinkedIn,
)}
>
Linkedin Link
</Typography>
<a
href={userDetails.linkedinLink as string}
className={styles.valueLink}
<Typography
variant="body1"
className={styles.name}
>
Linkedin Link
</Typography>
<a
href={
userDetails.linkedinLink as string
}
className={styles.valueLink}
>
Linkedin link
</a>
</Grid>
<Grid
container
item
className={getValidClassNames(
styles.row,
styles.description,
)}
>
Linkedin link
</a>
<Typography
variant="body1"
className={styles.name}
>
Description
</Typography>
<Typography
variant="body1"
className={styles.value}
>
{userDetails.description}
</Typography>
</Grid>
</Grid>
</Grid>
</Grid>
Expand Down
Loading

0 comments on commit 5f6771a

Please sign in to comment.