Skip to content

Commit

Permalink
feat: added supporters page (#216)
Browse files Browse the repository at this point in the history
* fix: conflicts with master branch

* feat: dev and staging gh actions

* feat: done supporters page
  • Loading branch information
fagundesjg authored May 17, 2024
1 parent 0d9053f commit 8854303
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: [develop]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: setup node js
uses: actions/setup-node@v4
with:
node-version: 18.18.x

- run: npm install

- name: Create .env file
run: |
touch .env
echo VITE_API_URL=${{ secrets.DEV_VITE_API_URL }} >> .env
cat .env
- run: npm run build

- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: sa-east-1
- run: aws s3 sync ./dist s3://dev.sos-rs.com
34 changes: 34 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: [staging]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: setup node js
uses: actions/setup-node@v4
with:
node-version: 18.18.x

- run: npm install

- name: Create .env file
run: |
touch .env
echo VITE_API_URL=${{ secrets.STG_VITE_API_URL }} >> .env
cat .env
- run: npm run build

- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: sa-east-1
- run: aws s3 sync ./dist s3://stg.sos-rs.com
6 changes: 6 additions & 0 deletions src/components/BurgerMenu/BurgerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CircleHelp,
CirclePlus,
DoorOpen,
HeartHandshake,
Info,
LinkIcon,
Menu,
Expand Down Expand Up @@ -65,6 +66,11 @@ const BurgerMenu = () => {
link="/politica-de-privacidade"
icon={<Info className="w-4 h-4" />}
/>
<BurguerMenuItem
label="Apoiadores"
link="/apoiadores"
icon={<HeartHandshake className="w-4 h-4" />}
/>
<Separator />
{partners.length > 0 && (
<Fragment>
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useViaCep } from './useViaCep';
import { usePartners } from './usePartners';
import { useGithubContributors } from './useGithubContributors';
import { useAuthRoles } from './useAuthRoles';
import { useSupporters } from './useSupporters';

export {
useShelters,
Expand All @@ -26,4 +27,5 @@ export {
usePartners,
useGithubContributors,
useAuthRoles,
useSupporters,
};
3 changes: 3 additions & 0 deletions src/hooks/useSupporters/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { useSupporters } from './useSupporters';

export { useSupporters };
8 changes: 8 additions & 0 deletions src/hooks/useSupporters/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface ISupporter {
id: string;
name: string;
imageUrl: string;
link: string;
createdAt: string;
updatedAt?: string | null;
}
11 changes: 11 additions & 0 deletions src/hooks/useSupporters/useSupporters.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useFetch } from '../useFetch';
import { ISupporter } from './types';

const useSupporters = () => {
return useFetch<ISupporter[]>('/supporters', {
initialValue: [],
cache: true,
});
};

export { useSupporters };
41 changes: 41 additions & 0 deletions src/pages/Supporters/Supporters.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { BurgerMenu, Header, LoadingScreen } from '@/components';
import WithTooltip from '@/components/ui/with-tooltip';
import { useSupporters } from '@/hooks';
import { Link } from 'react-router-dom';

const Supporters = () => {
const { data: supporters, loading } = useSupporters();

if (loading) return <LoadingScreen />;

return (
<div className="flex flex-col h-screen items-center bg-gray-50 overflow-auto">
<Header title="SOS Rio Grande do Sul" startAdornment={<BurgerMenu />} />
<div className="flex flex-col gap-4 p-4 max-w-5xl pb-8 w-full">
<h2 className="text-4xl pt-4 font-semibold !text-zinc-900">
Apoiadores do projeto
</h2>
<div className="grid grid-cols-2 md:grid-cols-4 w-full gap-4 md:gap-8 mt-8">
{supporters
.sort((a, b) => a.createdAt.localeCompare(b.createdAt))
.map((supporter, idx) => (
<Link key={idx} to={supporter.link}>
<WithTooltip content={supporter.name}>
<div className="bg-white flex flex-col gap-2 w-full aspect-square p-4 justify-between shadow-sm rounded-md hover:border-text hover:cursor-pointer">
<div
style={{
backgroundImage: `url('${supporter.imageUrl}')`,
}}
className="flex-1 bg-center w-full bg-contain bg-no-repeat"
/>
</div>
</WithTooltip>
</Link>
))}
</div>
</div>
</div>
);
};

export { Supporters };
3 changes: 3 additions & 0 deletions src/pages/Supporters/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Supporters } from './Supporters';

export { Supporters };
3 changes: 2 additions & 1 deletion src/pages/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SignIn } from './SignIn';

import { Home } from './Home';
import { Shelter } from './Shelter';
import { EditShelterSupply } from './EditShelterSupply';
Expand All @@ -8,6 +7,7 @@ import { CreateShelter } from './CreateShelter';
import { UpdateShelter } from './UpdateShelter';
import { PrivacyPolicy } from './PrivacyPolicy';
import { AboutUs } from './AboutUs';
import { Supporters } from './Supporters';

export {
SignIn,
Expand All @@ -19,4 +19,5 @@ export {
UpdateShelter,
PrivacyPolicy,
AboutUs,
Supporters,
};
2 changes: 2 additions & 0 deletions src/routes/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
UpdateShelter,
PrivacyPolicy,
AboutUs,
Supporters,
} from '@/pages';

const Routes = () => {
Expand All @@ -27,6 +28,7 @@ const Routes = () => {
<Route path="/entrar" element={<SignIn />} />
<Route path="/politica-de-privacidade" element={<PrivacyPolicy />} />
<Route path="/sobre-nos" element={<AboutUs />} />
<Route path="/apoiadores" element={<Supporters />} />
<Route path="*" element={<Navigate to="/" />} />
</Switch>
);
Expand Down

0 comments on commit 8854303

Please sign in to comment.