Split Slug from Creator
This commit is contained in:
@@ -22,7 +22,7 @@ const isReserved = computed(() => reservationState.value === 'reserved');
|
||||
|
||||
const isOperationPending = ref(false);
|
||||
const reservationState = ref(null);
|
||||
const reservationId = ref(null);
|
||||
const reservationId = ref(v7());
|
||||
|
||||
let timeout = null;
|
||||
const handleInput = () => {
|
||||
@@ -40,21 +40,19 @@ const checkNameAvailability = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
const id = v7();
|
||||
isOperationPending.value = true;
|
||||
reservationState.value = "loading";
|
||||
await client.post(
|
||||
`/api/creators/@${encodeURIComponent(name.value)}/reserve`,
|
||||
{reservationId: id}
|
||||
{reservationId: reservationId.value}
|
||||
);
|
||||
reservationState.value = "reserved";
|
||||
reservationId.value = id;
|
||||
} catch (error) {
|
||||
reservationState.value = "unavailable"; // Handle API failure case
|
||||
reservationId.value = undefined;
|
||||
} finally {
|
||||
emits('update:name', name);
|
||||
emits('update:creatorNameReservationId', reservationId);
|
||||
emits('update:name', name.value);
|
||||
emits('update:creatorNameReservationId', reservationId.value);
|
||||
isOperationPending.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user