No Description

commentAjaxLogi.ts 491B

123456789101112131415161718192021222324252627282930
  1. import { favorComment, unFavorComment } from '@/services/comment';
  2. export const toggleFavor = async ({
  3. favored,
  4. id,
  5. commentId,
  6. userId,
  7. }: {
  8. id: string;
  9. favored: boolean;
  10. commentId: string;
  11. userId: number;
  12. }) => {
  13. let responseData;
  14. if (!favored) {
  15. responseData = await favorComment({
  16. id,
  17. commentId,
  18. userId,
  19. })
  20. } else {
  21. responseData = await unFavorComment({
  22. id,
  23. commentId,
  24. userId,
  25. })
  26. }
  27. return responseData.data;
  28. }