3131import AlbumService from " @/services/album-service" ;
3232import Dialog from " primevue/dialog" ;
3333import InputText from " @/components/forms/basic/InputText.vue" ;
34- import { computed , ref , watch } from " vue" ;
34+ import { computed , ref } from " vue" ;
3535import { useRouter } from " vue-router" ;
3636import FloatLabel from " primevue/floatlabel" ;
3737import Button from " primevue/button" ;
3838import { useToast } from " primevue/usetoast" ;
3939import { useTogglablesStateStore } from " @/stores/ModalsState" ;
4040import { storeToRefs } from " pinia" ;
4141import { onKeyPressed } from " @vueuse/core" ;
42-
43- const props = defineProps <{
44- parentId: string | null ;
45- }>();
42+ import { usePhotoRoute } from " @/composables/photo/photoRoute" ;
4643
4744const togglableStore = useTogglablesStateStore ();
4845const { is_create_album_visible } = storeToRefs (togglableStore );
49-
50- const parentId = ref ( props . parentId );
46+ const router = useRouter ();
47+ const { getParentId } = usePhotoRoute ( router );
5148
5249const toast = useToast ();
53- const router = useRouter ();
5450
5551const title = ref <string | undefined >(undefined );
5652
@@ -63,12 +59,12 @@ function create() {
6359
6460 AlbumService .createAlbum ({
6561 title: title .value as string ,
66- parent_id: parentId . value ,
62+ parent_id: getParentId () ?? null ,
6763 })
6864 .then ((response ) => {
6965 title .value = undefined ;
7066 is_create_album_visible .value = false ;
71- AlbumService .clearCache (parentId . value );
67+ AlbumService .clearCache (getParentId () );
7268 router .push (` /gallery/${response .data } ` );
7369 })
7470 .catch ((error ) => {
@@ -77,12 +73,4 @@ function create() {
7773}
7874
7975onKeyPressed (" Enter" , () => is_create_album_visible .value && isValid .value && create ());
80-
81- watch (
82- () => props .parentId ,
83- (newAlbumID , _oldAlbumID ) => {
84- title .value = undefined ;
85- parentId .value = newAlbumID as string | null ;
86- },
87- );
8876 </script >
0 commit comments