massari
massari
WWasp-lang
Created by massari on 8/29/2024 in #đŸ™‹questions
OpenSaaS add entities into useAuth/getMe or User entity
@kapa.ai I'm not seeing what I'm doing wrong. I pass an object which includes the id and the data with :
await updateRestaurantInfo({ id: user?.id!, data: updatedData });
await updateRestaurantInfo({ id: user?.id!, data: updatedData });
` and my operation just look like this:
export const updateRestaurantInfo: UpdateUserById<{ id: string; data: Partial<User> }, User> = async (
{ id, data },
context
) => {
if (!context.user) {
throw new HttpError(401);
}

return context.entities.User.update({
where: { id },
data: {
restaurantName: data.restaurantName,
restaurantAddress: data.restaurantAddress,
restaurantPhone: data.restaurantPhone ? Number(data.restaurantPhone) : null,
restaurantWebsite: data.restaurantWebsite,
restaurantDescription: data.restaurantDescription,
},
});
};
export const updateRestaurantInfo: UpdateUserById<{ id: string; data: Partial<User> }, User> = async (
{ id, data },
context
) => {
if (!context.user) {
throw new HttpError(401);
}

return context.entities.User.update({
where: { id },
data: {
restaurantName: data.restaurantName,
restaurantAddress: data.restaurantAddress,
restaurantPhone: data.restaurantPhone ? Number(data.restaurantPhone) : null,
restaurantWebsite: data.restaurantWebsite,
restaurantDescription: data.restaurantDescription,
},
});
};
` my "User" modal contains those restaurant entities, but it still throw the error: error TS2554: Expected 2 arguments, but got 1.
27 replies
WWasp-lang
Created by massari on 8/29/2024 in #đŸ™‹questions
OpenSaaS add entities into useAuth/getMe or User entity
@kapa.ai I'm trying to update user byid just like this:
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
const updatedData = {
...formData,
restaurantPhone: formData.restaurantPhone ? Number(formData.restaurantPhone) : null,
};

await updateUserById({ id: user?.id!, data: updatedData });
alert('Restaurant information updated successfully!');
} catch (error) {
if (error instanceof HttpError) {
alert(`Error: ${error.message}`);
} else {
console.error('Failed to update restaurant info:', error);
}
}
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
const updatedData = {
...formData,
restaurantPhone: formData.restaurantPhone ? Number(formData.restaurantPhone) : null,
};

