mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-24 20:03:41 +03:00
feat: remove user onboarding on complete (#1387)
https://github.com/StanGirard/quivr/issues/1384 https://github.com/StanGirard/quivr/assets/63923024/ac05456d-2817-4196-8afc-51b34a4d8c5f
This commit is contained in:
parent
0477cce971
commit
1baf9ee5b0
@ -263,3 +263,7 @@ class Repository(ABC):
|
||||
@abstractmethod
|
||||
def update_user_onboarding(self, user_id: UUID, onboarding):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def remove_user_onboarding(self, user_id: UUID):
|
||||
pass
|
||||
|
@ -76,3 +76,19 @@ class Onboarding(Repository):
|
||||
raise HTTPException(404, "User onboarding not updated")
|
||||
|
||||
return OnboardingStates(**response[0])
|
||||
|
||||
def remove_user_onboarding(self, user_id: UUID) -> OnboardingStates | None:
|
||||
"""
|
||||
Remove user onboarding information by user_id
|
||||
"""
|
||||
onboarding_data = (
|
||||
self.db.from_("onboardings")
|
||||
.delete()
|
||||
.match({"user_id": str(user_id)})
|
||||
.execute()
|
||||
).data
|
||||
|
||||
if onboarding_data == []:
|
||||
return None
|
||||
|
||||
return OnboardingStates(**onboarding_data[0])
|
||||
|
@ -13,4 +13,9 @@ def update_user_onboarding(
|
||||
"""Update user onboarding information by user_id"""
|
||||
|
||||
supabase_db = get_supabase_db()
|
||||
return supabase_db.update_user_onboarding(user_id, onboarding)
|
||||
updated_onboarding = supabase_db.update_user_onboarding(user_id, onboarding)
|
||||
|
||||
if all(not value for value in onboarding.dict().values()):
|
||||
supabase_db.remove_user_onboarding(user_id)
|
||||
|
||||
return updated_onboarding
|
@ -9,7 +9,7 @@ from models.databases.supabase.onboarding import (
|
||||
)
|
||||
from models.user_identity import UserIdentity
|
||||
from repository.onboarding.get_user_onboarding import get_user_onboarding
|
||||
from repository.onboarding.udpate_user_onboarding import update_user_onboarding
|
||||
from repository.onboarding.update_user_onboarding import update_user_onboarding
|
||||
|
||||
onboarding_router = APIRouter()
|
||||
|
||||
|
@ -17,17 +17,17 @@ export const useOnboarding = () => {
|
||||
|
||||
const chatId = params?.chatId as string | undefined;
|
||||
|
||||
const {
|
||||
data: onboarding = {
|
||||
const { data } = useQuery({
|
||||
queryFn: getOnboarding,
|
||||
queryKey: [ONBOARDING_DATA_KEY],
|
||||
});
|
||||
|
||||
const onboarding: Onboarding = data ?? {
|
||||
onboarding_a: false,
|
||||
onboarding_b1: false,
|
||||
onboarding_b2: false,
|
||||
onboarding_b3: false,
|
||||
},
|
||||
} = useQuery({
|
||||
queryFn: getOnboarding,
|
||||
queryKey: [ONBOARDING_DATA_KEY],
|
||||
});
|
||||
};
|
||||
|
||||
const updateOnboardingHandler = async (
|
||||
newOnboardingStatus: Partial<Onboarding>
|
||||
|
Loading…
Reference in New Issue
Block a user