Skip to content

Commit 2275040

Browse files
Resolves #284 - Padronizar Termos: Alterar "necessita urgentemente" para "precisa com urgência" (#288)
Relacionado à issue: #284 Ao rodar o lint, reparei que o projeto tinha 5 warnings, relacionados a `Separate Constants or Functions from Components`. antes: ![image](https://github.com/SOS-RS/frontend/assets/70142962/45bb57da-7f61-419c-ad00-c97dd6edcc75) depois: ![image](https://github.com/SOS-RS/frontend/assets/70142962/d91c2674-7a30-45c5-b515-9d971958fc78) _Indicates that Fast Refresh works best when a file only exports components. If you have constants or functions that are not part of the component, move them to a separate file._ Consegui resolver 4 deles (não tenho taaaanta experiência com forms, rs), então achei válido manter nesse PR, mas caso fuja do padrão esperado por vocês, posso remover e deixar esse PR focado no objetivo da issue relacionada. **PS:** <s>ainda preciso instalar o backend para verificar se preciso modificar algo relacionado a esta issue</s> (**_edit:_** não encontrei nada no backend).
2 parents 02065f5 + dc0bb64 commit 2275040

File tree

11 files changed

+80
-101
lines changed

11 files changed

+80
-101
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { cva } from "class-variance-authority";
2+
3+
const badgeVariants = cva(
4+
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
5+
{
6+
variants: {
7+
variant: {
8+
default:
9+
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
10+
secondary:
11+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
12+
destructive:
13+
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
14+
outline: "text-foreground",
15+
},
16+
},
17+
defaultVariants: {
18+
variant: "default",
19+
},
20+
}
21+
);
22+
23+
export { badgeVariants };

src/components/ui/badge.tsx

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
1-
import * as React from "react"
2-
import { cva, type VariantProps } from "class-variance-authority"
1+
import * as React from "react";
2+
import { type VariantProps } from "class-variance-authority";
33

4-
import { cn } from "@/lib/utils"
5-
6-
const badgeVariants = cva(
7-
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
8-
{
9-
variants: {
10-
variant: {
11-
default:
12-
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
13-
secondary:
14-
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
15-
destructive:
16-
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
17-
outline: "text-foreground",
18-
},
19-
},
20-
defaultVariants: {
21-
variant: "default",
22-
},
23-
}
24-
)
4+
import { cn } from "@/lib/utils";
5+
import { badgeVariants } from "./badge-variants";
256

267
export interface BadgeProps
278
extends React.HTMLAttributes<HTMLDivElement>,
@@ -30,7 +11,7 @@ export interface BadgeProps
3011
function Badge({ className, variant, ...props }: BadgeProps) {
3112
return (
3213
<div className={cn(badgeVariants({ variant }), className)} {...props} />
33-
)
14+
);
3415
}
3516

36-
export { Badge, badgeVariants }
17+
export { Badge };
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { cva } from 'class-variance-authority';
2+
3+
const buttonVariants = cva(
4+
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
5+
{
6+
variants: {
7+
variant: {
8+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
9+
destructive:
10+
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
11+
outline:
12+
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
13+
secondary:
14+
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
15+
ghost: 'hover:bg-accent hover:text-accent-foreground',
16+
link: 'text-primary underline-offset-4 hover:underline',
17+
},
18+
size: {
19+
default: 'h-10 px-4 py-2',
20+
sm: 'h-9 rounded-md px-3',
21+
lg: 'h-11 rounded-md px-8',
22+
icon: 'h-10 w-10',
23+
},
24+
},
25+
defaultVariants: {
26+
variant: 'default',
27+
size: 'default',
28+
},
29+
}
30+
);
31+
32+
export { buttonVariants };

src/components/ui/button.tsx

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,10 @@
11
import * as React from 'react';
22
import { Slot } from '@radix-ui/react-slot';
3-
import { cva, type VariantProps } from 'class-variance-authority';
3+
import { type VariantProps } from 'class-variance-authority';
44

55
import { cn } from '@/lib/utils';
66
import { Loader } from 'lucide-react';
7-
8-
const buttonVariants = cva(
9-
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
10-
{
11-
variants: {
12-
variant: {
13-
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
14-
destructive:
15-
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
16-
outline:
17-
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
18-
secondary:
19-
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
20-
ghost: 'hover:bg-accent hover:text-accent-foreground',
21-
link: 'text-primary underline-offset-4 hover:underline',
22-
},
23-
size: {
24-
default: 'h-10 px-4 py-2',
25-
sm: 'h-9 rounded-md px-3',
26-
lg: 'h-11 rounded-md px-8',
27-
icon: 'h-10 w-10',
28-
},
29-
},
30-
defaultVariants: {
31-
variant: 'default',
32-
size: 'default',
33-
},
34-
}
35-
);
7+
import { buttonVariants } from './button-variants';
368

379
export interface ButtonProps
3810
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
@@ -70,4 +42,4 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
7042
);
7143
Button.displayName = 'Button';
7244

