Skip to content

Commit

Permalink
Merge branch 'main' into dbaric99/mobile-navigation-and-router
Browse files Browse the repository at this point in the history
# Conflicts:
#	apps/app/package.json
#	apps/app/src/App.tsx
  • Loading branch information
dbaric99 committed Dec 22, 2024
2 parents 6d7f054 + 9b9e85a commit 8d2e46f
Show file tree
Hide file tree
Showing 57 changed files with 1,644 additions and 112 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- '2024'

workflow_dispatch:

Expand All @@ -30,7 +31,7 @@ jobs:
run: yarn install --immutable

- name: Build frontend web apps
run: yarn build --filter=admin... --filter=sponsor... --filter=web...
run: yarn build --filter=admin... --filter=sponsor... --filter=web... --filter=app...

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -49,6 +50,7 @@ jobs:
file: ./apps/api/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }},
ghcr.io/${{ github.repository }}:${{ github.ref_name }},
ghcr.io/${{ github.repository }}:${{ github.ref_name == 'main' && 'latest' || 'unstable' }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down Expand Up @@ -90,4 +92,4 @@ jobs:
- name: Run Ansible playbook
run: |
eval $(ssh-agent)
./infrastructure/scripts/ansible-playbook.sh production api
./infrastructure/scripts/ansible-playbook.sh ${{ github.ref_name == 'main' && 'production' || github.ref_name }} api
6 changes: 3 additions & 3 deletions .github/workflows/docker-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches-ignore:
- main
- '2024'

workflow_dispatch:

Expand All @@ -30,7 +31,7 @@ jobs:
run: yarn install --immutable

- name: Build frontend web apps
run: yarn build --filter=admin... --filter=sponsor... --filter=web...
run: yarn build --filter=admin... --filter=sponsor... --filter=web... --filter=app...

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -48,7 +49,6 @@ jobs:
context: .
file: ./apps/api/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }},
ghcr.io/${{ github.repository }}:${{ github.ref_name == 'main' && 'latest' || 'unstable' }}
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ COPY --from=installer --chown=nestjs:nestjs /app .
COPY --chown=nestjs:nestjs apps/admin/dist ./apps/admin/dist
COPY --chown=nestjs:nestjs apps/sponsor/dist ./apps/sponsor/dist
COPY --chown=nestjs:nestjs apps/web/dist ./apps/web/dist
COPY --chown=nestjs:nestjs apps/app/dist ./apps/app/dist

CMD node apps/api/dist/src/main.js
2 changes: 1 addition & 1 deletion apps/api/db/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@
"breakpoints": true
}
]
}
}
2 changes: 2 additions & 0 deletions apps/api/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export const company = pgTable('company', {
description: text('description'),
opportunitiesDescription: text('opportunities_description'),
website: text('website_url'),
instagram: text('instagram_url'),
linkedin: text('linkedin_url'),
logoImage: text('logo_image'),
landingImage: text('landing_image'),
landingImageCompanyCulture: text('landing_image_company_culture'),
Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import { SurveyQuestionModule } from './survey-question/survey-question.module';
? [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', '..', '..', 'web', 'dist'),
exclude: ['/api/(.*)', '/sponsor/(.*)', '/admin/(.*)'],
exclude: ['/api/(.*)', '/app/(.*)', '/sponsor/(.*)', '/admin/(.*)'],
}),
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', '..', '..', 'app', 'dist'),
serveRoot: '/app',
}),
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', '..', '..', 'sponsor', 'dist'),
Expand Down
10 changes: 10 additions & 0 deletions apps/api/src/company/company.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class CompanyService {
description: company.description,
opportunitiesDescription: company.opportunitiesDescription,
website: company.website,
instagram: company.instagram,
linkedin: company.linkedin,
booth: booth.name,
logoImage: company.logoImage,
landingImage: company.landingImage,
Expand All @@ -69,6 +71,8 @@ export class CompanyService {
description: company.description,
opportunitiesDescription: company.opportunitiesDescription,
website: company.website,
instagram: company.instagram,
linkedin: company.linkedin,
logoImage: company.logoImage,
landingImage: company.landingImage,
landingImageCompanyCulture: company.landingImageCompanyCulture,
Expand Down Expand Up @@ -97,6 +101,8 @@ export class CompanyService {
description: company.description,
opportunitiesDescription: company.opportunitiesDescription,
website: company.website,
instagram: company.instagram,
linkedin: company.linkedin,
logoImage: company.logoImage,
landingImage: company.landingImage,
landingImageCompanyCulture: company.landingImageCompanyCulture,
Expand Down Expand Up @@ -176,6 +182,8 @@ export class CompanyService {
username: dto.username,
description: dto.description,
website: dto.website,
instagram: dto.instagram,
linkedin: dto.linkedin,
codeId: dto.codeId,
})
.where(eq(company.id, id))
Expand All @@ -198,6 +206,8 @@ export class CompanyService {
.set({
description: data.description,
website: data.website,
instagram: data.instagram,
linkedin: data.linkedin,
opportunitiesDescription: data.opportunitiesDescription,
})
.where(eq(company.id, companyId))
Expand Down
10 changes: 9 additions & 1 deletion apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const setupProxies = (app: INestApplication) => {
(pathname: string) =>
!pathname.startsWith('/api') &&
!pathname.startsWith('/admin') &&
!pathname.startsWith('/sponsor'),
!pathname.startsWith('/sponsor') &&
!pathname.startsWith('/app'),
{ target: 'http://localhost:3004' },
),
);
Expand All @@ -57,6 +58,13 @@ const setupProxies = (app: INestApplication) => {
'/sponsor',
createProxyMiddleware({ target: 'http://localhost:3003' }),
);

app.use(
'/app',
createProxyMiddleware({
target: 'http://localhost:3005',
}),
);
}
};

