feat: Ensure all owner-created shops are globally listed using the owner's user ID as the shop ID.
This commit is contained in:
@@ -134,12 +134,17 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
: [...s.users, nextUser];
|
||||
|
||||
let shops = s.shops;
|
||||
if (/*role === 'barbearia' && shopId*/true) {
|
||||
const exists = shops.some((shop) => shop.id === shopId);
|
||||
// Removida condicional restrita (/*role === 'barbearia' && shopId*/true)
|
||||
// para garantir que *todas* as shops criadas por donos fiquem listadas no array maestro global
|
||||
// para qualquer utilizador que faça fetch deste `id`
|
||||
if (data.shop_name) {
|
||||
const shopIdFromOwner = userId; // O dono usa o user ID como shop ID
|
||||
const exists = shops.some((shop) => shop.id === shopIdFromOwner);
|
||||
|
||||
if (!exists) {
|
||||
const shopName = data.shop_name?.trim() || `Barbearia ${displayName}`;
|
||||
const shopName = data.shop_name.trim();
|
||||
const shop: BarberShop = {
|
||||
id: 'shopId',
|
||||
id: shopIdFromOwner,
|
||||
name: shopName,
|
||||
address: 'Endereço a definir',
|
||||
rating: 0,
|
||||
|
||||
Reference in New Issue
Block a user