73-
export { Button, buttonVariants };
45+
export { Button };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { AccessLevel } from '@/service/sessions/types';
2+
3+
const MappedRoles: Record<AccessLevel, AccessLevel[]> = {
4+
Admin: ['Admin'],
5+
DistributionCenter: ['Admin', 'DistributionCenter'],
6+
Staff: ['Admin', 'Staff'],
7+
User: ['Admin', 'Staff', 'DistributionCenter', 'User'],
8+
};
9+
10+
export default MappedRoles;

src/hooks/useAuthRoles/useAuthRoles.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import { useContext } from 'react';
22

33
import { SessionContext } from '@/contexts';
4+
import MappedRoles from '@/hooks/useAuthRoles/MappedRoles';
45
import { AccessLevel } from '@/service/sessions/types';
56

6-
const MappedRoles: Record<AccessLevel, AccessLevel[]> = {
7-
Admin: ['Admin'],
8-
DistributionCenter: ['Admin', 'DistributionCenter'],
9-
Staff: ['Admin', 'Staff'],
10-
User: ['Admin', 'Staff', 'DistributionCenter', 'User'],
11-
};
12-
137
const useAuthRoles = (...roles: AccessLevel[]) => {
148
const { session } = useContext(SessionContext);
159

src/hooks/useShelters/useShelters.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const useShelters = (options: IUseShelterOptions = {}) => {
5353
if (!append) setLoading(false);
5454
});
5555
},
56-
[]
56+
[cache]
5757
);
5858

5959
useEffect(() => {

src/lib/utils.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,6 @@ function cn(...inputs: ClassValue[]) {
1212
return twMerge(clsx(inputs));
1313
}
1414

15-
/**
16-
* deprecated
17-
*/
18-
function variantStatusPriority(priority: SupplyPriority) {
19-
if (priority === SupplyPriority.Needing) return 'danger';
20-
if (priority === SupplyPriority.Urgent) return 'warn';
21-
if (priority === SupplyPriority.NotNeeded) return 'alert';
22-
if (priority === SupplyPriority.Remaining) return 'success';
23-
}
24-
25-
/**
26-
* deprecated
27-
*/
28-
const colorStatusPriority = (priority: SupplyPriority) => {
29-
if (priority === SupplyPriority.Needing) return 'bg-[#f69f9d]';
30-
if (priority === SupplyPriority.Urgent) return 'bg-[#f8b993]';
31-
if (priority === SupplyPriority.NotNeeded) return 'bg-[#f9cf8d]';
32-
if (priority === SupplyPriority.Remaining) return 'bg-[#63bc43]';
33-
};
34-
35-
/**
36-
* deprecated
37-
*/
38-
function nameStatusPriority(priority: SupplyPriority) {
39-
if (priority === SupplyPriority.Needing) return 'Precisa urgentimente';
40-
if (priority === SupplyPriority.Urgent) return 'Precisa';
41-
if (priority === SupplyPriority.NotNeeded) return 'Não preciso';
42-
if (priority === SupplyPriority.Remaining) return 'Disponível para doação';
43-
}
44-
4515
function getAvailabilityProps(props: {
4616
capacity?: number | null;
4717
shelteredPeople?: number | null;
@@ -72,7 +42,7 @@ function getAvailabilityProps(props: {
7242
}
7343

7444
const priorityOptions: Record<SupplyPriority, string> = {
75-
[SupplyPriority.Urgent]: 'Necessita urgente',
45+
[SupplyPriority.Urgent]: 'Precisa com urgência',
7646
[SupplyPriority.Needing]: 'Precisa',
7747
[SupplyPriority.Remaining]: 'Disponível para doação',
7848
[SupplyPriority.NotNeeded]: 'Não preciso',
@@ -185,9 +155,6 @@ export {
185155
getAvailabilityProps,
186156
group,
187157
getSupplyPriorityProps,
188-
variantStatusPriority,
189-
colorStatusPriority,
190-
nameStatusPriority,
191158
priorityOptions,
192159
groupShelterSuppliesByTag,
193160
removeDuplicatesByField,

src/pages/EditShelterSupply/EditShelterSupply.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const EditShelterSupply = () => {
153153
title="Escolha a prioridade do item"
154154
options={[
155155
{
156-
label: 'Precisa urgente',
156+
label: 'Precisa com urgência',
157157
value: `${SupplyPriority.Urgent}`,
158158
},
159159
{

src/pages/Home/components/Filter/Filter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const Filter = (props: IFilterProps) => {
176176
<div className="flex flex-col gap-2 w-full my-4">
177177
<p className="text-sm md:text-lg font-medium">Busca avançada</p>
178178
<p className="text-muted-foreground text-sm md:text-lg font-medium">
179-
Você pode buscar pelo item que os abrigos precisam urgentemente
179+
Você pode buscar pelo item que os abrigos precisam com urgência
180180
de doação ou por itens que os abrigos tem disponibilidade para
181181
doar.
182182
</p>

0 commit comments

Comments
 (0)