Skip to content

Commit

Permalink
fix(ui/api): updated adduserfile api service, add user route
Browse files Browse the repository at this point in the history
  • Loading branch information
cephaschapa committed Mar 11, 2024
1 parent 40793c6 commit 0b9fb3a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
11 changes: 10 additions & 1 deletion app/src/app/[lng]/data/review/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export default function ReviewPage({

const [isConfirming, setIsConfirming] = useState<boolean>(false);

const { data: userInfo, isLoading: isUserInfoLoading } =
api.useGetUserInfoQuery();

const { data: inventory } = api.useGetInventoryQuery(
userInfo?.defaultInventoryId!,
{ skip: !userInfo },
);
const cityId = inventory?.city.cityId;

const onConfirm = async () => {
setIsConfirming(true);
try {
Expand All @@ -79,7 +88,7 @@ export default function ReviewPage({
formData.append("data", file, file.name);
}

await addUserFile(formData).then(() => {
await addUserFile({ formData, cityId }).then(() => {
// TODO
// Trigger notification to user
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/api/v0/city/[city]/file/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const POST = apiHandler(async (req: NextRequest, context) => {

const fileData = {
userId: userId,
cityId: formData.get("cityId"),
cityId: context.params.city,
fileReference: formData.get("fileReference"),
url: formData.get("url"),
data: buffer,
Expand Down
2 changes: 0 additions & 2 deletions app/src/components/Tabs/my-files-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ const MyFilesTab: FC<MyFilesTabProps> = ({
lastUpdated: "",
});

console.log(cityData);

const [fileData, setFileData] = useState<UserFileAttributes>();

return (
Expand Down
4 changes: 2 additions & 2 deletions app/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ export const api = createApi({
transformResponse: (response: { data: any }) => response.data,
}),
addUserFile: builder.mutation<UserFileResponse, any>({
query: (formData) => {
query: ({ formData, cityId }) => {
return {
method: "POST",
url: `/user/file`,
url: `city/${cityId}/file`,
body: formData,
};
},
Expand Down

0 comments on commit 0b9fb3a

Please sign in to comment.