mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-05 21:54:47 -04:00
Fix file upload
This commit is contained in:
@@ -26,8 +26,8 @@ function RegisterComponent() {
|
||||
const [age, setAge] = useState(0);
|
||||
const [personalityType, setPersonalityType] = useState('');
|
||||
const [conflictStyle, setConflictStyle] = useState('');
|
||||
const [image, setImage] = useState<string | null>(null);
|
||||
const [key, setKey] = useState<string | null>(null);
|
||||
const [image, setImage] = useState<string>('');
|
||||
const [key, setKey] = useState<string>('');
|
||||
const [images, setImages] = useState<string[]>([]);
|
||||
const [keys, setKeys] = useState<string[]>([]);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
@@ -75,7 +75,7 @@ function RegisterComponent() {
|
||||
setImages([])
|
||||
setKeys(profile?.images)
|
||||
await Promise.all(
|
||||
(profile?.images || []).map(async (img) => {
|
||||
(profile?.images || []).map(async (img: string) => {
|
||||
await parseImage(img, setImages, true);
|
||||
})
|
||||
);
|
||||
@@ -390,7 +390,7 @@ function RegisterComponent() {
|
||||
name="age"
|
||||
type="number"
|
||||
value={age}
|
||||
onChange={(e) => setAge(e.target.value)}
|
||||
onChange={(e) => setAge(Number(e.target.value))}
|
||||
className="appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm"
|
||||
// placeholder=""
|
||||
/>
|
||||
@@ -405,7 +405,7 @@ function RegisterComponent() {
|
||||
name="location"
|
||||
type="text"
|
||||
value={location}
|
||||
maxLength="100"
|
||||
maxLength={100}
|
||||
onChange={(e) => setLocation(e.target.value)}
|
||||
className="appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm"
|
||||
placeholder="City, Country"
|
||||
@@ -462,7 +462,7 @@ function RegisterComponent() {
|
||||
<input
|
||||
type="text"
|
||||
value={newInterest}
|
||||
maxLength="100"
|
||||
maxLength={100}
|
||||
onChange={(e) => setNewInterest(e.target.value)}
|
||||
onFocus={() => setShowDropdown(true)}
|
||||
onKeyDown={handleKeyDown}
|
||||
@@ -588,7 +588,7 @@ function RegisterComponent() {
|
||||
rows={4}
|
||||
// required
|
||||
value={description}
|
||||
maxLength="30000"
|
||||
maxLength={30000}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
className="appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm"
|
||||
placeholder="Tell us about yourself, your background, and what you're looking for."
|
||||
@@ -604,7 +604,7 @@ function RegisterComponent() {
|
||||
name="contactInfo"
|
||||
rows={2}
|
||||
value={contactInfo}
|
||||
maxLength="5000"
|
||||
maxLength={5000}
|
||||
onChange={(e) => setContactInfo(e.target.value)}
|
||||
className="appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm"
|
||||
placeholder="How can people reach you? (Email, social media, phone, Google Forms, etc.)"
|
||||
|
||||
@@ -9,8 +9,8 @@ interface FilterProps {
|
||||
interests: string[];
|
||||
causeAreas: string[];
|
||||
searchQuery: string;
|
||||
minAge?: number;
|
||||
maxAge?: number;
|
||||
minAge?: number | null;
|
||||
maxAge?: number | null;
|
||||
};
|
||||
onFilterChange: (key: string, value: any) => void;
|
||||
onShowFilters: (value: boolean) => void;
|
||||
|
||||
@@ -11,27 +11,29 @@ export const dynamic = "force-dynamic";
|
||||
|
||||
const renderImages = false;
|
||||
|
||||
const initialState = {
|
||||
gender: '',
|
||||
minAge: null as number | null,
|
||||
maxAge: null as number | null,
|
||||
interests: [] as string[],
|
||||
causeAreas: [] as string[],
|
||||
searchQuery: '',
|
||||
};
|
||||
|
||||
export default function ProfilePage() {
|
||||
const [profiles, setProfiles] = useState<ProfileData[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [showFilters, setShowFilters] = useState(true);
|
||||
const [totalUsers, setTotalUsers] = useState<number>(0);
|
||||
const [images, setImages] = useState<string[]>([])
|
||||
const [filters, setFilters] = useState({
|
||||
gender: '',
|
||||
minAge: null,
|
||||
maxAge: null,
|
||||
interests: [] as string[],
|
||||
causeAreas: [] as string[],
|
||||
searchQuery: '',
|
||||
});
|
||||
const [filters, setFilters] = useState(initialState);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const getCount = async () => {
|
||||
const countResponse = await fetch('/api/profiles/count');
|
||||
if (countResponse.ok) {
|
||||
const { count } = await countResponse.json();
|
||||
const {count} = await countResponse.json();
|
||||
setTotalUsers(count);
|
||||
}
|
||||
};
|
||||
@@ -45,8 +47,8 @@ export default function ProfilePage() {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (filters.gender) params.append('gender', filters.gender);
|
||||
if (filters.minAge) params.append('minAge', filters.minAge);
|
||||
if (filters.maxAge) params.append('maxAge', filters.maxAge);
|
||||
if (filters.minAge) params.append('minAge', filters.minAge.toString());
|
||||
if (filters.maxAge) params.append('maxAge', filters.maxAge.toString());
|
||||
if (filters.interests.length > 0) params.append('interests', filters.interests.join(','));
|
||||
if (filters.causeAreas.length > 0) params.append('causeAreas', filters.causeAreas.join(','));
|
||||
if (filters.searchQuery) params.append('search', filters.searchQuery);
|
||||
@@ -116,12 +118,7 @@ export default function ProfilePage() {
|
||||
};
|
||||
|
||||
const resetFilters = () => {
|
||||
setFilters({
|
||||
gender: '',
|
||||
interests: [],
|
||||
causeAreas: [],
|
||||
searchQuery: '',
|
||||
});
|
||||
setFilters(initialState);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -31,7 +31,7 @@ export async function parseImage(img: string, setImage: any, batch = false) {
|
||||
}
|
||||
if (url) {
|
||||
if (batch) {
|
||||
setImage(prev => [...prev, url]);
|
||||
setImage((prev: any) => [...prev, url]);
|
||||
} else {
|
||||
setImage(url);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {useEffect, useState} from "react";
|
||||
import {parseImage} from "@/lib/client/media";
|
||||
import LoadingSpinner from "@/lib/client/LoadingSpinner";
|
||||
|
||||
export function getProfile(url, header = null) {
|
||||
export function getProfile(url: string, header: any = null) {
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [userData, setUserData] = useState<any>(null);
|
||||
@@ -22,7 +22,7 @@ export function getProfile(url, header = null) {
|
||||
|
||||
setImages([]);
|
||||
await Promise.all(
|
||||
(data?.profile?.images || []).map(async (img) => {
|
||||
(data?.profile?.images || []).map(async (img: string) => {
|
||||
await parseImage(img, setImages, true);
|
||||
})
|
||||
);
|
||||
@@ -64,7 +64,7 @@ export function getProfile(url, header = null) {
|
||||
|
||||
< ul
|
||||
className="flex flex-wrap gap-2 mt-1">
|
||||
{userData?.profile?.desiredConnections.map((value, idx) => (
|
||||
{userData?.profile?.desiredConnections.map((value: any, idx: number) => (
|
||||
<li
|
||||
key={idx}
|
||||
className="px-3 py-1 text-sm bg-blue-100 text-blue-800 dark:text-white dark:bg-gray-700 rounded-full hover:bg-gray-200 transition"
|
||||
@@ -149,7 +149,7 @@ export function getProfile(url, header = null) {
|
||||
< ul
|
||||
className="flex flex-wrap gap-2 mt-1">
|
||||
{
|
||||
userData.profile.intellectualInterests.map((value, idx) => (
|
||||
userData.profile.intellectualInterests.map((value: any, idx: number) => (
|
||||
<li
|
||||
key={idx}
|
||||
className="px-3 py-1 text-sm bg-blue-100 text-blue-800 dark:text-white dark:bg-gray-700 rounded-full hover:bg-gray-200 transition"
|
||||
@@ -173,7 +173,7 @@ export function getProfile(url, header = null) {
|
||||
< ul
|
||||
className="flex flex-wrap gap-2 mt-1">
|
||||
{
|
||||
userData.profile.causeAreas.map((value, idx) => (
|
||||
userData.profile.causeAreas.map((value: any, idx: number) => (
|
||||
<li
|
||||
key={idx}
|
||||
className="px-3 py-1 text-sm bg-blue-100 text-blue-800 dark:text-white dark:bg-gray-700 rounded-full hover:bg-gray-200 transition"
|
||||
@@ -217,7 +217,7 @@ export function getProfile(url, header = null) {
|
||||
< ul
|
||||
className="flex flex-wrap gap-2 mt-1">
|
||||
{
|
||||
userData.profile.promptAnswers.map((value, idx) => (
|
||||
userData.profile.promptAnswers.map((value: any, idx: any) => (
|
||||
<li
|
||||
key={idx}
|
||||
// className="px-3 py-1 text-sm bg-gray-100 rounded-full hover:bg-gray-200 transition"
|
||||
|
||||
Reference in New Issue
Block a user