Skip to content

Commit b5b9a9f

Browse files
authored
Merge pull request #212 from estartando-devs/refactor/id-card-2024
Refactor/id-card-2024
2 parents c0423fe + 49dd934 commit b5b9a9f

File tree

7 files changed

+60
-20
lines changed

7 files changed

+60
-20
lines changed

src/components/IdCard/idCardHandlers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const useIdCardHandlers = ({
1212
src: string;
1313
alt: string;
1414
}>(image);
15+
1516
const courseKey = getKeyByCourse(course);
1617

1718
useEffect(() => {

src/components/IdCard/styles.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const styleByCourse: Record<CourseKey, CourseStyle> = {
2020
colorTitle: '#6C63FF',
2121
backgroundSrc: '/bg-card-design.png',
2222
},
23+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
24+
// @ts-ignore
25+
softskills: {
26+
colorTitle: '##F76B15',
27+
backgroundSrc: '/bg-card-design.png',
28+
},
2329
};
2430

2531
export const Container = styled.div`

src/components/IdCard/utils/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CourseKey } from '../../../mocks';
2-
import { CourseKeyByName } from '../../../types';
2+
import { CourseKeyByName, CourseKeyByNameTeam } from '../../../types';
33

44
export const getKeyByCourse = (course: string) => {
55
if (!course) {
@@ -9,6 +9,7 @@ export const getKeyByCourse = (course: string) => {
99
'Desenvolvimento Web': CourseKeyByName['Desenvolvimento Web'],
1010
'Desenvolvimento Backend': CourseKeyByName['Desenvolvimento Backend'],
1111
'Design UI/UX': CourseKeyByName['Design UI/UX'],
12+
'Soft Skills': CourseKeyByNameTeam['Soft Skills'],
1213
};
1314
return dict[course] as CourseKey;
1415
};

src/components/IdCardForm/index.tsx

+25-7
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import Cropper from 'react-easy-crop';
77
import { FormProvider, useForm } from 'react-hook-form';
88
import { useTheme } from 'styled-components';
99
import { useCropImage } from '../../hooks/useCropImage';
10-
import { CourseNameByKey, Status } from '../../types';
10+
import { CourseNameByKey, CourseNameByKeyTeam, Status } from '../../types';
1111
import { getCroppedImg } from '../../utils/cropImage';
1212
import { Input } from '../Input';
1313
import { Logo } from '../Logo';
1414
import { Typography } from '../Typography';
1515
import { FileIcon } from './components/FileIcon';
1616
import * as S from './styles';
1717

18-
export const IdCardForm = () => {
18+
export const IdCardForm = (props: { team?: boolean }) => {
1919
const router = useRouter();
2020
const theme = useTheme();
2121
const [imagePreview, setImagePreview] = useState(null);
@@ -37,6 +37,12 @@ export const IdCardForm = () => {
3737

3838
const handleSubmit = ({ email, ...rest }: Record<string, string>) => {
3939
setCookies('nagato', JSON.stringify({ ...rest }));
40+
41+
if (props.team) {
42+
router.push(`/id-card/time/${rest.name}`);
43+
return;
44+
}
45+
4046
router.push(`/id-card/${email}`);
4147
return;
4248

@@ -150,11 +156,23 @@ export const IdCardForm = () => {
150156
id="course"
151157
color={theme.palette.design.white}
152158
>
153-
{Object.entries(CourseNameByKey).map(([key, value]) => (
154-
<option key={key} value={value}>
155-
{value}
156-
</option>
157-
))}
159+
{props.team ? (
160+
<>
161+
{Object.entries(CourseNameByKeyTeam).map(([key, value]) => (
162+
<option key={key} value={value}>
163+
{value}
164+
</option>
165+
))}
166+
</>
167+
) : (
168+
<>
169+
{Object.entries(CourseNameByKey).map(([key, value]) => (
170+
<option key={key} value={value}>
171+
{value}
172+
</option>
173+
))}
174+
</>
175+
)}
158176
</Select>
159177
</>
160178
<Input

src/pages/id-card/time/[name].tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, useToast } from '@chakra-ui/react';
1+
import { Box } from '@chakra-ui/react';
22
import { getCookie } from 'cookies-next';
33
import { GetServerSideProps } from 'next';
44
import { NextSeo } from 'next-seo';
@@ -49,7 +49,7 @@ export default function MyIdCard({
4949
profile: IdCardProps;
5050
error?: string;
5151
}) {
52-
const toast = useToast();
52+
// const toast = useToast();
5353

5454
if (error) {
5555
return (
@@ -59,15 +59,15 @@ export default function MyIdCard({
5959
);
6060
}
6161

62-
toast({
63-
position: 'top',
64-
title: 'Tudo pronto!',
65-
description:
66-
'Agora você pode compartilhar seu id card. Não esqueça de nos marcar.',
67-
status: 'success',
68-
duration: 5000,
69-
isClosable: true,
70-
});
62+
// toast({
63+
// position: 'top',
64+
// title: 'Tudo pronto!',
65+
// description:
66+
// 'Agora você pode compartilhar seu id card. Não esqueça de nos marcar.',
67+
// status: 'success',
68+
// duration: 5000,
69+
// isClosable: true,
70+
// });
7171

7272
return (
7373
<Layout>

src/pages/id-card/time/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function IdCardTeam() {
1818
display="flex"
1919
flexDirection="column"
2020
>
21-
<IdCardForm />
21+
<IdCardForm team />
2222
<Footer />
2323
</Box>
2424
</Layout>

src/types/CourseName.ts

+14
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,17 @@ export enum CourseKeyByName {
88
'Desenvolvimento Backend' = 'backend',
99
'Design UI/UX' = 'design',
1010
}
11+
12+
export enum CourseNameByKeyTeam {
13+
'frontend' = 'Desenvolvimento Web',
14+
'backend' = 'Desenvolvimento Backend',
15+
'design' = 'Design UI/UX',
16+
'softskills' = 'Soft Skills',
17+
}
18+
19+
export enum CourseKeyByNameTeam {
20+
'Desenvolvimento Web' = 'frontend',
21+
'Desenvolvimento Backend' = 'backend',
22+
'Design UI/UX' = 'design',
23+
'Soft Skills' = 'softskills',
24+
}

0 commit comments

Comments
 (0)