File tree Expand file tree Collapse file tree 3 files changed +39
-10
lines changed Expand file tree Collapse file tree 3 files changed +39
-10
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ async function handlePropose() {
5353
5454 router .go (0 );
5555 } catch (err ) {
56- alert (err .message );
56+ alert (err .data );
5757 }
5858}
5959async function handleAccept(shortcode : string ) {
@@ -65,7 +65,20 @@ async function handleAccept(shortcode: string) {
6565
6666 router .go (0 );
6767 } catch (err ) {
68- alert (err .message );
68+ alert (err .data );
69+ }
70+ }
71+
72+ async function handleRevoke(shortcode : string ) {
73+ try {
74+ await $fetch (' /api/family/proposal' , {
75+ method: ' DELETE' ,
76+ body: { shortcode }
77+ });
78+
79+ router .go (0 );
80+ } catch (err ) {
81+ alert (err .data );
6982 }
7083}
7184 </script >
@@ -153,9 +166,20 @@ async function handleAccept(shortcode: string) {
153166 <div class =" flex flex-col items-start" >
154167 <strong >{{ proposal.proposee }}</strong >
155168 </div >
156- <div class =" flex items-start gap-3" >
157- <span class =" cursor-pointer bg-yellow-400 p-1 text-sm text-white" >
158- Pending
169+ <div
170+ class =" flex items-start gap-3"
171+ @click =" handleRevoke(proposal.proposee)" >
172+ <span
173+ class =" group grid cursor-pointer bg-yellow-400 p-1 text-sm text-white duration-300 hover:bg-red-600 motion-reduce:transition-none" >
174+ <!-- We shove them into the same cell in a grid to essentially overlay them for the transition. duration-300 is not inherited. -->
175+ <div
176+ class =" col-start-1 row-start-1 duration-300 group-hover:opacity-0" >
177+ Pending
178+ </div >
179+ <div
180+ class =" col-start-1 row-start-1 opacity-0 duration-300 group-hover:opacity-100" >
181+ Revoke?
182+ </div >
159183 </span >
160184 </div >
161185 </div >
@@ -168,6 +192,7 @@ async function handleAccept(shortcode: string) {
168192 </strong >
169193 <div class =" flex gap-4" >
170194 <input
195+ @keyup.enter =" handlePropose"
171196 type =" text"
172197 class =" flex-grow"
173198 placeholder =" e.g. nj421"
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ async function handleSubmit() {
160160
161161 <SurveyGroup label =" Gender:" :required =" true" >
162162 <SurveySelect
163- :options =" ['male', 'female', 'other', 'na ']"
163+ :options =" ['male', 'female', 'other', 'n/a ']"
164164 :labels =" ['Male', 'Female', 'Other', 'Prefer not to say']"
165165 name =" gender"
166166 v-model =" formData.gender"
Original file line number Diff line number Diff line change @@ -124,7 +124,10 @@ export const family = factory
124124 . where ( eq ( students . shortcode , proposee ) ) ;
125125
126126 if ( proposeeInDb . length == 0 ) {
127- return ctx . text ( 'Invalid proposee.' , 400 ) ;
127+ return ctx . text (
128+ 'Invalid proposee. Have they signed in to MaDs yet?' ,
129+ 400
130+ ) ;
128131 }
129132
130133 // 3 max proposals
@@ -140,10 +143,11 @@ export const family = factory
140143 }
141144
142145 // No dupe proposals
143- currProposals . forEach ( ( { proposer : _proposer , proposee : _proposee } ) => {
144- if ( _proposee == proposee )
146+ for ( const proposal of currProposals ) {
147+ if ( proposal . proposee == proposee ) {
145148 return ctx . text ( 'You have already proposed to this user.' , 400 ) ;
146- } ) ;
149+ }
150+ }
147151
148152 await db . insert ( proposals ) . values ( {
149153 proposer : proposer ,
You can’t perform that action at this time.
0 commit comments