await updateUserById({ id: user?.id!, data: updatedData });
alert('Restaurant information updated successfully!');
} catch (error) {
if (error instanceof HttpError) {
alert(`Error: ${error.message}`);
} else {
console.error('Failed to update restaurant info:', error);
}
}
};
` but get error: [ Wasp ] ext-src/user/RestaurantPage.tsx(45,19): error TS2554: Expected 2 arguments, but got 1.
27 replies
WWasp-lang
Created by massari on 8/29/2024 in #đŸ™‹questions
OpenSaaS add entities into useAuth/getMe or User entity
@kapa.ai I'm using the default src/user/operations.ts of OpenSaaS, do you know where the error is in there maybe?
27 replies
WWasp-lang
Created by massari on 8/29/2024 in #đŸ™‹questions
OpenSaaS add entities into useAuth/getMe or User entity
I'm using the default src/user/operations.ts of OpenSaaS, do you know where the error is in there maybe?
27 replies
WWasp-lang
Created by massari on 8/29/2024 in #đŸ™‹questions
OpenSaaS add entities into useAuth/getMe or User entity
@kapa.ai error: [ Wasp ] ext-src/user/AccountPage.tsx(34,46): error TS2322: Type 'GetResult<{ id: string; createdAt: Date; email: string; username: string; lastActiveTimestamp: Date; isAdmin: boolean; stripeId: string; checkoutSessionId: string; subscriptionStatus: string; ... 13 more ...; restaurantImageUrl: string; }, unknown> & {}' is not assignable to type 'AuthUser'. [ Wasp ] Property 'identities' is missing in type 'GetResult<{ id: string; createdAt: Date; email: string; username: string; lastActiveTimestamp: Date; isAdmin: boolean; stripeId: string; checkoutSessionId: string; subscriptionStatus: string; ... 13 more ...; restaurantImageUrl: string; }, unknown> & {}' but required in type '{ identities: { email: { id: string; isEmailVerified: boolean; emailVerificationSentAt: string; passwordResetSentAt: string; }; }; }'.
27 replies
WWasp-lang
Created by massari on 8/29/2024 in #đŸ™‹questions
OpenSaaS add entities into useAuth/getMe or User entity
@kapa.ai I've this in my AccountPage with also a Form to update user (restaurant) information:
const [restaurantInfo, setRestaurantInfo] = useState({
restaurantName: user.restaurantName || '',
restaurantAddress: user.restaurantAddress || '',
restaurantPhone: user.restaurantPhone || '',
restaurantWebsite: user.restaurantWebsite || '',
restaurantDescription: user.restaurantDescription || '',
});

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const { name, value } = e.target;
setRestaurantInfo({ ...restaurantInfo, [name]: value });
};

const handleSave = async () => {
try {
const updatedInfo = {
...restaurantInfo,
restaurantPhone: Number(restaurantInfo.restaurantPhone),
};

await updateCurrentUser(updatedInfo, { user });
alert('Restaurant information updated successfully.');
} catch (error) {
console.error(error);
alert('Failed to update restaurant information.');
}
};
const [restaurantInfo, setRestaurantInfo] = useState({
restaurantName: user.restaurantName || '',
restaurantAddress: user.restaurantAddress || '',
restaurantPhone: user.restaurantPhone || '',
restaurantWebsite: user.restaurantWebsite || '',
restaurantDescription: user.restaurantDescription || '',
});

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const { name, value } = e.target;
setRestaurantInfo({ ...restaurantInfo, [name]: value });
};

const handleSave = async () => {
try {
const updatedInfo = {
...restaurantInfo,
restaurantPhone: Number(restaurantInfo.restaurantPhone),
};

await updateCurrentUser(updatedInfo, { user });
alert('Restaurant information updated successfully.');
} catch (error) {
console.error(error);
alert('Failed to update restaurant information.');
}
};
My model looks like:
model User {
id String @id @default(uuid())
createdAt DateTime @default(now())

email String? @unique
username String? @unique
lastActiveTimestamp DateTime @default(now())
isAdmin Boolean @default(false)

.....
....
...
..

firstName String?
lastName String?

restaurantId String? @unique
restaurantCreatedAt DateTime @default(now())
restaurantName String?
restaurantAddress String?
restaurantPhone Int?
restaurantWebsite String?
restaurantDescription String?
restaurantImageUrl String?
}
model User {
id String @id @default(uuid())
createdAt DateTime @default(now())

email String? @unique
username String? @unique
lastActiveTimestamp DateTime @default(now())
isAdmin Boolean @default(false)

.....
....
...
..

firstName String?
lastName String?

restaurantId String? @unique
restaurantCreatedAt DateTime @default(now())
restaurantName String?
restaurantAddress String?
restaurantPhone Int?
restaurantWebsite String?
restaurantDescription String?
restaurantImageUrl String?
}
But I get error: - SDK build failed with exit code: 2
27 replies
WWasp-lang
Created by Suchitk on 6/24/2024 in #đŸ™‹questions
How to add custom Sign up field that refers another entity
No description
13 replies
WWasp-lang
Created by Suchitk on 6/24/2024 in #đŸ™‹questions
How to add custom Sign up field that refers another entity
@miho also thank from me ^^ couldn't figure it out without your help. That should be in the OpenSaaS Documentation
13 replies
WWasp-lang
Created by P1511 on 8/19/2024 in #đŸ™‹questions
How do i connect APIs to Open SaaS ?
You seem to have some port issues, I would recommend you to close each terminal tab (assuming db, etc. are running), close ur IDE and reopen everything. Check also if the ports ur using are fine, because as I remember 3000 is default in OpenSaaS
260 replies