Skip to content

Commit

Permalink
feat: show only the edit button if you own it
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinx0 committed Nov 7, 2024
1 parent adb2b6c commit db63479
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
9 changes: 1 addition & 8 deletions src/app/solicitudes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,7 @@ export default function ListaSolicitudes() {
</div>
) : (
requests.map((caso) => (
<SolicitudCard
isHref={true}
towns={towns}
key={caso.id}
caso={caso}
button={{ text: 'Editar', link: '/solicitudes/editar/' }}
isEdit={true}
/>
<SolicitudCard isHref={true} towns={towns} key={caso.id} caso={caso} isEdit={true} />
))
)}
</div>
Expand Down
18 changes: 3 additions & 15 deletions src/components/SolicitudCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,10 @@ type SolicitudCardProps = {
caso: HelpRequestData;
towns: Town[];
isHref?: boolean;
button?: SolicitudCardButton;
isEdit?: boolean;
};

type SolicitudCardButton = {
text: string;
link: string;
};

export default function SolicitudCard({
caso,
towns,
isHref = true,
button = { text: 'Ver solicitud', link: '/solicitud/' },
isEdit = false,
}: SolicitudCardProps) {
export default function SolicitudCard({ caso, towns, isHref = true, isEdit = false }: SolicitudCardProps) {
const session = useSession();

const additionalInfo = caso.additional_info as HelpRequestAdditionalInfo;
Expand Down Expand Up @@ -184,10 +172,10 @@ export default function SolicitudCard({
)}
{isHref && (
<Link
href={button.link + caso.id}
href={'/solicitud/' + caso.id}
className={`w-full rounded-xl text-center px-4 py-2 font-semibold text-white sm:w-auto bg-gray-700 hover:bg-gray-800 transition-all`}
>
{button.text}
Ver solicitud
</Link>
)}
<AsignarSolicitudButton helpRequest={caso} />
Expand Down

0 comments on commit db63479

Please sign in to comment.