Expand Down
7 changes: 3 additions & 4 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
"preview": "vite preview"
},
"dependencies": {
"@types/react": "18",
"@types/react-dom": "18",
"react": "18",
"react-dom": "18",
"clsx": "^2.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^7.0.2"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions apps/app/src/assets/icons/arrow-down-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 117 additions & 0 deletions apps/app/src/compontents/Dropdown/Dropdown.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
.wrapper {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 4px;
position: relative;

.label {
@include paragraph-14;
color: $black-50;
}

.mainButton {
@include paragraph-16;
background-color: $black-10;
outline: none;
border: none;
cursor: pointer;
width: 100%;

box-sizing: border-box;
padding: 16px;
border-radius: 4px;

display: flex;
justify-content: space-between;
align-items: center;
gap: 8px;

transition: box-shadow 200ms;

.arrow {
transition: 200ms;
}

&.isOpen {
box-shadow: inset 0 0 0 1px $black-30;

.arrow {
rotate: 180deg;
}
}

&.isError {
box-shadow: inset 0 0 0 1px $error-light;
}
}

.errorLabel {
@include paragraph-14;
color: $error-light;
}

.optionsWrapper {
box-sizing: border-box;
padding: 16px;
box-shadow: 0px 4px 16px 0px rgba(0, 0, 0, 0.12);
background-color: white;
border-radius: 4px;
position: absolute;
top: 86px;
width: 100%;
z-index: 100;

.innerContainer {
display: block;
width: 100%;
box-sizing: border-box;

max-height: 310px;
overflow-y: auto;

&::-webkit-scrollbar {
width: 4px;
border-radius: 100px;
}

&::-webkit-scrollbar-track {
background: $black-10;
border-radius: 100px;
}

&::-webkit-scrollbar-thumb {
background: $primary-black;
border-radius: 100px;
}

&::-webkit-scrollbar-thumb:hover {
background: $primary-black;
}

.divider {
@include dottedBreak(rgba(23, 22, 21, 0.65));
height: 4px;
margin-bottom: 16px;
margin-top: 8px;
}

.option {
background: none;
outline: none;
border: none;
@include paragraph-16;
margin: 0;
padding: 0;
text-align: left;
cursor: pointer;
width: 100%;

&.selected {
color: $black-30;
cursor: default;
}
}
}
}
}
90 changes: 90 additions & 0 deletions apps/app/src/compontents/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { useRef, useState } from 'react';
import React from 'react';
import c from './Dropdown.module.scss';
import { DropdownOption } from './DropdownOption';
import ArrowIcon from '../../assets/icons/arrow-down-1.svg';
import clsx from 'clsx';
import { useClickOutside } from '../../hooks/useClickOutside';

type DropdownProps = {
label: string;
placeholder: string;
options: DropdownOption[];
setOption: (option: DropdownOption) => void;
selectedOption: DropdownOption | undefined;
errorLabel?: string;
showError?: boolean;
width?: string;
hasError?: boolean;
};

const Dropdown = ({
label,
placeholder,
options,
setOption,
selectedOption,
errorLabel,
width = 'auto',
hasError = false,
}: DropdownProps) => {
const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef(null);

const toggle = () => {
setIsOpen(!isOpen);
};

function handleOptionSelected(option: DropdownOption) {
setOption(option);
setIsOpen(false);
}

useClickOutside(dropdownRef, () => setIsOpen(false));

const widthStyle = { width: width };
const showError = (hasError || !selectedOption?.value) && !isOpen;

return (
<div className={c.wrapper} style={widthStyle} ref={dropdownRef}>
{label && <label className={c.label}>{label}</label>}

<button
className={clsx({
[c.mainButton]: true,
[c.isOpen]: isOpen,
[c.isError]: showError,
})}
onClick={toggle}>
{selectedOption?.label || placeholder}
<img className={c.arrow} src={ArrowIcon} alt='arrow' />
</button>

{showError && <div className={c.errorLabel}>{errorLabel}</div>}

{isOpen && (
<div className={c.optionsWrapper}>
<div className={c.innerContainer}>
{options.map((option, i) => (
<React.Fragment key={option.value}>
{i !== 0 && <div className={c.divider} key={i}></div>}
<button
disabled={option.value === selectedOption?.value}
className={clsx({
[c.option]: true,
[c.selected]: option.value === selectedOption?.value,
})}
key={option.value}
onClick={() => handleOptionSelected(option)}>
{option.label}
</button>
</React.Fragment>
))}
</div>
</div>
)}
</div>
);
};

export default Dropdown;
4 changes: 4 additions & 0 deletions apps/app/src/compontents/Dropdown/DropdownOption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type DropdownOption = {
value: string;
label: string;
};
3 changes: 3 additions & 0 deletions apps/app/src/compontents/Dropdown/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Dropdown from './Dropdown';

export default Dropdown;
Loading

0 comments on commit 8d2e46f

Please sign in to comment.