Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
sayandedotcom committed Nov 11, 2024
1 parent 69c1952 commit 627228d
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 23 deletions.
2 changes: 2 additions & 0 deletions apps/web/app/(portals)/[profile]/posts/[postId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export default async function Post({ params }: PostProps) {
<PostCard.Description showMore={false}>{data.description}</PostCard.Description>
<PostCard.Tags
allTags={true}
companyName={data.companyName}
locationType={data.jobLocationType}
location={data.jobLocation}
experience={data.jobExperience}
jobType={data.jobType}
Expand Down
2 changes: 2 additions & 0 deletions apps/web/app/(portals)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default function Home() {
</Navigate>
<PostCard.Tags
allTags={false}
companyName={data.companyName}
locationType={data.jobLocationType}
location={data.jobLocation}
experience={data.jobExperience}
jobType={data.jobType}
Expand Down
3 changes: 3 additions & 0 deletions apps/web/app/api/v1/posts/referral/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export async function POST(request: NextRequest) {
}
const response: TPostReferralPost = await request.json();
const session = await auth();

// const key = `RATE_LIMIT:POST:${response.userId}`;
// const currentCount = await redis.incr(key);

Expand Down Expand Up @@ -49,6 +50,8 @@ export async function POST(request: NextRequest) {
jobCode: response.jobCode,
jobCompensation: response.jobCompensation,
jobExperience: response.jobExperience,
jobLocationType: response.jobLocationType,
jobURL: response.jobURL,
jobLocation: response.jobLocation,
jobRole: response.jobRole,
jobType: response.jobType,
Expand Down
35 changes: 30 additions & 5 deletions apps/web/components/custom-components/post-card/post-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const ApplyStatus = ({ totalApplied, acceptLimit }: { totalApplied?: any;
<TooltipDemo text={`${totalApplied} / ${acceptLimit} Applied`}>
<div
className={`flex items-center text-base ${totalApplied === acceptLimit ? "text-red-600" : ""} ${
acceptLimit === 0 ? "hidden" : ""
acceptLimit ? "" : "hidden"
} `}>
<svg height="22" width="22" viewBox="0 0 20 20">
<circle r="10" cx="10" cy="10" fill="#ffff" />
Expand All @@ -129,29 +129,54 @@ export const ApplyStatus = ({ totalApplied, acceptLimit }: { totalApplied?: any;
);
};

export const Tags = ({ allTags, location, experience, jobType, salary, role, skills }) => {
export const Tags = ({
allTags,
companyName,
locationType,
location,
experience,
jobType,
salary,
role,
skills,
}) => {
const { width } = useWindowSize();
console.log(skills);

return (
<>
<Badge
search={role}
className="hover:bg-foreground hover:text-background cursor-pointer border border-black dark:border-gray-200"
variant="secondary">
{companyName}
</Badge>
<Badge
search={role}
className="hover:bg-foreground hover:text-background cursor-pointer border border-black dark:border-gray-200"
variant="secondary">
💼 {role}
</Badge>

<Badge
search={location}
className="hover:bg-foreground hover:text-background cursor-pointer border border-black dark:border-gray-200"
variant="secondary">
📍 {location}
{locationType}
</Badge>

{location && (
<Badge
search={location}
className="hover:bg-foreground hover:text-background cursor-pointer border border-black dark:border-gray-200"
variant="secondary">
📍 {location}
</Badge>
)}
<Badge
search={experience}
className="hover:bg-foreground hover:text-background cursor-pointer border border-black dark:border-gray-200"
variant="secondary">
🧑‍💻 {experience}
🧑‍💻 {experience} + years of experience
</Badge>
<Badge
search={jobType}
Expand Down
10 changes: 8 additions & 2 deletions apps/web/components/custom-components/post-card/post-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function PostCardHeader({
</UsernameNavigate>
</PostHoverCard>
<small id="post-uploaded">{time}</small>
<small id="post-time-left" className="hidden md:block">
<small id="post-time-left" className="hidden capitalize md:block">
{timeLeft}
</small>
</div>
Expand Down Expand Up @@ -110,6 +110,8 @@ PostCard.Description = PostCardDescription;

function PostCardTags({
allTags = false,
companyName,
locationType,
location,
experience,
jobType,
Expand All @@ -118,8 +120,10 @@ function PostCardTags({
skills,
}: {
allTags: boolean;
companyName: string;
locationType: string;
location: string;
experience: string;
experience: number;
jobType: string;
salary: string;
role: string;
Expand All @@ -129,6 +133,8 @@ function PostCardTags({
<div id="post-tags" className="font-heading">
<Tags
allTags={allTags}
companyName={companyName}
locationType={locationType}
location={location}
salary={salary}
role={role}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/ui/badge/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function Badge({ children, search, className, variant, ...props }: Search
return (
<div
onClick={() => {
search && router.push("/search" + "?" + createQueryString("q", search?.toLowerCase()));
search && router.push("/search" + "?" + createQueryString("search_query", search?.toLowerCase()));
}}
className={cn(badgeVariants({ variant }), "mx-1 w-fit", className)}
{...props}>
Expand Down
1 change: 1 addition & 0 deletions apps/web/components/ui/post-forms/async-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const AsyncSelectComponent = ({
return (
<>
<AsyncSelect
closeMenuOnSelect={!isMulti}
getOptionValue={getOptionValue}
onInputChange={onInputChange}
cacheOptions={cacheOptions}
Expand Down
64 changes: 55 additions & 9 deletions apps/web/components/ui/post-forms/referral-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useMutation } from "@tanstack/react-query";
import { format } from "date-fns";
import { CalendarIcon } from "lucide-react";
import { useSession } from "next-auth/react";
import numeral from "numeral";
import { useForm } from "react-hook-form";
import * as z from "zod";

Expand Down Expand Up @@ -107,6 +108,7 @@ export default function ReferralPost() {
jobCode,
jobCompensation,
jobExperience,
jobLocationType,
jobLocation,
jobRole,
jobURL,
Expand All @@ -127,6 +129,7 @@ export default function ReferralPost() {
jobURL,
jobCompensation,
jobExperience,
jobLocationType,
jobLocation,
jobRole,
jobType,
Expand Down Expand Up @@ -233,31 +236,72 @@ export default function ReferralPost() {
if (values?.cityLocation) {
locationString += " - " + values.cityLocation;
}
const finalLocationString = locationString + ")";

let tags = [...values.skills, values.countryLocation, values.stateLocation, values.cityLocation].filter(
(item) => item !== ""
);
let jobLocation;
if (values?.countryLocation) {
jobLocation = values.countryLocation;
}
if (values?.stateLocation) {
jobLocation += ", " + values.stateLocation;
}
if (values?.cityLocation) {
jobLocation += ", " + values.cityLocation + "";
}

const finalLocationString =
values.jobLocation === "Remote Only" ? values.jobLocation : locationString + ")";

console.log(values);
let tags = values.skills.filter((item) => item !== "");
let equity = values.noEquity
? " (No Equity)"
: " (" + values.equityStartingRange + "%-" + values.equityEndingRange + "% Equity)";

// mutate({
let jobCompensation =
values.salaryStartingRange &&
values.currency +
numeral(values.salaryStartingRange).format("0a") +
"-" +
values.currency +
numeral(values.salaryEndingRange).format("0a") +
equity;

// console.log("===========", {
// accept: values.accept,
// acceptLimit: values.acceptLimit,
// companyName: values.companyName,
// description: values.description,
// expiresAt: values.expiresAt,
// jobCode: values.jobCode,
// jobCompensation: values.jobCompensation,
// jobCompensation: jobCompensation,
// jobExperience: values.jobExperience,
// jobLocation: finalLocationString,
// jobLocationType: values.jobLocation,
// jobLocation: jobLocation,
// jobRole: values.jobRole,
// jobType: values.jobType,
// postType: "REFERRALPOST",
// stars: values.stars,
// jobURL: values.jobURL,
// tags: tags,
// });

mutate({
accept: values.accept,
acceptLimit: values.acceptLimit,
companyName: values.companyName,
description: values.description,
expiresAt: values.expiresAt,
jobCode: values.jobCode,
jobCompensation: jobCompensation,
jobExperience: values.jobExperience,
jobLocationType: values.jobLocation,
jobLocation: values.jobLocation === "Remote Only" ? null : jobLocation,
jobRole: values.jobRole,
jobType: values.jobType,
postType: "REFERRALPOST",
stars: values.stars,
jobURL: values.jobURL,
tags: tags,
});
}
// console.log("form.watch", form.watch("noEquity"));

Expand Down Expand Up @@ -551,7 +595,7 @@ export default function ReferralPost() {
type="text"
///@ts-ignore
icon={form.watch("currency")?.value ?? "$"}
placeholder="10,000"
placeholder="50,000"
// value={numeral(field.value).format("0,0")}
{...field}
/>
Expand Down Expand Up @@ -697,6 +741,7 @@ export default function ReferralPost() {
Country Location <Required />
</FormLabel>
<AsyncSelectComponent
isDisabled={form.watch("jobLocation") === "Remote Only"}
isMulti={false}
loadOptions={countriesList}
onChange={(data) => {
Expand Down Expand Up @@ -726,6 +771,7 @@ export default function ReferralPost() {
State Location
</FormLabel>
<AsyncSelectComponent
isDisabled={form.watch("jobLocation") === "Remote Only"}
isMulti={false}
loadOptions={statesList}
onChange={(data) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/ui/post-forms/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const SelectComponent = ({
return (
<>
<Comp
closeMenuOnSelect={false}
closeMenuOnSelect={!isMulti}
getOptionValue={getOptionValue}
onInputChange={onInputChange}
loadingMessage={() => <Loader2 className="mx-auto my-2 h-4 w-4 animate-spin" />}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/lib/validators/referral-post-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ export const referralPostValidator = z.object({
.optional()
// .parse((value) => numeral(value).format("0,0")),
// .refine((value) => numeral(value).format("0,0"))
.transform((value) => +value.replace(/,/g, "")),
.transform((value) => +value?.replace(/,/g, "")),
salaryEndingRange: z.coerce
.string({
// required_error: "Name is required",
// invalid_type_error: "Name must be a string",
})
.optional()
.transform((value) => +value.replace(/,/g, "")),
.transform((value) => +value?.replace(/,/g, "")),
equityStartingRange: z.coerce
.number({
required_error: "Name is required",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/types/next-auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare module "next-auth" {
interface Session {
error?: "RefreshTokenError";
user: {
id: string;
id: PrismaUser["id"];
userName: PrismaUser["userName"];
stripeCustomerId?: PrismaUser["stripeCustomerId"];
stars: PrismaUser["stars"];
Expand Down
1 change: 1 addition & 0 deletions apps/web/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type TPostReferralPost = {
jobCode: Posts["jobCode"];
jobCompensation: Posts["jobCompensation"];
jobExperience: Posts["jobExperience"];
jobLocationType: Posts["jobLocationType"];
jobLocation: Posts["jobLocation"];
jobRole: Posts["jobRole"];
jobType: Posts["jobType"];
Expand Down
5 changes: 3 additions & 2 deletions packages/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ model User {
overlayImage String? @map("overlay_image")
name String?
bio String?
locale String?
link String?
location String?
stars Int? @default(0)
stripeCustomerId String? @unique @map("stripe_customer_id")
Expand Down Expand Up @@ -86,7 +86,8 @@ model Posts {
expiresAt DateTime? @map("expires_at")
jobRole String? @map("job_role")
jobType String? @map("job_type")
jobExperience String? @map("job_experience")
jobExperience Int? @map("job_experience")
jobLocationType String? @map("job_location_type")
jobLocation String? @map("job_location")
jobCompensation String? @map("job_compensation")
userId String
Expand Down

0 comments on commit 627228d

Please sign in to comment.