From 5f724b0d8f750e77627ba1e3082864d8907628e9 Mon Sep 17 00:00:00 2001 From: Jasper Concepcion Date: Mon, 9 Oct 2023 09:47:47 +0800 Subject: [PATCH] feat(profile): add company logo --- app/_experiences.tsx | 32 +++++++++---- app/dashboard/experiences/_form.tsx | 56 ++++++++++++++++++++-- components/add-tech-form.tsx | 50 +++++++++++++++++-- lib/validators.ts | 1 + server/server-actions/experience-upsert.ts | 1 + 5 files changed, 125 insertions(+), 15 deletions(-) diff --git a/app/_experiences.tsx b/app/_experiences.tsx index 4bd4a0c..b7baa1f 100644 --- a/app/_experiences.tsx +++ b/app/_experiences.tsx @@ -18,6 +18,7 @@ import type { GetPortfolioWithRelations } from "@/queries"; import { format } from "date-fns/esm"; import { StackItem } from "./_stack-item"; import NextLink from "next/link"; +import NextImage from "next/image"; interface Props { experiences: GetPortfolioWithRelations["experiences"]; @@ -46,16 +47,29 @@ export function ExperienceList({ experiences = [] }: Props) { {format(exp.startedAt, "MMMM yyyy")} —{" "} {exp.endedAt ? format(exp.endedAt, "MMMM yyyy") : "Present"} -
- - - {exp.companyName} - - +
+ {exp.companyLogo && ( + + )} +
+
+ + + {exp.companyName} + + +
+ + {exp.jobTitle} + +
- - {exp.jobTitle} - {exp.jobDescription && ( )} diff --git a/app/dashboard/experiences/_form.tsx b/app/dashboard/experiences/_form.tsx index 7db76a5..3f03ba8 100644 --- a/app/dashboard/experiences/_form.tsx +++ b/app/dashboard/experiences/_form.tsx @@ -1,4 +1,5 @@ "use client"; +import "@uploadthing/react/styles.css"; import { insertExperienceSchema } from "@/lib/validators"; import type { GetExp, GetAllTech } from "@/queries"; import { @@ -25,6 +26,7 @@ import { IconCalendar, IconDeviceFloppy, IconLoader2, + IconTrash, IconX, } from "@tabler/icons-react"; import { Badge } from "@/components/ui/badge"; @@ -37,6 +39,8 @@ import { import { format } from "date-fns"; import { cn } from "@/lib/utils"; import { Calendar } from "@/components/ui/calendar"; +import { UploadDropzone } from "@uploadthing/react"; +import type { UploadRouter } from "@/app/api/uploadthing/core"; interface Props { experience?: GetExp; @@ -58,8 +62,9 @@ export function ExperienceForm({ id: experience?.id, portfolioId, companyName: experience?.companyName ?? "", - jobTitle: experience?.jobTitle ?? "", companyWebsite: experience?.companyWebsite ?? "", + companyLogo: experience?.companyLogo ?? "", + jobTitle: experience?.jobTitle ?? "", jobDescription: experience?.jobDescription ?? "", startedAt: experience?.startedAt ?? new Date(), endedAt: experience?.endedAt, @@ -67,7 +72,7 @@ export function ExperienceForm({ }, }); - const experienceId = form.watch("id"); + const [experienceId, companyLogo] = form.watch(["id", "companyLogo"]); const submit = form.handleSubmit(async (data) => { startTransition(async () => { const newExp = await upsertExperience(data); @@ -80,6 +85,7 @@ export function ExperienceForm({ companyName: newExp.companyName ?? "", jobTitle: newExp.jobTitle ?? "", companyWebsite: newExp.companyWebsite ?? "", + companyLogo: newExp.companyLogo ?? "", jobDescription: newExp.jobDescription ?? "", startedAt: newExp.startedAt ?? new Date(), endedAt: newExp.endedAt, @@ -167,7 +173,51 @@ export function ExperienceForm({ Job Description -