Skip to content

Commit

Permalink
fixed activate listing bugs, fixed bugs related to clothing type, sti…
Browse files Browse the repository at this point in the history
…ll want to add clothing type to listing display
  • Loading branch information
EYoung21 committed Dec 9, 2024
1 parent 80f4a94 commit 8b0f026
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
13 changes: 10 additions & 3 deletions app/actions/listing/create-listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const presenceCheckBaseFields = (formData: FormData) => {
"firmonprice", //firmonprice should be required
];

// const clothingRequiredFields = [

// ]

for (const field of baseRequiredFields) {
if (!formData.has(field)) {
console.error(`Missing required field: ${field}`);
Expand Down Expand Up @@ -70,6 +74,7 @@ export async function createListing(userId: number, formData: FormData) {
description: formData.get("description"),
type: formData.get("type"),
category: formData.get("category"),
//
condition: formData.get("condition"),
firmonprice: formData.get("firmonprice"), //added this to fix bug
brand: formData.get("brand"),
Expand All @@ -89,7 +94,7 @@ export async function createListing(userId: number, formData: FormData) {
apparelGender: formData.get("apparelGender"),
};
}

console.log("Listing Data: \n", listingData)
const validatedListingFormData =
createListingFormDataSchema.parse(listingData);

Expand Down Expand Up @@ -117,12 +122,14 @@ export async function createListing(userId: number, formData: FormData) {
category: validatedListingFormData.category,
condition: validatedListingFormData.condition,
acceptedPaymentTypes: validatedListingFormData.acceptedPaymentTypes,
// apparel: validatedListingFormData.apparelGender,
// size: validatedListingFormData.apparelSize,
// apparel: validatedListingFormData.apparelGender, //new
// size: validatedListingFormData.apparelSize, //new
brand: validatedListingFormData.brand,
//brand is another optional thing, so is also commented out ?? (the commenting out is something theron had originally done for some reason...)
//apparel and size commented out?
price: validatedListingFormData.price,


},
});
revalidatePath("/");
Expand Down
1 change: 1 addition & 0 deletions app/create/components/CreateListingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const CreateListingForm = ({ userId }: CreateListingFormProps) => {
);

const onFormSubmitError = useCallback((error: any) => {
console.log("failed to submit error")
console.log(error);
}, []);

Expand Down
4 changes: 2 additions & 2 deletions app/create/components/ListingCategoryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const ListingCategoryForm = () => {
<>
<p className="m-0 font-medium text-xl">Choose a size</p>
<Controller
name="clothingItemSize"
name="apparelSize"
control={control}
render={({ field: { onChange } }) => (
<Select
Expand All @@ -67,7 +67,7 @@ export const ListingCategoryForm = () => {
/>
<p className="m-0 font-medium text-xl">Choose a gender</p>
<Controller
name="clothingItemTypes"
name="apparelGender"
control={control}
render={({ field: { onChange } }) => (
<Select
Expand Down
2 changes: 1 addition & 1 deletion components/DeactivateListingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const DeactivateListingButton = ({
);
};

export default DeactivateListingButton;
export default DeactivateListingButton;
4 changes: 2 additions & 2 deletions dtos/listing/create-listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export const createListingFormDataSchema = z.object({
message: "Invalid condition",
}),
}),
apparelSize: z.array(z.string()).optional(),
apparelGender: z.array(z.string()).optional(),
apparelSize: z.string().optional(),
apparelGender: z.string().optional(),
brand: z.string().optional(), //brand is optional
});

Expand Down

0 comments on commit 8b0f026

Please sign in to comment.