Skip to content

Commit

Permalink
Resolves SOS-RS#284 - Padronizar Termos: Alterar "necessita urgenteme…
Browse files Browse the repository at this point in the history
…nte" para "precisa com urgência" (SOS-RS#288)

Relacionado à issue:
SOS-RS#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).
  • Loading branch information
vinny-silveira authored May 22, 2024
2 parents 02065f5 + dc0bb64 commit 2275040
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 101 deletions.
23 changes: 23 additions & 0 deletions src/components/ui/badge-variants.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { cva } from "class-variance-authority";

const badgeVariants = cva(
"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",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
outline: "text-foreground",
},
},
defaultVariants: {
variant: "default",
},
}
);

export { badgeVariants };
31 changes: 6 additions & 25 deletions src/components/ui/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react";
import { type VariantProps } from "class-variance-authority";

import { cn } from "@/lib/utils"

const badgeVariants = cva(
"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",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
outline: "text-foreground",
},
},
defaultVariants: {
variant: "default",
},
}
)
import { cn } from "@/lib/utils";
import { badgeVariants } from "./badge-variants";

export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
Expand All @@ -30,7 +11,7 @@ export interface BadgeProps
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
)
);
}

export { Badge, badgeVariants }
export { Badge };
32 changes: 32 additions & 0 deletions src/components/ui/button-variants.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { cva } from 'class-variance-authority';

const buttonVariants = cva(
'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',
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
}
);

export { buttonVariants };
34 changes: 3 additions & 31 deletions src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
import * as React from 'react';
import { Slot } from '@radix-ui/react-slot';
import { cva, type VariantProps } from 'class-variance-authority';
import { type VariantProps } from 'class-variance-authority';

import { cn } from '@/lib/utils';
import { Loader } from 'lucide-react';

const buttonVariants = cva(
'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',
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
}
);
import { buttonVariants } from './button-variants';

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
Expand Down Expand Up @@ -70,4 +42,4 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
);
Button.displayName = 'Button';

export { Button, buttonVariants };
export { Button };
10 changes: 10 additions & 0 deletions src/hooks/useAuthRoles/MappedRoles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AccessLevel } from '@/service/sessions/types';

const MappedRoles: Record<AccessLevel, AccessLevel[]> = {
Admin: ['Admin'],
DistributionCenter: ['Admin', 'DistributionCenter'],
Staff: ['Admin', 'Staff'],
User: ['Admin', 'Staff', 'DistributionCenter', 'User'],
};

export default MappedRoles;
8 changes: 1 addition & 7 deletions src/hooks/useAuthRoles/useAuthRoles.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { useContext } from 'react';

import { SessionContext } from '@/contexts';
import MappedRoles from '@/hooks/useAuthRoles/MappedRoles';
import { AccessLevel } from '@/service/sessions/types';

const MappedRoles: Record<AccessLevel, AccessLevel[]> = {
Admin: ['Admin'],
DistributionCenter: ['Admin', 'DistributionCenter'],
Staff: ['Admin', 'Staff'],
User: ['Admin', 'Staff', 'DistributionCenter', 'User'],
};

const useAuthRoles = (...roles: AccessLevel[]) => {
const { session } = useContext(SessionContext);

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useShelters/useShelters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const useShelters = (options: IUseShelterOptions = {}) => {
if (!append) setLoading(false);
});
},
[]
[cache]
);

useEffect(() => {
Expand Down
35 changes: 1 addition & 34 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,6 @@ function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

/**
* deprecated
*/
function variantStatusPriority(priority: SupplyPriority) {
if (priority === SupplyPriority.Needing) return 'danger';
if (priority === SupplyPriority.Urgent) return 'warn';
if (priority === SupplyPriority.NotNeeded) return 'alert';
if (priority === SupplyPriority.Remaining) return 'success';
}

/**
* deprecated
*/
const colorStatusPriority = (priority: SupplyPriority) => {
if (priority === SupplyPriority.Needing) return 'bg-[#f69f9d]';
if (priority === SupplyPriority.Urgent) return 'bg-[#f8b993]';
if (priority === SupplyPriority.NotNeeded) return 'bg-[#f9cf8d]';
if (priority === SupplyPriority.Remaining) return 'bg-[#63bc43]';
};

/**
* deprecated
*/
function nameStatusPriority(priority: SupplyPriority) {
if (priority === SupplyPriority.Needing) return 'Precisa urgentimente';
if (priority === SupplyPriority.Urgent) return 'Precisa';
if (priority === SupplyPriority.NotNeeded) return 'Não preciso';
if (priority === SupplyPriority.Remaining) return 'Disponível para doação';
}

function getAvailabilityProps(props: {
capacity?: number | null;
shelteredPeople?: number | null;
Expand Down Expand Up @@ -72,7 +42,7 @@ function getAvailabilityProps(props: {
}

const priorityOptions: Record<SupplyPriority, string> = {
[SupplyPriority.Urgent]: 'Necessita urgente',
[SupplyPriority.Urgent]: 'Precisa com urgência',
[SupplyPriority.Needing]: 'Precisa',
[SupplyPriority.Remaining]: 'Disponível para doação',
[SupplyPriority.NotNeeded]: 'Não preciso',
Expand Down Expand Up @@ -185,9 +155,6 @@ export {
getAvailabilityProps,
group,
getSupplyPriorityProps,
variantStatusPriority,
colorStatusPriority,
nameStatusPriority,
priorityOptions,
groupShelterSuppliesByTag,
removeDuplicatesByField,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditShelterSupply/EditShelterSupply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const EditShelterSupply = () => {
title="Escolha a prioridade do item"
options={[
{
label: 'Precisa urgente',
label: 'Precisa com urgência',
value: `${SupplyPriority.Urgent}`,
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/components/Filter/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const Filter = (props: IFilterProps) => {
<div className="flex flex-col gap-2 w-full my-4">
<p className="text-sm md:text-lg font-medium">Busca avançada</p>
<p className="text-muted-foreground text-sm md:text-lg font-medium">
Você pode buscar pelo item que os abrigos precisam urgentemente
Você pode buscar pelo item que os abrigos precisam com urgência
de doação ou por itens que os abrigos tem disponibilidade para
doar.
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const ShelterListItem = (props: IShelterListItemProps) => {
tags={tags.NeedVolunteers.map(getChipProps)}
/>
<ShelterSupplyCategoryRow
title="Necessita urgente doações de:"
title="Precisa com urgência de doações de:"
tags={tags.NeedDonations.map(getChipProps)}
/>
<ShelterSupplyCategoryRow
Expand Down

0 comments on commit 2275040

Please sign in to comment.